tracks-on-tracks-on-tracks

This commit is contained in:
Alexander Heldt
2025-11-03 21:47:09 +01:00
parent 2ac630dd8c
commit b8181175c9
10 changed files with 442 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import gleam/list
pub fn new_list() -> List(String) {
[]
}
pub fn existing_list() -> List(String) {
["Gleam", "Go", "TypeScript"]
}
pub fn add_language(languages: List(String), language: String) -> List(String) {
[language, ..languages]
}
pub fn count_languages(languages: List(String)) -> Int {
list.length(languages)
}
pub fn reverse_list(languages: List(String)) -> List(String) {
list.reverse(languages)
}
pub fn exciting_list(languages: List(String)) -> Bool {
// - The first on the list is Gleam.
// - The second item on the list is Gleam and the list contain either two or three languages.
case languages {
[first] -> first == "Gleam"
[first, second, ..] ->
first == "Gleam"
|| {
second == "Gleam"
&& { list.length(languages) == 2 || list.length(languages) == 3 }
}
_ -> False
}
}