HI
I'm reading an example of code that use apply built-in..but a step isn't clear to me:
ps. this function take a compress list as ((3 1) 0 1 (4 0) 1)) and return (1 1 1 0 1 0 0 0 0 1)
thanks again in advance!!
ps. sorry for wrong inidentation in the first defun (the second if belongs to let declaration), in preview works, but not when printed....(???)
I'm reading an example of code that use apply built-in..but a step isn't clear to me:
ps. this function take a compress list as ((3 1) 0 1 (4 0) 1)) and return (1 1 1 0 1 0 0 0 0 1)
(defun uncompress (lst)
(if (null lst)
nil
(let ((elt (car lst))
(rest (uncompress (cdr lst))))
(if (consp elt)
(append (apply #' list_of elt)
rest)
(cons elt rest)))))
(defun list_of (n elt)
(if (zerop n)
nil
(cons elt (list_of (- n 1) elt))))
well," list_of" func take two arg of course, but why when "uncompress" func give it only one arg through apply ( for ex. when elt value is one integer and not a nested list of pair) this function doesn't raise error???thanks again in advance!!
ps. sorry for wrong inidentation in the first defun (the second if belongs to let declaration), in preview works, but not when printed....(???)
Last edited by megera on , edited 1 time in total.