Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. type Set = Int => Boolean
  2.  
  3. def singletonSet(x: Int): Set = Set(x)
  4. val three = singletonSet(3)
  5. three(3) //True
  6. three(5) //False
  7.  
  8. def map(s: Set, p: Int => Int): Set
  9.  
  10. def map(s: Set, p: Int => Int): Set = {
  11. x =>
  12. if (s(x)) singletonSet(p(x))
  13. else p(x) => false
  14. }
  15.  
  16. The error that I'm getting with this format is:
  17. error: not a legal formal parameter.
  18. Note: Tuples cannot be directly destructured in method or function parameters.
  19. Either create a single parameter accepting the Tuple1,
  20. or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
  21. else p(x) => false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement