Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.40 KB | None | 0 0
  1. // x, f(x), f(f(x)), ..
  2.     def riddleR(f : (Int) => Int, x : Int, num : Int, numanswers : Int) : Boolean =
  3.      num match
  4.      {
  5.       case 0 =>
  6.       {
  7.        numanswers match
  8.        {
  9.         case 0 => readInt == x
  10.         case _ if(numanswers >= 0) => readInt == x && riddleR(f, f(x), 0, numanswers - 1)
  11.        }
  12.       }
  13.       case _ if(num > 0) =>
  14.       {
  15.        print(x + ", ")
  16.        riddleR(f, f(x), num - 1, numanswers)
  17.       }
  18.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement