unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* built-in procedural logical operator
@ 2015-09-01 15:44 Alex Vong
  2015-09-01 16:21 ` David Kastrup
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Vong @ 2015-09-01 15:44 UTC (permalink / raw)
  To: guile-user

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-01 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-01 15:44 built-in procedural logical operator Alex Vong
2015-09-01 16:21 ` David Kastrup
     [not found]   ` <CADrxHD8e6VoAsY5_rtD3od8iSR9VdZamDMiYQf2hNGcmq3Hdfw@mail.gmail.com>
2015-09-01 17:13     ` Alex Vong

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).