diff --git a/assignment3/main.oz b/assignment3/main.oz index ed673c2..20b6e54 100644 --- a/assignment3/main.oz +++ b/assignment3/main.oz @@ -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}} + + diff --git a/assignment3/report.md b/assignment3/report.md index ffadebb..29186e7 100644 --- a/assignment3/report.md +++ b/assignment3/report.md @@ -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. +