enqueue   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/core/extempore_lang.xtm

Implementation

;; add to the back of the list
(bind-func enqueue
  (lambda (queue:|2,list_t*|* value:i64)
    (let ((tmp:list_t* (halloc))
          (front (aref queue 0))
          (back (aref queue 1)))
      (tset! tmp 0 value)
      (tset! tmp 1 null)
      (if (null? back) 1 (begin (tset! back 1 tmp) 1))
      (if (null? front) (aset! queue 0 tmp))
      (aset! queue 1 tmp) ;; set back to tmp
      1)))


Back to Index

Similar Entries