Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You 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.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: