Evan Martin (evan) wrote in evan_tech,
Evan Martin


I remember when I first started really using ML I found the function parameter order kinda weird. Operations like List.map took the list as their last argument, even though the object-oriented style I'm accustomed to (C, Python, etc.) puts the object first. I initially wrote it off to weirdness (after all, the C library functions like fwrite() take the FILE* as their last argument), but then I eventually realized how useful it is when combined with currying.

I've been using R lately, which lacks currying, and I keep needing to write lambda expressions like this (the syntax for lambdas is "function(x) expr"):
f(data, function(x) g(x, function(y) h(y, someconstant)))
Here, the data being passed through is the first arguments of these functions (which do things like map, etc.), and so R chose to make it the first arguments.
If the functions were curried and took their arguments in the other order, I could do something like this:
(f (g (h someconstant))) data
which is a lot simpler.

Though I admit neither makes much sense as I write them here. They're easier to understand in context. :)

  • blog moved

    As described elsewhere, I've quit LiveJournal. If you're interested in my continuing posts, you should look at one of these (each contains feed…

  • dremel

    They published a paper on Dremel, my favorite previously-unpublished tool from the Google toolchest. Greg Linden discusses it: "[...] it is capable…

  • treemaps

    I finally wrote up my recent adventures in treemapping, complete with nifty clickable visualizations.

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.