Browse files

added koan for partial application

  • Loading branch information...
1 parent 8bf0459 commit 455d26391310502128bcd20cdf27ac4ce55dc77d @ChrisMarinos committed Nov 1, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1 FSharpKoans/MoreAboutFunctions.fs
View
21 FSharpKoans/MoreAboutFunctions.fs
@@ -16,4 +16,23 @@ type ``more about functions``() =
(* The fun keyword allows you to create a function inline without giving
it a name. These functions are known as anonymous functions, lambdas,
- or lambda functions. *)
+ or lambda functions. *)
+
+ [<Koan>]
+ member this.PartialApplication() =
+ let add x y =
+ x + y
+
+ (* You already know that you can pass multiple arguments to a function
+ at once *)
+ let thirteen = add 6 7
+ AssertEquality thirteen __
+
+ (* but you can also pass arguments one at a time to create residual
+ functions. This is called Partial Application. *)
+ let addSeven = add 7
+ let unluckyNumber = addSeven 6
+ let luckyNumber = addSeven 0
+
+ AssertEquality unluckyNumber __
+ AssertEquality luckyNumber __

0 comments on commit 455d263

Please sign in to comment.