|
|||
|
Gareth McCaughan wrote:
> Oh, and if we're playing the intuitive-appeal-to-novices > game, consider > > (loop for n from 1 upto 10 sum n) ==> 55 > > and try to find another language in which that could be > expressed as neatly. :-) Racket: (for/sum ([i 11]) i) => 55 NewLisp: (apply + (sequence 1 10)) => 55 MatzLisp: (1..10).reduce(:+) ==>55 Clojure: user=> (apply + (range 1 11)) 55 user=> (reduce + (range 1 11)) 55 |
|
|
||||
|
||||
|
|
|
|||
|
On 25/05/12 10:58, WJ wrote:
> Gareth McCaughan wrote: > >> Oh, and if we're playing the intuitive-appeal-to-novices >> game, consider >> >> (loop for n from 1 upto 10 sum n) ==> 55 >> >> and try to find another language in which that could be >> expressed as neatly. :-) > > Racket: > > (for/sum ([i 11]) i) > => 55 > > NewLisp: > > (apply + (sequence 1 10)) > => 55 > > MatzLisp: > > (1..10).reduce(:+) > ==>55 > > Clojure: > > user=> (apply + (range 1 11)) > 55 > user=> (reduce + (range 1 11)) > 55 I was struggling with loop for ages, mostly because I have expected it to be like other languages. Lisp being too intuitive is a problem because other languages do it hard way. Unlearning something is often much harder than learning new things. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|