Loading ...
Sorry, an error occurred while loading the content.

616Re: [aima-talk] Complex returns from recursive functions - tail recursion?

Expand Messages
  • Steven Shaw
    Jan 29, 2006
      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))
      (t (split-list2-helper
      (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??...

    • Show all 5 messages in this topic