[erlang-questions] list comprehensions speed

Loïc Hoguin essen@REDACTED
Tue Feb 25 22:46:15 CET 2014


On 02/25/2014 10:22 PM, Richard A. O'Keefe wrote:
>
> On 26/02/2014, at 5:33 AM, Oleg wrote:
>
>> If we can use =:= for the string matching, why does string module contain equal()?
>
> (1) Abstraction.
> (2) To have a function that you can pass around.
>      There's a nasty little gotcha in Erlang, which I've
>      never been able to see the point of.
>
>      In Lisp,    I can use #'EQUAL   to get the equality function.
>      "  SML,     " "   "   op =      "  "   "   "        "
>      "  Haskell, " "   "   (==)      "  "   "   "        "
>      In Erlang,  there is nothing I can use.
>
>      You might expect that fun erlang:'=:='/2 or even
>      fun =:= would do the trick.  But it doesn't.  If
>      you have a function that takes a two-argument "match"
>      predicate, and you want to pass =:= to it, you must
>      have a "real" function.

I'm not sure what you mean by that?

1> F = fun erlang:'=:='/2.
#Fun<erlang.=:=.2>
2> F(1, 1).
true

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-questions mailing list