Practicing currying

Exercise in Carying: Create a function that determines if a number is greater than 4 by Carying. Here is the function definition.

def largerThan(n: Int)(i: Int): Boolean = i > n

Now largerThan(4) is greater than 4? so it can be passed directly to filter function.

List(5,1,2,4,0).filter(largerThan(4))

この記事が気に入ったらサポートをしてみませんか?