( sequence -1 1 0.2 ) results in :
(-1 -0.8 -0.6 -0.4 -0.2 5.551115123e-017 0.2 0.4 0.6 0.8 1)
Instead of "0" "5.55..e-017" is shown, the reason is probably the float-arithmetic , but i need a 'nice' looking sequence with "0" . Has anyone an idea ?
programming-hint ?
in your previous post:
you can also use shorter:
(exists ...) is like (first (filter ..)) and with 'curry you can shorten the lambda expression
use round
in this case we cannot use 'curry because the parameter mapped is not the last of the two.
Lutz
Code: Select all
( first ( filter ( fn(x) ( > x mvalue) ) prefer-list )
Code: Select all
(exists (curry < mvalue) prefer-list)
Code: Select all
( sequence -1 1 0.2 ) results in :
(-1 -0.8 -0.6 -0.4 -0.2 5.551115123e-017 0.2 0.4 0.6 0.8 1)
Code: Select all
(map (fn (x) (round x -1)) ( sequence -1 1 0.2 ))
=> (-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1)
Lutz
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
I get different results:
Why is that?
Code: Select all
$ newlisp
newLISP v.9.1.0 on OSX UTF-8, execute 'newlisp -h' for more info.
> ( sequence -1 1 0.2 )
(-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1)
Thanks, now it's all OK :-)
syntax : ( exists func-condition list )
returns the first list-element , that meets the func-condition - this is clear .
But i have to think about the curry-command , and why in the last example only 'map' is possible .. but i have already found a thread in this forum about curry - ok, i'll understand it ;-)
syntax : ( exists func-condition list )
returns the first list-element , that meets the func-condition - this is clear .
But i have to think about the curry-command , and why in the last example only 'map' is possible .. but i have already found a thread in this forum about curry - ok, i'll understand it ;-)
Hi didi! Please take the time to meditate on curry, if you need to. You will come to realize how cool it is and you will be ready to join the Cult of Curry. I will personally initiate you when we meet at the next newLISP Users Convention -- you will learn the secret handshake and walk away with a nice embossed certificate to show to your friends. :-)didi wrote:But i have to think about the curry-command , and why in the last example only 'map' is possible .. but i have already found a thread in this forum about curry - ok, i'll understand it ;-)
--Rick
(λx. x x) (λx. x x)