lots of additions

- added Makefile for building
- added math constant support
- added many more calc operators and functions
- added more stack manipulation functions
This commit is contained in:
2023-10-30 19:13:24 +01:00
parent 3b48674f2b
commit 4ace2b4385
5 changed files with 286 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ func (s *Stack) Pop() float64 {
val := tail.Value
s.dll.Remove(tail)
s.Debug(fmt.Sprintf("DEBUG: remove from stack: %.2f", val))
s.Debug(fmt.Sprintf("remove from stack: %.2f", val))
s.Bump()
return val.(float64)
@@ -72,7 +72,7 @@ func (s *Stack) Shift() {
tail := s.dll.Back()
s.dll.Remove(tail)
s.Debug(fmt.Sprintf("DEBUG: remove from stack: %.2f", tail.Value))
s.Debug(fmt.Sprintf("remove from stack: %.2f", tail.Value))
}
func (s *Stack) Last() float64 {
@@ -130,3 +130,13 @@ func (s *Stack) Restore() {
s.rev = s.backuprev
s.dll = s.backup
}
func (s *Stack) Reverse() {
newstack := list.List{}
for e := s.dll.Front(); e != nil; e = e.Next() {
newstack.PushFront(e.Value)
}
s.dll = newstack
}