Skip to content

Commit 5bd2934

Browse files
committed
Sample output added
1 parent da49841 commit 5bd2934

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

Special_Functions/FoldAndReduce.scala

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,62 @@ object FoldAndReduce extends App
3737
println("(1 to 10).foldLeft(0)(_ + _) : " + (1 to 10).foldLeft(0)(_ + _))
3838
println("(1 to 10).mkString(\",\") : " + (1 to 10).mkString(","))
3939
}
40+
41+
/***
42+
Sample Output
43+
Total: 0, Next:1
44+
Total: 1, Next:2
45+
Total: 3, Next:3
46+
Total: 6, Next:4
47+
Total: 10, Next:5
48+
Total: 15, Next:6
49+
Total: 21, Next:7
50+
Total: 28, Next:8
51+
Total: 36, Next:9
52+
Total: 45, Next:10
53+
foldLeftRes: 55
54+
55+
56+
Total: 1, Next:2
57+
Total: 3, Next:3
58+
Total: 6, Next:4
59+
Total: 10, Next:5
60+
Total: 15, Next:6
61+
Total: 21, Next:7
62+
Total: 28, Next:8
63+
Total: 36, Next:9
64+
Total: 45, Next:10
65+
reduceLeftRes: 55
66+
67+
68+
Total: 0, Next:10
69+
Total: 10, Next:9
70+
Total: 19, Next:8
71+
Total: 27, Next:7
72+
Total: 34, Next:6
73+
Total: 40, Next:5
74+
Total: 45, Next:4
75+
Total: 49, Next:3
76+
Total: 52, Next:2
77+
Total: 54, Next:1
78+
foldRightRes: 55
79+
80+
81+
Total: 10, Next:9
82+
Total: 19, Next:8
83+
Total: 27, Next:7
84+
Total: 34, Next:6
85+
Total: 40, Next:5
86+
Total: 45, Next:4
87+
Total: 49, Next:3
88+
Total: 52, Next:2
89+
Total: 54, Next:1
90+
reduceRightRes: 55
91+
92+
93+
(1 to 10).sum : 55
94+
(1 to 10).product : 3628800
95+
(1 to 10).foldLeft(0)(_ + _) : 55
96+
(1 to 10).mkString(",") : 1,2,3,4,5,6,7,8,9,10
97+
98+
**/

0 commit comments

Comments
 (0)