dequeue   xtlang


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

Implementation

;; remove value from front of list
(bind-func dequeue
  (lambda (queue:|2,list_t*|*)
    (let ((front (aref queue 0)))
      (if (null? front) -1
          (let ((val (tref front 0))
                (back (aref queue 1)))
            (aset! queue 0 (tref front 1))
            (if (= back front) (aset! queue 1 null))
            (free front)
            val)))))


Back to Index

Similar Entries