1. It depends what you mean by 'temporarily'? To change it in a local scope, you can shadow the function variable like this:
(def foo (x y) (pr x y))
(let foo (fn (y x) (foo x y)) (foo "one" "two"))
=> twoone
2. Square-bracket notation is the most concise way to partially apply a function to all but one argument:
(map [foo _ "bar"] '(1 2 3))
=> 1bar2bar3bar
Currying is a different thing to partial application and isn't supported by Arc, but it is possible to write a curry operator that can produce the curried equivalent of any function. (Note that the 'curry' operator defined by pg in ANSI Common Lisp does not actually curry the function, strictly speaking). Such an operator would have to take an argument saying how many arguments the original function had, as Arc has no way of reflecting on functions at the moment.
3. map is currently implemented so that extra list members are simply ignored:
(map + '(1 2 3) '(1 2))
=> (2 4)
It would be quite easy to define new versions of map that do what you require. For example, repeating the last element:
(def repeat-map (f . ls)
(if (pos no ls) nil
(all ~cdr ls) (list:apply f (map car ls))
(cons (apply f (map car ls))
(apply repeat-map f (map [if (~cdr _) _ (cdr _)] ls)))))
Thanks, that was what I was looking for. Unfortunately, I think I've configured something wrong in git or ssh, and cannot clone the arc repo for actually using it ;)
By temporarily, I originally meant without defining a shadow function, like you did, just reorganizing them for the single call. But that might not be easy to do in a concise, flexible way so I suppose shadow functions make the most sense.
You shouldn't need ssh just to clone the repo. This should work fine:
git clone git://github.com/nex3/arc.git
However, you can't push using that URL, so you'll end up with an un-pushable copy. Have you tried looking through all the guides? http://github.com/guides/home
To reorder arguments in a single call... it would certainly be easy to do that for binary functions:
As for the silence, it appears almkglor and stefano are busy working on hl (http://github.com/AmkG/hl/tree/master). I don't know if they still read the forum. I suspect a lot of other people are getting disheartened.
Also, until there's another release of Arc, there isn't much to talk about.
Yes, I think I've followed all of the guides. However, I keep getting the "Permission (publickey)" error. I wonder if there are more configurations like username or email address that have to be the same as what github expects?
; convert a cycle into transpositions
(def trans (cycle (o first nil))
(if (no cycle) nil
(~cdr cycle) (list:list cycle.0 first)
(cons (list cycle.0 cycle.1)
(trans (cdr cycle)
(if first first cycle.0)))))
; permute a list using a list of disjoint cycles
(def permute (cycles l)
(with (ts (apply join (map trans cycles))
ret (copy l))
(map [= (ret (- _.1 1)) (l (- _.0 1))] ts)
ret))
(permute '((1 2 3) (4 5)) '(a b c d e))
=> (c a b e d)