bug (Funarg problem) in Gauche (Scheme) ?

Liste des GroupesRevenir à cl scheme 
Sujet : bug (Funarg problem) in Gauche (Scheme) ?
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : comp.lang.scheme comp.lang.lisp fj.comp.lang.lisp
Date : 19. May 2024, 09:41:09
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2caem$38tor$1@dont-email.me>
User-Agent : Mozilla Thunderbird
 From the Gauche (Scheme)  manual:
              (cartesian-product ’((a b c) (0 1)))
                    ⇒         ((a 0) (a 1) (b 0) (b 1) (c 0) (c 1))
___________________________________________________
The  Gauche (Scheme)  manual  describes
                                   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)
   (if (null? (cdr x))
     (map list (car x))
     (apply append
       (map (lambda (F)
              (map (lambda (R) (cons F R)) (cartesian-product (cdr x))))
            (car x)))))
(print (cartesian-product '((0 1))) )      ==> ((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  Gauche (Scheme).
             gosh>  (load "CpMerge.lsp")
             ((0) (1))
             *** ERROR: pair required, but got a
                           While loading "./CpMerge.lsp" at line 19

Date Sujet#  Auteur
19 May 24 * bug (Funarg problem) in Gauche (Scheme) ?2HenHanna
19 May 24 `- Re: bug (Funarg problem) in Gauche (Scheme) ?1HenHanna

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal