Code · 1 file
Sample Gleam File
Gleam, a typed functional language for the Erlang VM. Every language sample implements the same small program so you can compare them side by side.
Gleam · 697 B
Sample Gleam file
An idiomatic Gleam example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.
CC0 · free for any use · Verified by an independent tool · Report a problem
// Sample Gleam program — samplefiles.com
import gleam/float
import gleam/io
import gleam/list
pub type Customer {
Customer(id: Int, name: String, balance: Float)
}
pub fn is_vip(customer: Customer) -> Bool {
customer.balance >=. 10_000.0
}
pub fn main() {
let customers = [
Customer(1, "Ada", 12_500.0),
Customer(2, "Grace", 830.5),
Customer(3, "Linus", 10_000.0),
]
list.each(customers, fn(c) {
let tag = case is_vip(c) {
True -> " VIP"
False -> ""
}
io.println(c.name <> " " <> float.to_string(c.balance) <> tag)File details
Download from the command line
curl -L -o sample.gleam https://files.samplefiles.com/code/gleam/sample.gleamwget https://files.samplefiles.com/code/gleam/sample.gleamhttps://files.samplefiles.com/code/gleam/sample.gleamprintf '%s %s\n' fa044d937164c06ce976d270e474bc9045406bec5950f4a595987b673e4a9d2e sample.gleam | shasum -a 256 -cOr check the download in your browser with the checksum calculator.