We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab272c4 commit dfbd0d6Copy full SHA for dfbd0d6
Functions/Currying.scala
@@ -0,0 +1,23 @@
1
+/**
2
+ * Currying is taking a set of arguments and turning them into sequence of functions returning functions.
3
+ * You can convert a function into a currying function by calling curried on that function.
4
+ * Use Funtion.uncurried to uncurry a function.
5
+ * Currying is named after mathematician Haskel Curry.
6
+ */
7
+
8
+object Currying extends App{
9
+ val g = (x:Int) => (y:Int) => x + y //here g is a function which returns a function with returns Int
10
11
+ val f = (x:Int, y:Int) => x + y
12
13
+ val fc = f.curried //fc and g are the same functions
14
15
+ val fuc = Function.uncurried(fc)
16
17
+ println("fuc(4, 5) : " +fuc(4, 5))
18
+}
19
20
21
+ Sample Output
22
+fuc(4, 5) : 9
23
+*/
0 commit comments