fork download
  1. object Main extends App {
  2. def boundedInt(min:Int, max: Int): Int => Int = {
  3. case n if n>max => max
  4. case n if n<min => min
  5. case n => n
  6. }
  7.  
  8. val oneToTen = boundedInt(1, 10)
  9.  
  10. println(oneToTen(-2))
  11. println(oneToTen(5))
  12. println(oneToTen(42))
  13. }
Success #stdin #stdout 0.38s 322368KB
stdin
Standard input is empty
stdout
1
5
10