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? >> -- Bahman Movaqar http://BahmanM.com - https://twitter.com/bahman__m https://github.com/bahmanm - https://gist.github.com/bahmanm PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com)
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users