From 31c064f7acd582e131461d54b0ff6d089f318cea Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Mon, 15 Jan 2024 21:15:49 -0700 Subject: [PATCH] Refactor to zip_reduce (#379) --- lib/kino/debug.ex | 25 ++++++++++++++----------- lib/kino/js.ex | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/kino/debug.ex b/lib/kino/debug.ex index 94030f87..975a2391 100644 --- a/lib/kino/debug.ex +++ b/lib/kino/debug.ex @@ -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 diff --git a/lib/kino/js.ex b/lib/kino/js.ex index 3268dec1..1be1e285 100644 --- a/lib/kino/js.ex +++ b/lib/kino/js.ex @@ -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}",