Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.42 KB | None | 0 0
  1. println("hello there")                                                          //hello there
  2.                                                                                 //res0: Unit = ()
  3. def mapRangeSum(f: Int => Int)(start: Int, end: Int) = {                        //
  4.   start to end map f sum                                                        //mapRangeSum: mapRangeSum[](val f: Int => Int)(val start: Int,val end: Int) => Int
  5. }                                                                               //
  6.                                                                                 //
  7. println(mapRangeSum(x => x + 2)(1, 50))                                         //
  8.                                                                                 //1375
  9. val mapRangeSum1 = (f: Int => Int) => {                                         //res1: Unit = ()
  10.   (start: Int, end: Int) => {                                                   //
  11.     (start to end).map(x => f(x)).sum                                           //mapRangeSum1: (Int => Int) => ((Int, Int) => Int) = <function1>
  12.   }                                                                             //
  13. }                                                                               //
  14.                                                                                 //
  15. println(mapRangeSum1(x => x + 2)(1, 50))                                        //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement