'mod 'mul 'min 'max dont work by default on lists and in this case
I could not find a fast way to create a nice lambda for it.
This might look quiet simple thought its not someting you think of all the time. But it is fully newlisp.
So how to get the highest number out of a list of numbers?
> b
(65 42 48 32 25 46 32 14 43 77 15 136 2 3549 268 215 119 217 110
84 56 211 98 22 24 96 46 35 51 278 74 36 41 91 64 65 99 83 82 44
46 62 52 15 53 157 85 54 29 63 75 75 29 44 27 1 8 32 17 57 23 121
35 51 34)
>
> (push max b 0)
max <8052D00>
> (eval b)
3549 <--- tataaa there it is!
> b
(max <8052D00> 65 42 48 32 25 46 32 14 43 77 15 136 2 3549 268 215
119 217 110 84 56 211 98 22 24 96 46 35 51 278 74 36 41 91 64 65
99 83 82 44 46 62 52 15 53 157 85 54 29 63 75 75 29 44 27 1 8 32
17 57 23 121 35 51 34)
> (pop b 0)
max <8052D00>
> b
(65 42 48 32 25 46 32 14 43 77 15 136 2 3549 268 215 119 217 110
84 56 211 98 22 24 96 46 35 51 278 74 36 41 91 64 65 99 83 82 44
46 62 52 15 53 157 85 54 29 63 75 75 29 44 27 1 8 32 17 57 23 121
35 51 34)
>
Just another encounter of newlisp flexibility ;-)
Just another encounter of newlisp flexibility ;-)
-- (define? (Cornflakes))
But not neccesarily faster:HPW wrote: ...shorter.
Code: Select all
> (setq c (flat (dup b 1000)))
....35 51 34
> (time (apply max c))
49
> (time ((push max c) (eval c)))
23
> (pop c)
max <C42C>
> (time (apply max c))
48
-
Ha ha, very funny! One thing for sure, sort is a really slow way to get the max:newdep wrote: Is 'max quicker on a sorted or unsorted list ;-)
Code: Select all
> (time (sort c))
183
> (last c)
3549
Code: Select all
> (time ((push max c) (eval c)))
27