aboutsummaryrefslogtreecommitdiff
path: root/ops.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-10-13 13:39:50 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-10-13 13:39:50 +0200
commit0b9501345b0685d31b355f2e85d3121f398b28c8 (patch)
treecbd5f2326a42168386cb9ffa1519c967554f9033 /ops.go
parent5cfc3f44d3aa5a30a6d590913a4e1eff10db0d77 (diff)
Cleanup
Diffstat (limited to 'ops.go')
-rw-r--r--ops.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/ops.go b/ops.go
index 73a2d38..bca0acd 100644
--- a/ops.go
+++ b/ops.go
@@ -2,6 +2,7 @@ package main
import (
"container/list"
+ "fmt"
"log"
)
@@ -81,3 +82,26 @@ func (m Element) sub(n Element) Element {
}
return m.sub(n.prev()).prev()
}
+
+// Equals compares two elements
+func (m Element) Equals(n Element) bool {
+ return m.Value == n.Value
+}
+
+// String pretty-prints value
+func (m Element) String() string {
+ return fmt.Sprint(m.Value)
+}
+
+// Scan returns n-th Element
+func Scan(n int) Element {
+ if n > alphabet.Len() {
+ log.Fatal("out of range ", n)
+ return Element{}
+ }
+ e := alphabet.Front()
+ for i := 0; i < n; i++ {
+ e = e.Next()
+ }
+ return Element{e}
+}