Current section
Files
Jump to
Current section
Files
src/shapes.gleam
//// The shape module
import gleam/float
import gleam/int
/// Some shapes
pub type Shape {
Rectangle(width: Int, height: Int)
Circle(radius: Int)
Square(Float)
}
/// A function that take a shape, and returns some info about it.
pub fn shape_info(box: Shape) -> String {
case box {
Rectangle(..) -> "It's a rectangle."
Circle(42) -> "It's a circle with a radius of 42."
Circle(radius: r) ->
"It's a circle with a radius of " <> int.to_string(r) <> "."
Square(metre) -> "It's a " <> float.to_string(metre) <> " metre square."
}
}