transcendental-lisp/lisp/util/list-builder.lisp

32 lines
890 B
Common Lisp
Raw Permalink Normal View History

(defun list-doubler (seed times-to-double)
(if (< times-to-double 1) seed
(recur (append seed seed) (- times-to-double 1))))
2017-11-18 18:01:00 -05:00
(defun decreasing-list (end size)
(decreasing-list-tail (list end) (+ end 1) size))
(defun decreasing-list-tail (seed end size)
(if (< size 1) seed
(recur (cons (+ (car seed) 1) seed) (+ end 1) (- size 1))))
(defun increasing-list (end size)
(increasing-list-tail (list end) (+ end 1) size))
(defun increasing-list-tail (seed end size)
(if (< size 1) seed
(recur (cons (- (car seed) 1) seed) (- end 1) (- size 1))))
2017-11-24 10:07:49 -05:00
(defun list-of (item size)
(list-of-tail nil item size))
(defun list-of-tail (seed item size)
(if (< size 1) seed
(recur (cons item seed) item (- size 1))))
2017-11-26 11:04:53 -05:00
(defun nested-list (size)
(nested-list-tail () size))
(defun nested-list-tail (seed size)
(if (< size 1) seed
(recur (cons seed nil) (- size 1))))