I've been looking for this for days, basically I need to implement a function that does the same thing that the system function reduce does. This is what I have came up so far, but without an initial value i
I can't get it to work.
Here is my code
(defun my-reduce (p i lista)
(if (null lista)
i
(funcall p (car lista) (my-reduce p i (cdr lista)))))
By the way, it doesn't even work properly because it goes "backward" eg.:
(my-reduce #'list NIL '(1 2 3 4))
should return
(((1 2) 3) 4)
but I get
(1 (2 (3 (4 NIL))))
any idea?