aboutsummaryrefslogtreecommitdiff
path: root/ops.go
diff options
context:
space:
mode:
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}
+}