Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

You can create your own opportunities this week. Blackmail a senior executive.


comp / comp.lang.lisp / Re: bug (Funarg problem) in Gauche (Scheme) ?

SubjectAuthor
* bug (Funarg problem) in Gauche (Scheme) ?HenHanna
`- Re: bug (Funarg problem) in Gauche (Scheme) ?HenHanna

1
Subject: bug (Funarg problem) in Gauche (Scheme) ?
From: HenHanna
Newsgroups: comp.lang.scheme, comp.lang.lisp, fj.comp.lang.lisp
Organization: A noiseless patient Spider
Date: Sun, 19 May 2024 07:41 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.scheme,comp.lang.lisp,fj.comp.lang.lisp
Subject: bug (Funarg problem) in Gauche (Scheme) ?
Date: Sun, 19 May 2024 00:41:09 -0700
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <v2caem$38tor$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 May 2024 09:41:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c9b538879cf3e39a2903d58d140dec87";
logging-data="3438363"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+f1DAdKlGFFVDAhZh6yVdnNdhRPDl9uzo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:es1EGFFG6v3uQRus3syQXerHZ/E=
Content-Language: en-US
View all headers

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

Subject: Re: bug (Funarg problem) in Gauche (Scheme) ?
From: HenHanna
Newsgroups: comp.lang.scheme, comp.lang.lisp, fj.comp.lang.lisp
Organization: A noiseless patient Spider
Date: Sun, 19 May 2024 10:37 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: HenHanna@devnull.tb (HenHanna)
Newsgroups: comp.lang.scheme,comp.lang.lisp,fj.comp.lang.lisp
Subject: Re: bug (Funarg problem) in Gauche (Scheme) ?
Date: Sun, 19 May 2024 03:37:26 -0700
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <v2ckp7$3bajr$1@dont-email.me>
References: <v2caem$38tor$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 May 2024 12:37:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c9b538879cf3e39a2903d58d140dec87";
logging-data="3517051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kfHmgmDXhAsNyVIE74zVSNrgwq/Pqb8s="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:CFT3WnOwFeFSV4VTjcj0Hg6GrDs=
Content-Language: en-US
In-Reply-To: <v2caem$38tor$1@dont-email.me>
View all headers

On 5/19/2024 12:41 AM, HenHanna wrote:
> 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

No... my bad... That's not a bug. Just my error!

1

rocksolid light 0.9.8
clearnet tor