Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Professor used "The binary version of a function". Does that even exist?

Our professor used this in the assignment. I don't think "The binary version of a function" exist after searching about it in Google. What do you think it means?

Say we have a function add that adds a bunch of numbers. Rather than writing add(3, 5, 4, 1) we want to use currying to create an adder function that can be extended using a chain of calls. We would then have adder(3)(5)(4)(1)(). Let us assume we have the currying function that can create this adder given the add2 function (the binary version of add) and a start value. Let us call it curry. Then we have adder = curry(add2, 0).

like image 667
mmswe Avatar asked Nov 25 '25 20:11

mmswe


1 Answers

I think he means a function that accepts only two arguments, so it just adds two numbers. His example function add(3, 5, 4, 1) would be a function that accepts any number of arguments and adds them all, but add2 would only accept two arguments, so add2(3, 5) would be 8. "The binary version of a function" in this case means a binary function (a function accepting two arguments).

like image 72
BrenBarn Avatar answered Nov 28 '25 12:11

BrenBarn



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!