Arc Forumnew | comments | leaders | submitlogin
1 point by tel 5922 days ago | link | parent

These examples were poor, sorry. I'd only just started the tutorial and I didn't want to guess function names too much.

A slightly better, though still trivial, example:

   (map [+ 5] 
        (list (range -3 0)
              (range 1 3)
              (range 3 5)))
becomes

   (map (fn (nums) (apply + (cons 5 nums)))
        (list (range -3 0)
              (range 1 3)
              (range 3 5)))
Though, normally, you might write something akin to:

   (map (fn (nums) (+ 5 (apply + nums)))
        ...)
It's a lot like Zak's suggestion, just noting that sometimes n is infinite. Full partial application is really powerful -- especially with the general trend in Arc to have the final argument be the most dynamic one -- and I regret that I don't really have time at the moment to make an interesting example.


2 points by Zak 5922 days ago | link

You're now taking a list of lists and trying to add a number to each list. That should fail - partial evaluation or no. There's no sane way for the first expression to translate in to the second.

-----