task 4 - quadratic polynomial currying
This commit is contained in:
@@ -87,3 +87,11 @@ local Iota Product Factorial in
|
||||
{System.show {Factorial 5}}
|
||||
end
|
||||
|
||||
% task 4
|
||||
fun {Quadratic A B C}
|
||||
fun {$ X} A*X*X + B*X + C end
|
||||
end
|
||||
{System.show '3*2^2 + 2*2 + 1 ='}
|
||||
{System.show {{Quadratic 3 2 1} 2}}
|
||||
|
||||
|
||||
|
||||
@@ -127,3 +127,15 @@ end
|
||||
{System.show {Factorial 5}} % -> 5! = 120
|
||||
```
|
||||
|
||||
## task 4
|
||||
|
||||
trivially curried* function
|
||||
|
||||
```oz
|
||||
fun {Quadratic A B C}
|
||||
fun {$ X} A*X*X + B*X + C end
|
||||
end
|
||||
```
|
||||
|
||||
*: Quadratic is of arity 3, but could be thought of as arity 4 if you consider the argument of it's returned function as well. all functions of arity greater than 1 can be thought of as functions returning functions composed with each other: currying. named after Haskell Curry.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user