task 4 - quadratic polynomial currying

This commit is contained in:
2025-09-28 14:57:02 +02:00
parent 910e758a75
commit d8a9d68624
2 changed files with 20 additions and 0 deletions

View File

@@ -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}}

View File

@@ -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.