Just another encounter of newlisp flexibility ;-)
Posted: Thu Nov 03, 2005 9:17 pm
'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)
>
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)
>