Hacker News new | ask | show | jobs
by skenney26 6394 days ago
Perhaps it would be simpler to pass the interval modifiers as functional arguments:

  (def mapr (f x y . fs)
    (let r (range x y)
      (map f r
             (apply map + (map [map _ r] fs)))))

  arc> (mapr (fn (x y) (prn x " " y)) 1 3 [+ _ 10])
  1 11
  2 12
  3 13
  (1 2 3)

  arc> (mapr (fn (x y) (prn x " " y)) 1 3 [expt _ 2])
  1 1
  2 4
  3 9
  (1 2 3)

  arc> (mapr (fn (x y) (prn x " " y)) 1 3 [+ _ 10] [expt _ 2])
  1 12
  2 16
  3 22
 (1 2 3)