diff options
author | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-12-21 22:09:25 +0100 |
---|---|---|
committer | Tomasz Chojnacki <tomaszchojnacki2001@gmail.com> | 2023-12-21 22:09:25 +0100 |
commit | d8e183f02f67522d94deafa328e19b3081ca41be (patch) | |
tree | 4617cc4fec15365cdcdfeb594b02432937d6c946 /aoc-2020-gleam/src/util/graph.gleam | |
parent | 02598d252c0e9093384ec53e46445df1a783feda (diff) | |
download | gleam_aoc2020-d8e183f02f67522d94deafa328e19b3081ca41be.tar.gz gleam_aoc2020-d8e183f02f67522d94deafa328e19b3081ca41be.zip |
Update to newest Gleam version
Diffstat (limited to 'aoc-2020-gleam/src/util/graph.gleam')
-rw-r--r-- | aoc-2020-gleam/src/util/graph.gleam | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/aoc-2020-gleam/src/util/graph.gleam b/aoc-2020-gleam/src/util/graph.gleam index d9aa5aa..5d02fff 100644 --- a/aoc-2020-gleam/src/util/graph.gleam +++ b/aoc-2020-gleam/src/util/graph.gleam @@ -1,6 +1,6 @@ import gleam/list -import gleam/iterator.{Iterator} as iter -import gleam/set.{Set} +import gleam/iterator.{type Iterator} as iter +import gleam/set.{type Set} fn dfs_helper( neighbours: fn(a) -> Iterator(a), @@ -14,7 +14,7 @@ fn dfs_helper( neighbours, stack: node |> neighbours - |> iter.filter(for: fn(n) { !set.contains(visited, n) }) + |> iter.filter(keeping: fn(n) { !set.contains(visited, n) }) |> iter.to_list |> list.append(stack), visited: visited @@ -26,10 +26,7 @@ fn dfs_helper( } pub fn dfs(from start: a, with neighbours: fn(a) -> Iterator(a)) -> Iterator(a) { - iter.from_list(dfs_helper( - neighbours, - stack: [start], - visited: set.new(), - acc: [], - )) + iter.from_list( + dfs_helper(neighbours, stack: [start], visited: set.new(), acc: []), + ) } |