A pattern I find myself in all the time is when I am writing a piped 
 series of function calls, when I need to pass the result into some 
parameter other than the first one.

Something like this.

        Map.get( p_map, puid )
        |> Group.insert_at( index, uid )
        |> ( &Map.put(p_map, puid, &1) ).()
        |> ( &put_primitive_map(graph, &1) ).()
        |> something_else()

The trick to pipe into a anonymous function works, but is ugly and least to 
poor readability.

I would really like a pipe_right macro, which would work something like 
this.

        Map.get( p_map, puid )
        |> Group.insert_at( index, uid )
        |>> Map.put(p_map, puid, &1)
        |>> put_primitive_map(graph, &1)
        |> something_else()

Note that it should be interchangeable with the standard pipe without 
breaking the piping flow.

I keep running into this and reached the point where I really want this 
macro in the Kernel module.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/a4c198a9-fdef-46ca-9467-e72c8bfeff22%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to