From 6ba1871c3825e17d33b96ffd3051239dfe18d61a Mon Sep 17 00:00:00 2001 From: bd Date: Wed, 9 Apr 2025 19:26:51 -0400 Subject: Saving first part of large rewrite --- src/util.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/util.lisp') diff --git a/src/util.lisp b/src/util.lisp index 027a770..93db659 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -11,6 +11,25 @@ (declare (type (integer 0 *) len)) (format nil "~V,'0b" len num)) +(defun insert-in-middle (list element) + (append (list (car list)) (list element) (cdr list))) + +(defun iota (n) + "Generates a number sequence from 0 to N." + (when (> n 0) + (do ((i 0 (1+ i)) + (item 0 (1+ item)) + (result nil (push item result))) + ((= i n) (nreverse result))))) + +(defun riffle (lst1 lst2) + "Given LST1 and LST2, returns a new list which is the an alternative sequence +of the elements from both lists. Returns nil if the lists are not equal size." + (when (eq (length lst1) (length lst2)) + (loop for l1 in lst1 + for l2 in lst2 + append (list l1 l2)))) + (defparameter type-r '(ADD SUB MUL QUOT REM SFTR SFTL AND OR NOT XOR ADDV SUBV MULV DIVV CMP CEV) "R-type instructions.") -- cgit v1.2.3