blob: e3fb3e70f86a983709f6177fd2cdc8b1f24643dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import gleam/io
pub fn main() {
// Call a function with another function
io.debug(twice(1, add_one))
// Functions can be assigned to variables
let function = add_one
io.debug(function(100))
}
fn twice(argument: Int, function: fn(Int) -> Int) -> Int {
function(function(argument))
}
fn add_one(argument: Int) -> Int {
argument + 1
}
|