From 2a6ae1fa5408247c95bf4a7d59e5038342a2a125 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Wed, 20 Dec 2023 20:46:44 +0000 Subject: Nil and bit arrays --- lessons/src/lesson036_bit_arrays/code.gleam | 13 +++++++++++++ lessons/src/lesson036_bit_arrays/text.html | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lessons/src/lesson036_bit_arrays/code.gleam create mode 100644 lessons/src/lesson036_bit_arrays/text.html (limited to 'lessons/src/lesson036_bit_arrays') diff --git a/lessons/src/lesson036_bit_arrays/code.gleam b/lessons/src/lesson036_bit_arrays/code.gleam new file mode 100644 index 0000000..dc772ca --- /dev/null +++ b/lessons/src/lesson036_bit_arrays/code.gleam @@ -0,0 +1,13 @@ +import gleam/io + +pub fn main() { + // 8 bit int. In binary: 00000011 + io.debug(<<3>>) + io.debug(<<3>> == <<3:size(8)>>) + + // 16 bit int. In binary: 0001100000000011 + io.debug(<<6147:size(16)>>) + + // A bit array of UTF8 data + io.debug(<<"Hello, Joe!":utf8>>) +} diff --git a/lessons/src/lesson036_bit_arrays/text.html b/lessons/src/lesson036_bit_arrays/text.html new file mode 100644 index 0000000..3214db1 --- /dev/null +++ b/lessons/src/lesson036_bit_arrays/text.html @@ -0,0 +1,26 @@ +

+ Bit arrays represent a sequence of 1s and 0s, and are a convenient syntax for + constructing and manipulating binary data. +

+

+ Each segment of a bit array can be given options to specify the representation + used for that segment. +

+ +

+ Bit arrays have limited support when compiling to JavaScript, not all options + can be used. Full bit array support will be implemented in future. +

-- cgit v1.2.3