Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've got some problems with list manipulation,
I will be grateful if sb could help me with it.
1) how sort such association list by given order for example
;list (setq lst '((("A" 5) ("B" 4) ("C" 6)) (("D" 1) ("B" 8) ("C" 9) ("A" 5)) (("E" 1) ("B" 8))) ;defined sort order (setq order '("D" "A" "B" "C" "E")) ;want to get sth like this ;-> ((("A" 5) ("B" 4) ("C" 6)) (("D" 1) ("A" 5) ("B" 8) ("C" 9)) (("B" 8) ("E" 1)))
2) how can I get merged values in second item (always strings so with strcat function) and join lists at the same time
when one of the sublist is the same...
I think below example should clarify what I mean:
(setq lst2 ' ( (("a" X) ("b" Y) ("c" Z)) (("a" X) ("d" N) ("e" A)) (("a" X) ("f" Y) ("d" Z)) (("a" Y) ("b" B) ("d" A)) (("a" Y) ("c" C) ("f" B)) (("a" Z) ("b" X) ("d" C)) (("a" Z) ("b" Y) ("d" D)) (("a" Z) ("b" Z) ("e" X)) ) -> ( (("a" X)("b" Y)("c" Z)("d" NZ)("e" A)("f" Y)) (("a" Y)("b" B)("d" A)("c" C)("f" B)) (("a" Z)("b" XYZ) ("d" CD)("e" X)) )
I've tried some mapcar/lambda operation but failed,
thanks in advance for any clues
Chris
Solved! Go to Solution.