[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
built-in procedural logical operator
From: |
Alex Vong |
Subject: |
built-in procedural logical operator |
Date: |
Tue, 1 Sep 2015 23:44:35 +0800 |
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
- built-in procedural logical operator,
Alex Vong <=