Arc Forumnew | comments | leaders | submitlogin
6 points by drcode 5979 days ago | link | parent

First of all, this is a nice piece of work, rincewind- I'm going to have to think a while to decide on the merits of this approach for my personal use. I like the fiendish use of 'zap :-)

FYI- If any of you are confused by the extra 2 in rincewinds code, it is NOT one of the numbers to be added. The currying code just requires it because of the impedance mismatch between variable arguments and currying. The Haskell core doesn't have variable argument support, so this is not an issue in Haskell.

Keep in mind that "On Lisp" covers currying, whereas arc currently does not. I assume this is because pg is still trying to decide on a currying approach, whether it will be implicit currying, syntax-based currying, or function-based currying.

Here's an awesome variant based on your approach I'm probably going to try and implement soon, now that I've thought of it- Have a number in the function position (currently an error) initiate currying!

For example:

  > (2 +)
  #<procedure>
The two here, as in rincewind's code, means that the curried version of '+ should resolve to the result after two parameters are passed in.

  > ((2 +) 7)
  #<procedure>

  > (((2 +) 7) 5)
  12

  > (map ((2 +) 7) '(1 2 3))
  (8 9 10)

  > (map (2.+ 7) '(1 2 3))
  (8 9 10)

  (these next ones assume my mods to the intrasymbol syntax are in place http://arclanguage.org/item?id=7644)

  > (map 2.+.7 '(1 2 3))
  (8 9 10)

  (for those of you wondering why the "2" is necessary)

  > (map 3.+.7 '(1 2 3))
  (#<procedure> #<procedure> #<procedure>)

  > (map [_ 100] (map 3.+.7 '(1 2 3)))
  (108 109 110)
Note that the "integers in function position" concept could also work with implicit currying- In that case, "2.+" would simply convert '+ into the dual arity version of '+. The examples would stay the same- However, in that case the integer could of course be ommited for fixed arity functions.