Visitor No.

Sunday 13 December 2015

Recursive LISP function which takes one argument as a list and returns a list except last element of the list.

6 - Define a Recursive LISP function which takes one argument as a list and returns a list except last element of the list.

     Implementation Code in LISP - 

      ( defun not_last(l)
      ( if (> (length (rest 1)) 0)
      (append (list ( first l)) (not_last (rest l)))
       nil))

     OUTPUT-

      (not_last '(1 2 3 4 5) )
      (4 3 2 1)

No comments:

Post a Comment