Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 4675 days ago | link | parent

It occurs to me that avg is intended to be analogous to sum. Perhaps we could have two variants, avg and mean. Which one should be variadic, thoughts?


2 points by rocketnia 4675 days ago | link

Well, essentially we already have 'avg:list as the variadic version. In fact, it looks like we can shave off two characters:

  (map(fn e avg.e)r t)
  (map avg:list r t)
I don't remember ever using 'avg except maybe to average some time measurements at the REPL, and I think the idiom (avg:accum ...) comes in handy for that. But I generally don't use arithmetic operators in my programs, probably due to the subject matter I choose.

Edit: Here's another opportunity:

  (cdr(mem _ s))
  (cdr:mem _ s)

-----

1 point by akkartik 4675 days ago | link

After I wrote that comment it seemed to me that variadic is more fundamental, because you can always convert lists using apply. But you're right that it's not hard to bounce between the two.

-----