[plt-scheme] re: the fastest way to calc a cartesian product

From: Ian Barland (ibarland at radford.edu)
Date: Thu Sep 21 11:05:30 EDT 2006

>> An uncommented example:
>> ===========
>> (define cars  (lambda (elt) (memq elt '(vw saab bmw audi))))
>> (define evens (lambda (elt) (and (number? elt) (even? elt))))
>> (define (element-of? elt set) (set elt))
>> (define (cartesian-product A B)
>>   (lambda (elt)
>>      (and (length=2? elt)
>>           (element-of? (first elt) A)
>>           (element-of? (first elt) B))))
> ITYM "second" ?
D'oh!  That's what I get for not writing my tests until *after* I'd pasted
into the email, sigh.  Thanks.

Posted on the users mailing list.