Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Returning functions from functions?
- "currying"
- (Int, Int) => Int // uncurried
- def add(x,y): Int = x+y
- Int => (Int => (Int => Int)) // curried
- val add = x => (y => x+y)
- list.map(add(1))
- list.map(1+_)
- matrix.map(_.map(1+_))
- map(map(add(1)))(matrix)
- map(f)(list)
- map(list)(f)
- ===
- "staged computation"
- def search(word, text)
- def search(word): String => Boolean = {
- ...preprocess word...
- text => ...use the processed word...
- }
- def search2(text) = {
- ...preprocess text...
- word => ...use the processed text...
- }
- ===
- build big things by combining smaller things
Add Comment
Please, Sign In to add comment