(append (cdr list1) list2))))
(defun append (&rest lists)
- (!reduce #'append-two lists))
+ (!reduce #'append-two lists nil))
(defun revappend (list1 list2)
(while list1
(setq assignments (reverse assignments))
;;
`(let ,(mapcar #'cdr assignments)
- (setq ,@(!reduce #'append (mapcar #'butlast assignments))))))
+ (setq ,@(!reduce #'append (mapcar #'butlast assignments) nil)))))
(defmacro do (varlist endlist &body body)
`(block nil
(+ (get-unix-time) 2208988800))
(defun concat (&rest strs)
- (!reduce #'concat-two strs :initial-value ""))
+ (!reduce #'concat-two strs ""))
(defun values-list (list)
(values-array (list-to-vector list)))
x
(list x)))
-(defun !reduce (func list &key initial-value)
- (if (null list)
- initial-value
- (!reduce func
- (cdr list)
- :initial-value (funcall func initial-value (car list)))))
+(defun !reduce (func list initial-value)
+ (let ((result initial-value))
+ (dolist (element list result)
+ (setq result (funcall func result element)))))
;;; Concatenate a list of strings, with a separator
(defun join (list &optional (separator ""))
(if (null list)
""
- (!reduce (lambda (s o) (concat s separator o))
- (cdr list)
- :initial-value (car list))))
+ (!reduce (lambda (s o) (concat s separator o))
+ (cdr list)
+ (car list))))
(defun join-trailing (list &optional (separator ""))
(if (null list)