mirror of
https://codeberg.org/scip/rpnc.git
synced 2025-12-17 04:21:01 +01:00
moved all math functions and operators to funcalls
So now if you want to add a new operator or math function all you have to do is to add it to func.go. Conpletion will be generated from it.
This commit is contained in:
16
stack.go
16
stack.go
@@ -115,20 +115,20 @@ func (s *Stack) Shift(num ...int) {
|
||||
}
|
||||
}
|
||||
|
||||
// just return the last item, do not remove it
|
||||
// Return the last num items from the stack w/o modifying it.
|
||||
func (s *Stack) Last(num ...int) []float64 {
|
||||
items := []float64{}
|
||||
i := s.Len()
|
||||
count := 1
|
||||
var items []float64
|
||||
if len(num) > 0 {
|
||||
count = num[0]
|
||||
}
|
||||
|
||||
if s.linklist.Back() == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
items = append(items, s.linklist.Back().Value.(float64))
|
||||
for e := s.linklist.Front(); e != nil; e = e.Next() {
|
||||
if i <= count {
|
||||
items = append(items, e.Value.(float64))
|
||||
}
|
||||
i--
|
||||
}
|
||||
|
||||
return items
|
||||
|
||||
Reference in New Issue
Block a user