Skip to content
Course map | Lesson 4 of 5

Functions · 2.4

Higher-Order Functions

All lessons are open — jump whenever you need.

Functions that receive or return other functions:

fn apply(f, x: int) -> int {
    return f(x)
}

let result = apply(|x| x * x, 5)
print(result) // 25

Goal: Implement apply_twice(f, x) that applies the function f twice. Test with a closure that adds 3, passing the value 10 — result: 16.

lesson-2-4.zolo
Program output

Run the code to see the output

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br