Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 5936 days ago | link | parent

Avoiding apply:

  (def >> (parm . args)
    ((afn (parm args)
       (if (no args)
           parm
           (self ((car args) parm) (cdr args))))
     parm args))


4 points by rincewind 5936 days ago | link

Avoiding re-inventing rreduce:

  (def >> args
     (rreduce (fn (a b) a.b) rev.args))

-----

3 points by almkglor 5936 days ago | link

Avoiding rev:

  (def >> args
    ; throw an error here so that user won't get
    ; mysterious errors in the 'reduce part
    (if (no args)
      (err "'>> requires at least one argument"))
    (reduce (fn (a b) b.a) args))

-----