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 — first linesGleam
// 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

Size
697 B (697 bytes)
MIME type
text/plain
SHA-256
fa044d937164c06ce976d270e474bc9045406bec5950f4a595987b673e4a9d2e
MD5
a0b9d2cd26612eb72dcd8ac111d75d30

Download from the command line

curl -L -o sample.gleam https://files.samplefiles.com/code/gleam/sample.gleam

Or check the download in your browser with the checksum calculator.