Skip to content

Commit 91cb3cf

Browse files
committed
Added anagrams (used standard library)
1 parent a831a74 commit 91cb3cf

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

gleam/gleam.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ version = "1.0.0"
1414

1515
[dependencies]
1616
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
17+
argv = ">= 1.0.2 and < 2.0.0"
1718

1819
[dev-dependencies]
1920
gleeunit = ">= 1.0.0 and < 2.0.0"

gleam/manifest.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
# You typically do not need to edit this file
33

44
packages = [
5+
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
56
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
67
{ name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
78
]
89

910
[requirements]
11+
argv = { version = ">= 1.0.2 and < 2.0.0" }
1012
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
1113
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }

gleam/src/anagrams_library.gleam

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import argv
2+
import gleam/io
3+
import gleam/list
4+
import gleam/string
5+
6+
pub fn main() {
7+
case argv.load().arguments {
8+
[word] ->
9+
word
10+
|> string.split("")
11+
|> list.permutations
12+
|> list.map(fn(letters) { string.join(letters, "") })
13+
|> list.each(fn(word) { io.println(word) })
14+
_ -> panic as "ERROR: There must be exactly 1 argument."
15+
}
16+
}

gleam/test.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ function Assert-MatchTests {
88
}
99
}
1010

11-
# Running the test requires the powershell to be in the Haxe folder.
11+
# Running the test requires the powershell to be in the Gleam root older.
1212
$currentLocation = $pwd
1313
Set-Location "$PSScriptRoot"
1414

15+
# Download dependencies if needed.
16+
gleam add argv
17+
1518
$Error.clear()
19+
gleam run -m anagrams_library rats |
20+
Compare-Object (Get-Content "$PSScriptRoot\..\test\rats_heap_expected") |
21+
Assert-MatchTests &&
1622
gleam run -m clockhands |
1723
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
1824
Assert-MatchTests &&

0 commit comments

Comments
 (0)