Add TAKE.
This commit is contained in:
		
							parent
							
								
									19c7d9afbd
								
							
						
					
					
						commit
						131b9848e9
					
				|  | @ -6,6 +6,15 @@ | ||||||
| 
 | 
 | ||||||
| ;;; This file contains various utilities I've written. | ;;; This file contains various utilities I've written. | ||||||
| 
 | 
 | ||||||
|  | (defun take (n lst) | ||||||
|  |   "Take n elements from lst." | ||||||
|  |   (labels ((rec (n lst acc) | ||||||
|  |              (if (or (zerop n) (null lst)) | ||||||
|  |                  (nreverse acc) | ||||||
|  |                  (rec (- n 1) (cdr lst) (cons (car lst) acc))))) | ||||||
|  |     (when (> n 0) | ||||||
|  |       (rec n lst nil)))) | ||||||
|  | 
 | ||||||
| (defun interpose (x sep) | (defun interpose (x sep) | ||||||
|   "Takes a list and a separator, and places separator between element |   "Takes a list and a separator, and places separator between element | ||||||
| of the list." | of the list." | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ | ||||||
|            #:compose |            #:compose | ||||||
|            #:defmacro! ; Let Over Lambda utilities |            #:defmacro! ; Let Over Lambda utilities | ||||||
|            #:interpose ; My utilities |            #:interpose ; My utilities | ||||||
|  |            #:take | ||||||
|            #:build-list |            #:build-list | ||||||
|            #:partial |            #:partial | ||||||
|            #:macroexpand-n |            #:macroexpand-n | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue