- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
fixed it already
Dear coders,
Have a question about mapcar.
Probably im doing it wrong
I read multiple cells from xls to make a list containg 7 others lists
Looks like this
(("OLD ATT" "ISO_PIPESPEC" "ISO_MEDIUM" "ISO_DESIGN_PRESS" ) ("NEW ATT" "n.v.t.1" "n.v.t.2" "n.v.t.3") ("PROMPT" "Prompt 1" "Prompt 2" "Prompt 3") ("ISO-QAZ" "val aa01" "val aa02" "val aa03") ("ISO-QQ" "val a1" "val a2" "val a3") ("ISO-QA" "val b1" "val b2" "val b3") ("ISO-AZ" "val c1" "val c2" "val c3"))
with
(setq b (mapcar 'car a))
Im making a list containing all the first elements
("OLD ATT" "NEW ATT" "PROMPT" "ISO-QAZ" "ISO-QQ" "ISO-QA" "ISO-AZ")
With
(setq c (mapcar 'cdr a))
Im making a list containing the other 7 lists without the first element in it
(("ISO_PIPESPEC" "ISO_MEDIUM" "ISO_DESIGN_PRESS" "ISO_DESIGN_TEMP") ("n.v.t.1" "n.v.t.2" "n.v.t.3" "n.v.t.4") ("Prompt 1" "Prompt 2" "Prompt 3" "Prompt 4") ("val aa01" "val aa02" "val aa03" "val aa04") ("val b1" "val b2" "val b3" "val b4") ("val c1" "val c2" "val c3" "val c4"))
Now I need to combine this lists again
Using
(setq d (mapcar 'list (cdr c) (cdr b)))
This will create the list I need only IT IS MISSING the whole first list i.e (OLD_ATT)
So the list looks like this
(("NEW ATT" ("Prompt 1" "Prompt 2" "Prompt 3" "Prompt 4")) ("PROMPT" ("val aa01" "val aa02" "val aa03" "val aa04")) ("ISO-QAZ" ("val a1" "val a2" "val a3" "val a4")) ("ISO-QQ" ("val b1" "val b2" "val b3" "val b4")) ("ISO-QA" ("val c1" "val c2" "val c3" "val c4")))
Changing cdr into car results in a error
(setq d (mapcar 'list (car c) (car b)))
error: bad argument type: consp "OLD ATT"
What function do I need to use to get a list containing all the lists?
Kind regards
Kind Regards
Solved! Go to Solution.