blob: e58659a07f3c7bdd28bf42b47665da6bf0f22f1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import gleam/io
pub fn main() {
// Assign an anonymous function to a variable
let add_one = fn(a) { a + 1 }
io.debug(twice(1, add_one))
// Pass an anonymous function as an argument
io.debug(twice(1, fn(a) { a * 2 }))
}
fn twice(argument: Int, my_function: fn(Int) -> Int) -> Int {
my_function(my_function(argument))
}
|