@ Shay:
Can you explain how/why you create this list?:
(setq lst
'(
("a" ((0 2 4) (0 7 0) (0 2 0)))
("b" ((0 2 0) (0 5 0) (0 2 0)))
("c" ((3 2 0) (0 2 0) (9 3 0)))
)
)
Hi roy
Ill try to explain what im doing,
Im from the constriction discipline, my task is to construct a supporting wall array between two planed ground levels, the one that behind the wall and the other is in front of the wall , (there is “exist” line but its off-topic now) Each ground level is represented by a line.
I distribute points along those lines and retrieve those points as a list associated with a key, by comparing their Y values I can know:
- Which point is the highest/lowest in the wall?
What line owns the highest/lowest point?
In order to get the answer I must use association list. In fact I need first to sort out which point is highest/lowest in which line, and which line has the highest/lowest point among all three lines.
There are some situation where the point will be rejected if its owner is “exist” , in that case the second lowest/height point will be tested.
(setq lst
'(
("front" ((0 3 4) (0 4 0) (0 2 0)))
("back" ((0 1 3) (0 5 0) (0 3 0)))
("exist" ((3 2 0) (0 4 0) (9 3 0)))
)
)
(defun foo3 (lst)
(vl-sort
(mapcar
(function
(lambda (grp)
(list (car grp)
(vl-sort (cadr grp)
(function
(lambda (a b)
(> (cadr a) (cadr b))
)
)
)
)
)
)
lst
)
(function
(lambda (a b)
(> (cadr (caadr a)) (cadr (caadr b)))
)
)
)
)
(("back" ((0 5 0) (0 3 0) (0 1 3))) ("front" ((0 4 0) (0 3 4) (0 2 0))) ("exist" ((0 4 0) (9 3 0) (3 2 0))))
how to shorten it?