if I have something like,
Code: Select all
(set 'a '())
(push this a)
(push that a)
Code: Select all
(push this that a)
Code: Select all
(set 'a '())
(push this a)
(push that a)
Code: Select all
(push this that a)
Code: Select all
(mypush 1 2 3 'a)Code: Select all
(define (mypush)
  (let
    ( stack (last (args))
      list-of-items (butlast (args))
    )
  ;body of let
    (dolist (item list-of-items)
      (push item (eval stack)) )))Code: Select all
(define (mypush)
  (let
    ( stack (last (args))
      list-of-items (reverse (rest (reverse (args))))
    )
  ;body of let
    (dolist (item list-of-items)
      (push item (eval stack) -1)) ))Code: Select all
;; butlast
;; return all but last n (default 1) elements of list / chars of string
;;
(define (butlast list-or-string n)
  (chop list-or-string (or n 1)) )Code: Select all
> (set 'a '())
() 
> (set 'b '("this" "that"))
("this" "that") 
> (map (fn(x) (push x a)) b)
("this" "that") 
> a
("that" "this")