HIGH ORDER
FUNCTIONS
Whats are high order functions?
• One or more of its parameters is a function, and it returns

some value.
• It returns a function, but none of its parameters is a

function.
• One or more of its parameters is a function, and it returns

a function.
• def isEqualToFour(a:Int) = a == 4
• val list = List(1, 2, 3, 4)

• val resultExists4 = list.exists(isEqualToFour)
def sumInts(a: Int, b: Int): Int =
if (a > b) 0 else a + sumInts(a + 1, b)
Advantages
• Higher-order functions reduce program size and

accelerate development speed, particularly for large
programs.
• Expressiveness of a visual syntax
• Zero run-time cost in most cases
Thanks

Highorderfunctions

  • 1.
  • 2.
    Whats are highorder functions? • One or more of its parameters is a function, and it returns some value. • It returns a function, but none of its parameters is a function. • One or more of its parameters is a function, and it returns a function.
  • 3.
    • def isEqualToFour(a:Int)= a == 4 • val list = List(1, 2, 3, 4) • val resultExists4 = list.exists(isEqualToFour)
  • 4.
    def sumInts(a: Int,b: Int): Int = if (a > b) 0 else a + sumInts(a + 1, b)
  • 5.
    Advantages • Higher-order functionsreduce program size and accelerate development speed, particularly for large programs. • Expressiveness of a visual syntax • Zero run-time cost in most cases
  • 6.