> I'm a really big fan of Lisp, and particularly Scheme.
> It's a relatively short time that I've been studying the language. I'm
> really enjoying the SICP videos. I'm a math student, and I wanted to
> produce a table of boolean values for various operations such as AND,
> OR, etc...
> Like this:
> AND table:
> A B Result
> ------------------------
> #f #f #f
> #f #t #f
> #t #f #f
> #t #t #t
> I know Scheme hasn't got Common Lisp's loop special form so I tries to
> figure a way of doing it, and I cooked up the following two solutions.
> Can anybody tell me if they're acceptable enough or whether there are
> better ways of iterating over lists especially in NESTED loops?
> Here's the code:
> (define boolean (list #f #t))
> (let loop ((list-a boolean) (list-b boolean))
> (if (null? list-a)
> 'done
> (if (null? list-b)
> (loop (cdr list-a) boolean)
> (let ((a (car list-a)) (b (car list-b)))
> (display a)
> (display " ")
> (display b)
> (display " ")
> (display (or a b))
> (newline)
> (loop list-a (cdr list-b))))))
There's alway do loops: