Append

From mojo_puzzler
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Return to: Chialisp
Return to: Recursive Functions

Appending lists in a solution:

(mod (list1 list2)
(defun append (list1 list2)
  (if (l list1)
     (c (f list1) (append (r list1) list2))
     list2) 
  )
(append list1 list2)
)

Example Usage:

brun '(a (q 2 2 (c 2 (c 5 (c 11 ())))) (c (q 2 (i (l 5) (q 4 9 (a 2 (c 2 (c 13 (c 11 ()))))) (q . 11)) 1) 1))' '((99 33)(1 2 3))'

Outputs:

(99 33 1 2 3)