[Nix-dev] Nix 1.2 released

Shea Levy shea at shealevy.com
Wed Dec 12 17:24:47 CET 2012


On 12/12/2012 11:20 AM, Eelco Dolstra wrote:
> Hi,
>
> On 12/12/12 17:15, Shea Levy wrote:
>
>>>> The elem library function evaluates all list elements instead of
>>>> returning "true" after finding a matching element.
>>> Sure about that?  This seems lazy enough:
>>>
>>>     elem =
>>>       builtins.elem or
>>>       (x: list: fold (a: bs: x == a || bs) false list);
>>>
>> Shouldn't the bs come first? i.e. (a: bs: bs || x == a)?
> Not if you want to check from left to right.
>

Huh? I didn't change the argument order, this is still a left fold. this 
just short-circuits the eval of (x == a) when bs is true.


More information about the nix-dev mailing list