Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Set = Int => Boolean
- def singletonSet(x: Int): Set = Set(x)
- val three = singletonSet(3)
- three(3) //True
- three(5) //False
- def map(s: Set, p: Int => Int): Set
- def map(s: Set, p: Int => Int): Set = {
- x =>
- if (s(x)) singletonSet(p(x))
- else p(x) => false
- }
- The error that I'm getting with this format is:
- error: not a legal formal parameter.
- Note: Tuples cannot be directly destructured in method or function parameters.
- Either create a single parameter accepting the Tuple1,
- or consider a pattern matching anonymous function: `{ case (param1, param1) => ... }
- else p(x) => false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement