-2

how does one create a list from a list,what function can i really use i was thinking of using mapcar or maplist with cons together but im not getting any fruitful results,lets say i have a list (a b) then i want a function that will create a list containing the same elements but they should be inform of lists like this ((a) (b)) ,any ideas on how i can solve this problem?? is there a function a use to it?

if i have a list(a b)
the result should be ((a)(b))

thanks guys

kintque
  • 9
  • 2
  • 1
    I don't speak lisp, but you should be able to do something like `map (lambda x: cons(x,nil))`. Hope that's understandable... – phipsgabler Nov 18 '12 at 17:20
  • 1
    this sounds like another fake question from a bunch of fake stackoverflow accounts. All have extremely poor spelling, wrong Lisp syntax, show no own effort and ask trivial questions. – Rainer Joswig Nov 18 '12 at 17:22
  • @RainerJoswig "fake question"? What have I missed? – fableal Nov 18 '12 at 17:23
  • @RainerJoswig how is it fake???the syntax is not the lisp syntax its just an example on how i want it to look like,just trying to learn here i will appreciate if you just help me out if you have ideas thanks – kintque Nov 18 '12 at 17:35
  • @fableal thanks for the contribution :) – kintque Nov 18 '12 at 17:37
  • @wvxvw: this is a similar question by another user just an hour earlier: http://stackoverflow.com/questions/13442008/repeating-elements-in-common-lisp. Same spelling mistakes, same formatting mistakes, no effort put into it, ... – Rainer Joswig Nov 18 '12 at 20:06

1 Answers1

1

What you want to do is this:

(defun listify(ls) 
    (mapcar (lambda (elem) (list elem))  ls))

EDIT

Which is the same as (Thanks to @RainerJoswig):

(defun listify(ls) 
    (mapcar #'list ls))

And if you do:

(listify (list 1 2 3))

or

(listify '(1 2 3))

The output will be:

((1) (2) (3))
fableal
  • 1,577
  • 10
  • 24