I’d use test-assert with member: http://api.call-cc.org/doc/test/test-assert

Bahman Movaqar writes:

> On 01/05/2015 10:26 PM, Alex Charlton wrote:
>> Just use member. Member returns #f when the element is not contained in the 
>> list. Your first function will never return #f, since member never returns 
>> an empty list.
>
> My mistake. This naive question actually popped up when I was writing
> tests...the following will fail where it should pass because "test"
> expects an identical value to pass.
>   (test #t (member a-thing list-of-things))
> So how would you go around this?
>
>>
>> Bahman Movaqar writes:
>>
>>> I need to check if a list contains an element. There are 2 approaches as
>>> far as I could gather:
>>>
>>>   A: (define (member? e l) (not (null? (member e l))))
>>>   B: (define (member? e l) (any (lambda (x) (equal? x e)) l)) ;; using
>>> srfi-1
>>>
>>> Which one do you seasoned CHICKEN'ers recommend in terms of performance
>>> and being idiomatic?
>>>


-- 
Alex


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to