Add list-head, list-tail.

* module/mes/scm (list-head, list-tail): New function.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-17 14:44:34 +01:00
parent 738eabbe0e
commit dab37a844b

View file

@ -32,6 +32,14 @@
(define (list . rest) rest) (define (list . rest) rest)
(define (list-head x n)
(if (= 0 n) '()
(cons (car x) (list-head (cdr x) (- n 1)))))
(define (list-tail x n)
(if (= 0 n) x
(list-tail (cdr x) (- n 1))))
(define-macro (case val . args) (define-macro (case val . args)
(if (null? args) #f (if (null? args) #f
(let ((clause (car args))) (let ((clause (car args)))