Arc Forumnew | comments | leaders | submitlogin
2 points by absz 6113 days ago | link | parent

I'm not a CLer, so I've never used loop, but in reading this example, couldn't you write it as

  (def count-cousins (self)
    (- (reduce + (map [len (kids _)] (kids .gramps))) 1))
? Or even, if I remember reduce properly, as

  (def count-cousins (self)
    (- (reduce [+ _1 (len (kids _2))] (kids .gramps)) 1))
? (Though that requires the multi-argument [] form on the git "wiki"; you can of course do it as a normal fn, though.) I personally love map, reduce, keep, etc., and find them to be incredibly effective for working on lists.

However, I do quite like the idea of symbol macros. There's a nicety to .gramps that (.gramps) doesn't have. (Setting aside the fact that with the new . syntax, .gramps is an illegal name.)