Pipe Branching Syntax Proposal

Or even like this so it is more traditionally pipe’y:

defmodule PipeMapInto do
  defmacro pipe_map_into(val_ast, applicitives_ast) when is_list(applicitives_ast) do
    do_pipe_map_into(val_ast, applicitives_ast)
  end
  defp do_pipe_map_into(val_ast, []), do: []
  defp do_pipe_map_into(val_ast, [applicitive_ast | rest_asts]) do
    [ quote do
        unquote(val_ast) |> unquote(applicitive_ast)
      end
    | do_pipe_map_into(val_ast, rest_asts)
    ]
  end
end

And used like:

iex> import PipeMapInto
PipeMapInto
iex> 2 |> pipe_map_into([
...>   add(2),
...>   add(5),
...>   mul(10),
...>   ])
[4, 7, 20]

Side Note: I’m noticing a lot of replies to old posts that have no replies, just trying to answer old posts or so? :slight_smile: