Re: [aima-talk] Complex returns from recursive functions - tail recursion?
- Here's version that's tail recursive though I don't think very
efficient because of my use of append and list perhaps were not
(defun split-list2 (list)
(let ((a (list)) (b (list)))
(split-list2-helper list a b)))
(defun split-list2-helper (list firsts seconds)
(cond ((null list) (list firsts seconds))
(rest (rest list))
(append firsts (list (first list)))
(append seconds (list (second list)))))))
Also, I forget the syntax for defining inner auxilary functions...
flet, labels, defun??...
- On 29/01/06, Peter Norvig <peter@...> wrote:
> How about this:Looks good. I could have done with nvreverse myself!