Skip to content

Commit 7e7f29d

Browse files
committed
Added the permutations
1 parent 91cb3cf commit 7e7f29d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

gleam/src/permutations.gleam

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
[_, ..] ->
9+
argv.load().arguments
10+
|> list.permutations
11+
|> list.map(fn(words) { string.join(words, "\t") })
12+
|> list.each(io.println)
13+
_ -> panic as "ERROR: There must be at least 1 argument."
14+
}
15+
}

gleam/test.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ gleam run -m clockhands |
2525
gleam run -m factorial &&
2626
gleam run -m generics &&
2727
gleam run -m hello &&
28+
gleam run -m permutations I like carrots |
29+
Compare-Object (Get-Content "$PSScriptRoot\..\test\carrots_expected") |
30+
Assert-MatchTests &&
2831
gleam run -m pipelines &&
2932
gleam run -m sum_of_even_squares &&
3033
gleam run -m triple_pipelines |

0 commit comments

Comments
 (0)