Skip to content

Commit a108983

Browse files
PastMomentslpil
authored andcommitted
Use erlang's lists:append/1 for list.flatten
1 parent 3972d84 commit a108983

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/gleam/list.gleam

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,15 +701,17 @@ pub fn prepend(to list: List(a), this item: a) -> List(a) {
701701

702702
/// Joins a list of lists into a single list.
703703
///
704-
/// This function traverses all elements twice.
705-
///
704+
/// This function traverses all elements twice on the Javascript target.
705+
/// This function traverses all elements once on the Erlang target.
706+
///
706707
/// ## Examples
707708
///
708709
/// ```gleam
709710
/// flatten([[1], [2, 3], []])
710711
/// // -> [1, 2, 3]
711712
/// ```
712713
///
714+
@external(erlang, "lists", "append")
713715
pub fn flatten(lists: List(List(a))) -> List(a) {
714716
flatten_loop(lists, [])
715717
}

0 commit comments

Comments
 (0)