Skip to content
← Index | Lesson 4 of 5

Higher-Order Functions

Higher-Order Functions

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

Search Zolo

9 results

enespt-br