adb: (Default)
[personal profile] adb
I'm currently spending my spare nerd time on Project Euler, a series of math exercises. The neat thing about them is that they don't require any math knowledge beyond what is taught in middle school in the US, nor do they require any programming knowledge beyond the willingness to experiment.

I've really appreciated Haskell in the course of this effort: for many of the Euler problems, you can just describe the problem recursively and Haskell will solve it for you; the only effort is looking up what you want in the "dictionary" (e.g., to discover that "nub" is Haskell for "uniq", and "words" Haskell for "split") and figuring out how you misdescribed the corner cases of the algorithm.

It would be nice, though, if there were a language where something this simple:

sum $ zipWith (*) (map (sum . catMaybes . map ((flip elemIndex) letters)) names) [0..]

didn't involve obnoxious quirks like:

- dollars signs for precedence
- "elemIndex": there should be either sugar or a nicer name for something this basic
- "flip": this is only here because elemIndex takes its arguments in the wrong order
- "Maybe" is a substitute for being able to put "nil" in place of anything and having stuff throw an exception if it doesn't like it. When hacking, I want the latter behavior, and the latter behavior is what is familiar from every dynamic language in the universe.
- Though you don't see it here, there is a separate zipWith for every arity. Haskell fans will defend this behavior to your face, with every appearance of sincerity.

That's a lot of quirks for one line, but then again, Haskell is a pretty dense language.

(Seriously, I blasted through a lot of these problems in way less time than it would have taken in a less declarative language. But seriously, it badly needs the warts planed off and the name changed so enough users will use it that it will get enough libraries that enough users will be able to use it to make it good.)

Profile

adb: (Default)
Aaron D. Ball

December 2010

S M T W T F S
   1234
567891011
12131415161718
192021 22232425
262728293031 

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 20th, 2017 11:14 am
Powered by Dreamwidth Studios