Hi!
I have a little challenging problem. I have this list:
(setq mylist (list (a (25 3)) (b (30 8)) (a (60 8)) (a (80 5)) (b (50 7)) (c (14 2)) ) )
Where the first element is the name of a place and the second one is their coordinates.Now I need the middle point for each group of letter at the first element and the biggest one of the second member in the second place. I mean:
(a (52.5 8)) (b (40 8)) (c (14 2))
I can't find any easy way to accomplish this simple task. Every help is welcome!
Best regards
Solved! Go to Solution.
Hi!
I have a little challenging problem. I have this list:
(setq mylist (list (a (25 3)) (b (30 8)) (a (60 8)) (a (80 5)) (b (50 7)) (c (14 2)) ) )
Where the first element is the name of a place and the second one is their coordinates.Now I need the middle point for each group of letter at the first element and the biggest one of the second member in the second place. I mean:
(a (52.5 8)) (b (40 8)) (c (14 2))
I can't find any easy way to accomplish this simple task. Every help is welcome!
Best regards
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
The data in your example doesn't match anything in the list above that. So you want to sort by the first number in the number pair, and in case of the same number, use the second number to sort?
The data in your example doesn't match anything in the list above that. So you want to sort by the first number in the number pair, and in case of the same number, use the second number to sort?
Not sure if this is simple way, but it works...
(defun :sort-by-letter-mid-max (lst / l a) (foreach e lst (setq l (if (setq a (assoc (car e) l)) (subst (append a (cdr e)) a l) (cons e l)))) (vl-sort (mapcar '(lambda (x) (list (car x) (list (/ (apply '+ (mapcar 'car (cdr x))) (- (length x) 1.)) (apply 'max (mapcar 'cadr (cdr x)))))) l) '(lambda (a b) (< (car a) (car b)))))
For
(setq mylist '(("a" (25 3)) ("b" (30 8)) ("a" (60 8)) ("a" (80 5)) ("b" (50 7)) ("c" (14 2))))
result is:
(:sort-by-letter-mid-max mylist) (("a" (55.0 8)) ("b" (40.0 8)) ("c" (14.0 2)))
Not sure if this is simple way, but it works...
(defun :sort-by-letter-mid-max (lst / l a) (foreach e lst (setq l (if (setq a (assoc (car e) l)) (subst (append a (cdr e)) a l) (cons e l)))) (vl-sort (mapcar '(lambda (x) (list (car x) (list (/ (apply '+ (mapcar 'car (cdr x))) (- (length x) 1.)) (apply 'max (mapcar 'cadr (cdr x)))))) l) '(lambda (a b) (< (car a) (car b)))))
For
(setq mylist '(("a" (25 3)) ("b" (30 8)) ("a" (60 8)) ("a" (80 5)) ("b" (50 7)) ("c" (14 2))))
result is:
(:sort-by-letter-mid-max mylist) (("a" (55.0 8)) ("b" (40.0 8)) ("c" (14.0 2)))
vl-symbol-name?
John F. Uhden
vl-symbol-name?
John F. Uhden
Can't find what you're looking for? Ask the community or share your knowledge.