blob: f4539751e4fbf20c0bd04cb20f699fdbd3edc4f1 (
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(a: Int, function: fn(Int) -> Int) -> Int {
function(function(a))
}
fn add_one(a: Int) -> Int {
a + 1
}
|