From 938f49fc7835501192ccc7db7c1ab3174f050b34 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Tue, 20 Feb 2024 12:20:16 +0000 Subject: Let assert --- .../lesson06_external_gleam_fallbacks/code.gleam | 18 ------------------ .../lesson06_external_gleam_fallbacks/en.html | 13 ------------- 2 files changed, 31 deletions(-) delete mode 100644 src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/code.gleam delete mode 100644 src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html (limited to 'src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks') diff --git a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/code.gleam b/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/code.gleam deleted file mode 100644 index a97b8fc..0000000 --- a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/code.gleam +++ /dev/null @@ -1,18 +0,0 @@ -import gleam/io - -@external(erlang, "lists", "reverse") -pub fn reverse_list(items: List(e)) -> List(e) { - tail_recursive_reverse(items, []) -} - -fn tail_recursive_reverse(items: List(e), reversed: List(e)) -> List(e) { - case items { - [] -> reversed - [first, ..rest] -> tail_recursive_reverse(rest, [first, ..reversed]) - } -} - -pub fn main() { - io.debug(reverse_list([1, 2, 3, 4, 5])) - io.debug(reverse_list(["a", "b", "c", "d", "e"])) -} diff --git a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html b/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html deleted file mode 100644 index 243c7ea..0000000 --- a/src/content/chapter5_advanced_features/lesson06_external_gleam_fallbacks/en.html +++ /dev/null @@ -1,13 +0,0 @@ -

- It's possible for a function to have both a Gleam implementation and an - external implementation. If there exists an external implementation for the - currently compiled-for target then it will be used, otherwise the Gleam - implementation is used. -

-

- This may be useful if you have a function that can be implemented in Gleam, - but there is an optimised implementation that can be used for one target. For - example, the Erlang virtual machine has a built-in list reverse function that - is implemented in native code. The code here uses this implementation when - running on Erlang, as it is then available. -

-- cgit v1.2.3