I would like to try out lazy expression evaluation, but I do not want to dive into Haskel right now. Please, can you help to find what other languages have this feature?
I would like to try out lazy expression evaluation, but I do not want to dive into Haskel right now. Please, can you help to find what other languages have this feature?
Lazy evaluation is useful in two cases: (1) You work with infinite lists, (2) You need answer before question.
This is normal in functional programming (f.e.: Gofer/Miranda/Haskell).
An infinite list can be seen as a stream (as keyboard input, random numbers, music from radio, ...)
Examples: (a) Natural numbers: [1..] (b) Fibonacci numbers: fibs = 0:1: zipwith (+) fibs (tl fibs)
If you want to get 20 random numbers, you will express this as: take 20 randoms
In "normal" (imperative) coding style, user dialogs are of form: ...->(input->output)->(input->output)->...
In functional programming (FP), the view is changed to: ...->input)->(output->input)->(output->...
This is only possible using lazy evaluation.
If you are running Linux, you can compile and run Miranda from miranda.org.uk. Miranda was commercial. It is much easier than Haskell.
foldr1 (+) [1..36]