Skip to content

Commit

Permalink
Refactor to zip_reduce (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhanks authored Jan 16, 2024
1 parent daa31c4 commit 31c064f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 14 additions & 11 deletions lib/kino/debug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,20 @@ defmodule Kino.Debug do
assignments = quote do: unquote(head_var) = unquote(head_ast)

{assignments, _} =
rest_vars
|> Enum.zip(rest_asts)
|> Enum.reduce({assignments, head_var}, fn {var, node}, {assignments, prev_var} ->
assignments =
quote do
unquote(assignments)
unquote(var) = unquote(Macro.pipe(prev_var, node, 0))
end

{assignments, var}
end)
Enum.zip_reduce(
rest_vars,
rest_asts,
{assignments, head_var},
fn var, node, {assignments, prev_var} ->
assignments =
quote do
unquote(assignments)
unquote(var) = unquote(Macro.pipe(prev_var, node, 0))
end

{assignments, var}
end
)

funs =
for ast <- rest_asts do
Expand Down
2 changes: 1 addition & 1 deletion lib/kino/js.ex
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ defmodule Kino.JS do
duplicates = Enum.uniq(filenames -- Enum.uniq(filenames))

if duplicates != [] do
duplicates = duplicates |> Enum.map(&inspect/1) |> Enum.join(", ")
duplicates = duplicates |> Enum.map_join(", ", &inspect/1)

IO.warn(
"found duplicate assets in #{inspect(env.module)}: #{duplicates}",
Expand Down

0 comments on commit 31c064f

Please sign in to comment.