Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic mean forwards vs backwards?

I'm familiar with this way of doing an arithmetic mean in J:

+/ % #

But it's also shown here as

# %~ +/

Are these two versions interchangeable, and if not when should I use one versus the other?

like image 625
Alex Shroyer Avatar asked Sep 10 '26 02:09

Alex Shroyer


1 Answers

Dyadic ~ reverses the arguments of a verb. x f~ y is equivalent to y f x. You use ~ when you, um, want to reverse the arguments of a verb.

One of its most common uses is for forks and hooks composition. For example, because y f (g y) is (f g) y you can use ((f~) g) y when you need (g y) f y.

like image 117
Eelvex Avatar answered Sep 12 '26 09:09

Eelvex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!