recursion - Appending list in lisp -
in lisp, appending lists as: (setq newlist (append (side b)(this b) (that b) ))
this appends required list as: (1 0 0 0 2 0 4 0 6 0) want this: ((1 0)(0 0)(2 0)(4 0)(6 0))
what should required format. please post code examples in lisp.
so in fact need restructure elements after have appended it:
(loop :for (e1 e2) :on '(1 0 0 0 2 0 4 0 6 0) :by #'cddr :collect (list e1 e2)) ; ==> ((1 0) (0 0) (2 0) (4 0) (6 0))
suggested reading loop black belts, section should pay attention i've used here "looping on collections , packages" , "destructuring variables". chapter practical common lisp read most. whole book every lisper should know it.
Comments
Post a Comment