reverse   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/tests/core/algebraic_data_types.xtm

Implementation

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


Back to Index

Similar Entries