Arc Forumnew | comments | leaders | submitlogin
1 point by chrisdone 6171 days ago | link | parent

In your above example I'm not exactly sure how it is different from just saying:

arc> (+ 1 2 3 4 5) 15 arc> (in 'a 'a 'b 'c 'd 'e) t arc> (- 5 4 3) -2

I.e. what power is gained from it?

Do you have any more examples?



1 point by tel 6170 days ago | link

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 6170 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.

-----