Hi, Am 28.02.2009 um 22:39 schrieb Joshua Fox:
-> confuses me: Does it treat functions with multiple parameters different from functions with one parameter? Am I right that it can only be used with the latter?
(-> a-thing fun-1 (fun-2) (fun-3 b-thing)) is turned into (fun-3 (fun-2 (fun-1 a-thing)) b-thing) So, -> takes the first argument and places it as first argument in the second argument. If the second argument is not a list, -> creates automatically a list the given thing as first argument. So here are the cases. (-> x foo) => (foo x) (-> x (foo)) => (foo x) (-> x (foo a b c)) => (foo x a b c) This works recursively. So you can easily chain functions together. One nice example is that of nested maps as given by James before in this thread. (-> the-map :a :b :c) is turned into (:c (:b (:a the-map))) Now consider the-map to be {:a {:b {:c 5}}} Then the above evaluates to 5. A bit contorted, but I hope this helps. Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature