3 ms·
Here it is in J: +/*:>:i.10 It's kind of cheating because J doesn't really do lazy evaluation of infinite sequences AFAIK, but I thought it was fun. EDIT
by burke 12y ago
Here it is in J:
+/*:>:i.10
It's kind of cheating because J doesn't really do lazy evaluation of infinite sequences AFAIK, but I thought it was fun.
EDIT:
i. integer range
*: square
>: increment
+/ sum
so this reads sort of like: sum(square_each(increment_each(integer_range(10)))
- eggy 12y agoYou beat me to the J solution, but here it is in APL: +/2*⍨⍳10 No need for increment, since index is set to start at 1. You can set it to 0 too, if you work that way. + addition / reduce 2 (to be fed to exponential operator * for square) * exponential ⍨ commute ⍳ iota - index generator I would consider C++ with this library over Haskell just because you get the world of C++, but with a bit more of the expressiveness I like in the functional languages.
- deleted 12y ago[deleted]
- omgtehlion 12y agolooks like brainfuck to me ;)
- eggy 12y agoSyntax is like getting used to math symbols, but once you do, you can really do a lot with a little - very expressive. I find myself in the J interpreter or APL workspace to hack away at solutions much more so than in any other language. I am not a web developer.