diff options
author | Louis Pilfold <louis@lpil.uk> | 2023-12-06 17:57:04 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-12-06 17:57:04 +0000 |
commit | 58efb89355676356ee1006bbd2c8b0ee44108358 (patch) | |
tree | f07f88c52150e738ddf597d3d4daab9444c01a9f /lessons/src/lesson004_ints | |
parent | e66db486ffa57a1ce68a85ab6cb7bfbb05e260b8 (diff) | |
download | tour-58efb89355676356ee1006bbd2c8b0ee44108358.tar.gz tour-58efb89355676356ee1006bbd2c8b0ee44108358.zip |
More try lessons
Diffstat (limited to 'lessons/src/lesson004_ints')
-rw-r--r-- | lessons/src/lesson004_ints/code.gleam | 5 | ||||
-rw-r--r-- | lessons/src/lesson004_ints/text.html | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lessons/src/lesson004_ints/code.gleam b/lessons/src/lesson004_ints/code.gleam index fbead50..5076902 100644 --- a/lessons/src/lesson004_ints/code.gleam +++ b/lessons/src/lesson004_ints/code.gleam @@ -1,4 +1,5 @@ import gleam/io +import gleam/int pub fn main() { // Int arithmetic @@ -13,4 +14,8 @@ pub fn main() { io.debug(2 < 1) io.debug(2 >= 1) io.debug(2 <= 1) + + // Standard library int functions + io.debug(int.max(42, 77)) + io.debug(int.clamp(5, 10, 20)) } diff --git a/lessons/src/lesson004_ints/text.html b/lessons/src/lesson004_ints/text.html index f5222ee..32a7aa8 100644 --- a/lessons/src/lesson004_ints/text.html +++ b/lessons/src/lesson004_ints/text.html @@ -1,2 +1,15 @@ <p> + Gleam's <code>Int</code> type represents whole numbers. +</p> +<p> + There are arithmetic and comparison operators for ints. +</p> +<p> + When running on the Erlang virtual machine ints have no maximum and minimum + size. When running on JavaScript runtimes ints are represented using + JavaScript's 64 bit floating point numbers, +</p> +<p> + The <a href="https://hexdocs.pm/gleam_stdlib/gleam/int.html"><code>gleam/int</code></a> + standard library module contains functions for working with ints. </p> |