[erlang-questions] Pipe Operator in Erlang?

Serge Aleynikov serge@REDACTED
Thu Jul 9 22:03:36 CEST 2015


I believe this is not quite the same thing as your proposition would
require for each a, b, c to be expressions that could be used in guards
whereas I was looking for a generic way to be able to join several matches
in a single 'case' branch (in the spirit of the C's multiple subsequent
case statements):

case {Ctrl, Char} of
  {ctrl, _} ->
    ignore;
  {_, $\n} | {_, $\r} ->
    end_of_line;
  Other ->
    Other
end.


On Thu, Jul 9, 2015 at 3:52 PM, Loïc Hoguin <essen@REDACTED> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150709/fa03d4c3/attachment.htm>


More information about the erlang-questions mailing list