[erlang-questions] Pipe Operator in Erlang?

Loïc Hoguin essen@REDACTED
Thu Jul 9 21:52:08 CEST 2015


Closer to Erlang syntax would be something like:

case SomeVar of
     V when V in [a, b, c] -> true;
     _ -> false
end

Or better yet:

if
     SomeVar in [a, b, c] -> true;
     true -> false
end

You can generalize with variables (SomeVar in List) though the compiler 
probably won't be able to optimize those away.

Of course the whole "returning a boolean" makes no sense, you probably 
want a function call in its place instead.

On 07/09/2015 07:44 PM, Serge Aleynikov wrote:
> Though it's a bit off topic, but I'd love to see a different kind of
> application of '|' supported by syntax (yet probably ';' would be more
> in the "Erlang" spirit for the task):
>
> case SomeVar of
>    a | b | c ->
>      true;
>    _ ->
>      false
> end.
>
>
>
> On Thu, Jul 9, 2015 at 11:24 AM, Volkert
> <volkert@REDACTED
> <mailto:volkert@REDACTED>> wrote:
>
>     Dear all,
>
>     I really love the Pipe Operator |> in Elixir and F#.
>
>     Are there any plans to have this in Erlang?
>
>     Volkert
>
>
>
>     _______________________________________________
>     erlang-questions mailing list
>     erlang-questions@REDACTED <mailto:erlang-questions@REDACTED>
>     http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang



More information about the erlang-questions mailing list