Arc Forumnew | comments | leaders | submitlogin
3 points by bOR_ 5923 days ago | link | parent

This link came from reddit, and the blog mentions some fun but underlighted things in clojure. It is sort of funny that the second 'cool' thing the blog post mentions, it also mentions 'just like in arc'.

I quoted the relevant section of the blog here. 2. Unnamed arguments for short lambdas Pretty straightforward:

  (map #(+ % 4) '(1 2 3)) 
   -> (5 6 7)
   ;; Multiple arguments.
  (map #(* %1 %2) '(1 2 3) '(4 5 6))
  -> (4 10 18)

  This is roughly equivalent to Arc’s [+ _ 4] form, though allows for more than one argument. The standard lambda form is also similar to Arc’s:

  (map (fn [x] (+ x 4)) '(1 2 3)
   -> (5 6 7)

And this is the reddit link: http://www.reddit.com/r/programming/comments/75p8f/cool_thin...


3 points by almkglor 5923 days ago | link

Anarki supports multiple arguments too:

  (map [* _1 _2] '(1 2 3) '(4 5 6))
Note that this is currently bugged in Arc-F though. Will fix ^^.

The auto-gensyms thing looks cute. It might be possible to hack something like that, although it would require modifying the axiomatic quasiquote operator.

Basically:

  `(let foo# ,foo
     (do-some foo# foo#))
=>

  (quasiquote (let (unquote-uniq foo) (unquote foo)
                (do-some (unquote-uniq foo) (unquote-uniq foo))))
Then quasiquote has to expand to scheme style:

  (let ((gensym012032 (gensym)))
    (quasiquote (let (unquote gensym012032) (unquote foo)
                  (do-some (unquote gensym012032) (unquote gensym012032)))))
The recur bit is a lot like (afn () ... self)

-----