Author Topic: [0518]How extracts in series value each in series greatest group of values?  (Read 2138 times)

0 Members and 1 Guest are viewing this topic.

hunterxyz

  • Guest


EXP:
(SETQ GTQQ(LIST 1 1 1))
(SETQ LTQQ '((51 17 32)
            (28 42 68)
            (53 25 19)
            (12 25 89)) )
Extracts: _$ (53 42 89)

Use the following procedure to extract
CODE:
(MAPCAR '(LAMBDA (X) (SETQ GTQQ(LIST
(MAX (CAR GTQQ)(CAR X))
(MAX(CADR GTQQ)(CADR X))
(MAX(CADDR GTQQ)(CADDR X))
))) LTQQ)

But if for under such in series, the non- fixed in series value, how should process?
(SETQ LSPNB '((11 4 8 17 2 20 22 7 5 12)
         (5 10 2 17 1 20 22 7 5 12)
         (9 6 6 17 1 20 22 7 5 12)
         (9 6 6 17 1 20 22 7 5 12)
         (3 12 17 1 4 11 3 22 7 5 12)
         (9 6 6 17 1 6 13 22 7 5 12)
         (7 8 4 17 1 20 22 7 5 12)
         (9 6 6 17 1 4 11 3 22 7 5 12)
         (7 8 4 17 1 4 11 3 22 7 5 12)
         (9 6 6 17 1 4 11 3 22 7 5 12)
         (1 13 1 15 1 16 3 22 7 5 12)
         (7 8 4 17 1 4 11 3 22 7 5 12)
         (13 2 14 1 4 11 3 22 7 5 12)
         (3 12 1 16 4 4 11 3 20 2 6 6 11)
         (7 8 5 16 4 4 11 3 20 2 6 6 11)
         (5 10 3 16 4 20 20 2 6 6 11)
         (15 13 16 4 20 20 2 6 6 11)
         (1 14 4 13 16 4 20 16 3 2 6 6 11)
         (10 16 2 20 20 2 6 6 11)
         (10 16 2 20 20 2 6 6 11)
         (11 14 17 1 1 20 20 2 6 6 11)
         (3 12 1 16 2 4 15 20 2 6 6 11)
         (13 2 10 16 4 20 20 2 6 6 11)
         (24 18 1 10 18 2 20 22 7 5 12)) )

Requests master help to answer, thanks ~

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Code: [Select]
(apply 'mapcar (cons 'max LTQQ))
(apply 'mapcar (cons 'max LSPNB))

SomeCallMeDave

  • Guest
Or maybe

Code: [Select]
(defun CreateMaxList(pList)
  (mapcar '(lambda(x) (apply 'max x)) pList)
)

(defun c:TestCreateMaxList()
   (SETQ LSPNB '((11 4 8 17 2 20 22 7 5 12)
         (115 10 2 17 1 20 22 7 5 12)
         (119 6 6 17 1 20 22 7 5 12)
         (229 6 6 17 1 20 22 7 5 12)
         (3 12 17 1 4 611 3 22 7 5 12)
         (9 6 6 17 1 66 13 22 7 5 12)
         (7 8 4 17 1 720 22 7 5 12)
         (9 6 6 17 1 4 11 3 22 7 5 712)
         (7 8 4 17 1 4 11 3 22 7 5 12)
         (9 6 6 17 1 4 11 3 22 7 5 12)
         (771 13 1 15 1 16 3 22 7 5 12)
         (7 8 4 17 1 4 11 3 22 7 5 12)
         (13 2 14 1 4 11 3 22 7 5 12)
         (3 12 1 16 4 4 11 3 20 2 6 6 11)
         (7 8 5 1776 4 4 11 3 20 2 6 6 11)
         (5 10 3 16 4 20 20 2 6 6 11)
         (15 13 16 4 20 20 2 6 6 11)
         (1 14 4 13 16 4 20 16 3 2 6 6 11)
         (10 16 2 20 20 2 6 6 11)
         (10 16 2 20 20 2 6 6 11)
         (11 14 17 1 1 20 20 2 6 6 11)
         (3 12 1 16 2 4 15 20 2 6 6 11)
         (13 2 10 16 4 20 20 2 6 6 11)
         (24 18 1 10 18 2 20 22 7 5 12))
     );setq
     (createMaxList LSPNB)
)     


I'm not exactly sure how you want the output formatted

hunterxyz

  • Guest
THANK ~ ElpanovEvgeniy

(SETQ A (apply 'mapcar (cons 'max LSPNB)))
_$ (771 18 17 1776 20 720 22 22 22)
(LENGTH A)
_$ 9

BUT,
LSPNB LIST, EXP: (7 8 5 1776 4 4 11 3 20 2 6 6 11)
Has in series is bigger than 9, not to process ?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Interesting :?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Interesting :?

Why am I having a flashback to Rowan and Martins 'Laugh In'

Quote
"Look that up in your Funk and Wagnalls."
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.