From: Alex Vong <alexvong1995@gmail.com>
To: guile-user@gnu.org
Subject: built-in procedural logical operator
Date: Tue, 1 Sep 2015 23:44:35 +0800 [thread overview]
Message-ID: <20150901234435.7d1c4384@debian> (raw)
Hi everyone,
I am learning scheme, please bear with me if I am wrong.
I try to define a new function LIST-OF-STRING?
(define (list-of-string? lst)
(reduce and #f (map string? lst)))
and I get the error
While compiling expression:
ERROR: Syntax error:
unknown location: source expression failed to match any pattern in form and
It seems it is because AND is implemented as a macro,
so I try to implement my own RECURSIVE-AND
(define (recursive-and . arg-lst)
(cond ((null? arg-lst) #t)
((not (car arg-lst)) #f)
(else (apply recursive-and (cdr arg-lst)))))
and now
(define (list-of-string? lst)
(reduce recursive-and #f (map string? lst)))
works as intended.
Is it a leaking implementation detail that AND is implemented as a macro?
Do we have a built-in procedural logical operators so that we don't that error?
I know it is easy enough to define your own RECURSIVE-AND and RECURSIVE-OR,
I just want to know it is a bug or a feature?
Thanks!
Cheers,
Alex
next reply other threads:[~2015-09-01 15:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 15:44 Alex Vong [this message]
2015-09-01 16:21 ` built-in procedural logical operator David Kastrup
[not found] ` <CADrxHD8e6VoAsY5_rtD3od8iSR9VdZamDMiYQf2hNGcmq3Hdfw@mail.gmail.com>
2015-09-01 17:13 ` Alex Vong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150901234435.7d1c4384@debian \
--to=alexvong1995@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).