diff options
author | Giacomo Cavalieri <giacomo.cavalieri@icloud.com> | 2024-10-20 13:43:15 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-10-20 20:07:28 +0100 |
commit | dd90ccf53a028bda83e7f6dcdb8bdb002ed168bf (patch) | |
tree | 5db0e265ef5c2fcacc135cacb58c036fa429800c /src | |
parent | 5d7033c845469f9c70a6b877670319ae27c7b51a (diff) | |
download | gleam_stdlib-dd90ccf53a028bda83e7f6dcdb8bdb002ed168bf.tar.gz gleam_stdlib-dd90ccf53a028bda83e7f6dcdb8bdb002ed168bf.zip |
deprecate concat
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/dynamic.gleam | 16 | ||||
-rw-r--r-- | src/gleam/list.gleam | 11 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam index 5b3bb46..f142034 100644 --- a/src/gleam/dynamic.gleam +++ b/src/gleam/dynamic.gleam @@ -1087,7 +1087,7 @@ pub fn decode2( fn(value) { case t1(value), t2(value) { Ok(a), Ok(b) -> Ok(constructor(a, b)) - a, b -> Error(list.concat([all_errors(a), all_errors(b)])) + a, b -> Error(list.flatten([all_errors(a), all_errors(b)])) } } } @@ -1121,7 +1121,7 @@ pub fn decode3( case t1(value), t2(value), t3(value) { Ok(a), Ok(b), Ok(c) -> Ok(constructor(a, b, c)) a, b, c -> - Error(list.concat([all_errors(a), all_errors(b), all_errors(c)])) + Error(list.flatten([all_errors(a), all_errors(b), all_errors(c)])) } } } @@ -1169,7 +1169,7 @@ pub fn decode4( Ok(a), Ok(b), Ok(c), Ok(d) -> Ok(constructor(a, b, c, d)) a, b, c, d -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), @@ -1226,7 +1226,7 @@ pub fn decode5( Ok(a), Ok(b), Ok(c), Ok(d), Ok(e) -> Ok(constructor(a, b, c, d, e)) a, b, c, d, e -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), @@ -1288,7 +1288,7 @@ pub fn decode6( Ok(constructor(a, b, c, d, e, f)) a, b, c, d, e, f -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), @@ -1354,7 +1354,7 @@ pub fn decode7( Ok(constructor(a, b, c, d, e, f, g)) a, b, c, d, e, f, g -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), @@ -1424,7 +1424,7 @@ pub fn decode8( Ok(constructor(a, b, c, d, e, f, g, h)) a, b, c, d, e, f, g, h -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), @@ -1498,7 +1498,7 @@ pub fn decode9( Ok(constructor(a, b, c, d, e, f, g, h, i)) a, b, c, d, e, f, g, h, i -> Error( - list.concat([ + list.flatten([ all_errors(a), all_errors(b), all_errors(c), diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index f0248e7..c363cda 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -699,6 +699,7 @@ fn do_concat(lists: List(List(a)), acc: List(a)) -> List(a) { /// // -> [1, 2, 3] /// ``` /// +@deprecated("Use `list.flatten` instead.") pub fn concat(lists: List(List(a))) -> List(a) { do_concat(lists, []) } @@ -730,7 +731,7 @@ pub fn flatten(lists: List(List(a))) -> List(a) { /// pub fn flat_map(over list: List(a), with fun: fn(a) -> List(b)) -> List(b) { map(list, fun) - |> concat + |> flatten } /// Reduces a list of elements into a single value by calling a given function @@ -1888,7 +1889,7 @@ pub fn permutations(list: List(a)) -> List(List(a)) { |> permutations |> map(fn(permutation) { [i, ..permutation] }) }) - |> concat + |> flatten } } @@ -2216,7 +2217,7 @@ fn do_combination_pairs(items: List(a)) -> List(List(#(a, a))) { /// pub fn combination_pairs(items: List(a)) -> List(#(a, a)) { do_combination_pairs(items) - |> concat + |> flatten } /// Make a list alternating the elements from the given lists @@ -2230,7 +2231,7 @@ pub fn combination_pairs(items: List(a)) -> List(#(a, a)) { /// pub fn interleave(list: List(List(a))) -> List(a) { transpose(list) - |> concat + |> flatten } /// Transpose rows and columns of the list of lists. @@ -2262,7 +2263,7 @@ pub fn transpose(list_of_list: List(List(a))) -> List(List(a)) { let firsts = rows |> map(take_first) - |> concat + |> flatten let rest = transpose(map(rows, drop(_, 1))) [firsts, ..rest] } |