From the Gauche (Scheme)-a manual:
-a-a-a-a-a-a-a-a-a-a-a-a (cartesian-product rCO((a b c) (0 1)))
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a rcA-a-a-a-a-a-a-a-a ((a 0) (a 1) (b 0) (b 1) (c 0) (c 1))
___________________________________________________
The-a Gauche (Scheme)-a manual-a describes
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a string-count and cartesian-product
as built-in functions, but I couldn't use them and ended up defining
them myself.
(define (cartesian-product x)
-a (if (null? (cdr x))
-a-a-a (map list (car x))
-a-a-a (apply append
-a-a-a-a-a (map (lambda (F)
-a-a-a-a-a-a-a-a-a-a-a-a (map (lambda (R) (cons F R)) (cartesian-product (cdr x))))
-a-a-a-a-a-a-a-a-a-a (car x)))))
(print (cartesian-product '((0 1))) )-a-a-a-a-a ==> ((0) (1))
(print (cartesian-product '((a b)(0 1))) ) ==> ((a 0) (a 1) (b 0) (b 1))
________________________________________
The above code works fine, but when i rename the variable (F) as (x), i
get the following error, and this must be a bug in-a Gauche (Scheme).
-a-a-a-a-a-a-a-a-a-a-a gosh>-a (load "CpMerge.lsp")
-a-a-a-a-a-a-a-a-a-a-a ((0) (1))
-a-a-a-a-a-a-a-a-a-a-a *** ERROR: pair required, but got a
-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a-a While loading "./CpMerge.lsp" at line 19
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 55:36:50 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,684 |