Skip to content

Commit 0625f4f

Browse files
pendletonglpil
authored andcommitted
fix: Renamed helper functions
1 parent 01cac5a commit 0625f4f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/gleam/list.gleam

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,15 +1835,19 @@ fn partition_loop(list, categorise, trues, falses) {
18351835
pub fn permutations(list: List(a)) -> List(List(a)) {
18361836
case list {
18371837
[] -> [[]]
1838-
l -> zipper(l, [], [])
1838+
l -> permutation_zip(l, [], [])
18391839
}
18401840
}
18411841

1842-
fn zipper(list: List(a), rest: List(a), acc: List(List(a))) -> List(List(a)) {
1842+
fn permutation_zip(
1843+
list: List(a),
1844+
rest: List(a),
1845+
acc: List(List(a)),
1846+
) -> List(List(a)) {
18431847
case list {
18441848
[] -> reverse(acc)
18451849
[head, ..tail] ->
1846-
zip_prepend(
1850+
permutation_prepend(
18471851
head,
18481852
permutations(reverse_and_prepend(rest, tail)),
18491853
tail,
@@ -1853,17 +1857,17 @@ fn zipper(list: List(a), rest: List(a), acc: List(List(a))) -> List(List(a)) {
18531857
}
18541858
}
18551859

1856-
fn zip_prepend(
1860+
fn permutation_prepend(
18571861
el: a,
18581862
permutations: List(List(a)),
18591863
list_1: List(a),
18601864
list_2: List(a),
18611865
acc: List(List(a)),
18621866
) -> List(List(a)) {
18631867
case permutations {
1864-
[] -> zipper(list_1, list_2, acc)
1868+
[] -> permutation_zip(list_1, list_2, acc)
18651869
[head, ..tail] ->
1866-
zip_prepend(el, tail, list_1, list_2, [[el, ..head], ..acc])
1870+
permutation_prepend(el, tail, list_1, list_2, [[el, ..head], ..acc])
18671871
}
18681872
}
18691873

0 commit comments

Comments
 (0)