[erlang-questions] Erlang cons function

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Tue Jan 31 22:34:52 CET 2017


It is easy to define:

cons(H,T) -> [H|T].

but you are perhaps better off by just using a fun-wrapper or writing it
directly in places where you need it. Without support for currying much of
the higher-order vocabulary seems somewhat weaker.

On Tue, Jan 31, 2017 at 7:26 PM Richard Carlsson <carlsson.richard@REDACTED>
wrote:

> No, it's considered a language primitive, similar to fixed-size tuples
> {1,2}. That's not to say that there couldn't be a named function like the
> one you looked for, just that there isn't one because there has never been
> much of a need for it.
>
>         /Richard
>
> 2017-01-31 16:16 GMT+01:00 Garrett Smith <g@REDACTED>:
>
> Is there a functional reference to the cons operator? Something
> equivalent to this:
>
>   fun(H, T) -> [H|T] end
>
> I was hoping for erlang:'|'(H, T) but no dice.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170131/b2981e5c/attachment.htm>


More information about the erlang-questions mailing list