Arc Forumnew | comments | leaders | submitlogin
1 point by drcode 6128 days ago | link | parent

Important note on implicit function currying:

In order to benefit most from this, languages such as haskell that include this feature have their core library functions written such that the most useful parameters to be "curried away" (which are usually obvious) are located at the end of the list.

For instance, you may want to redefine the function signature for subseq from:

  (def subseq (seq start (o end (len seq)))
      ...)
to:

  (def subseq ((start (o end (len seq))) seq)
      ...)
With that signature you would write (subseq '(1 4) "qwerty") which is arguably a more elegant style, as well. (yes, you can actually place an optional param inside of a destructuring like this in arc so it isn't at the end) Of course, the need for the quote is perhaps a small minus for some people.

Then you could use it in a curried fashion in a useful way:

  ;chop two letters off of each word
  > (map (subseq '(2)) '("apple" "orange" "banana")))
  ("ple" "ange" "nana")