diff options
Diffstat (limited to 'walk/atom.go')
-rw-r--r-- | walk/atom.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/walk/atom.go b/walk/atom.go index 13ad2ff..dfe5fe4 100644 --- a/walk/atom.go +++ b/walk/atom.go @@ -43,12 +43,24 @@ func NewAtomNumber(v float64) Atom { data: math.Float64bits(v), } } +func (v Atom) Number() float64 { + if v.Typ != AtomNumber { + panic("Tried to use non-number as number") + } + return math.Float64frombits(v.data) +} func NewAtomTerminal(v ValueTerminal) Atom { return Atom { Typ: AtomTerminal, data: uint64(v), } } +func (v Atom) Terminal() ValueTerminal { + if v.Typ != AtomTerminal { + panic("Tried to use non-terminal as terminal") + } + return ValueTerminal(v.data) +} func NewAtomStringTerminal() Atom { return Atom { Typ: AtomStringTerminal, |