javascriptic trick in scala
Oct. 11th, 2011 11:30 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Just discovered this trick that is pretty ubiquitous in JavaScript (and, probably in Scheme too).
The trick consists of defining a function and applying it right away to a value;
((n:Int) => if (n %2 == 1) n*3 + 1 else n/2)((2 to 1000) filter isAmicable max)
The trick consists of defining a function and applying it right away to a value;
no subject
Date: 2011-10-11 06:55 pm (UTC)(and this is what they can be desugared to)
no subject
Date: 2011-10-11 07:17 pm (UTC)I wouldn't call it desugaring.
no subject
Date: 2011-10-11 10:59 pm (UTC)no subject
Date: 2011-10-12 12:48 am (UTC)isAmicable - из Euler 21.
no subject
Date: 2011-10-12 12:49 am (UTC)no subject
Date: 2011-10-12 03:42 am (UTC)no subject
Date: 2011-10-12 04:59 am (UTC)