reverse   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/base/prelude.xtm

Implementation

;; tail recursive reverse
(bind-func reverse:[List{!a}*,List{!a}*]*
  (lambda (lst)
    (let ((rev (lambda (old new)
                 (if (Nil$ lst () #t #f)
                     rlst
                     (rev (Cons$ old (x xs) xs (Nil))
                          (Cons$ old (x xs)
                                    (Cons x new)
                                    (Nil)))))))
      (rev lst (Nil)))))


Back to Index

Similar Entries