|
SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
| <<[pred] | [Index] | [product]>> |
Conformance: SketchyLISP Core
Purpose: Turn a binary predicate into a variadic predicate.
Arguments:
P - predicate
Implementation:
(define (predicate-iterator p)
(lambda (first . rest)
(let ((fail (cons 'fail '())))
(let
((comp
(lambda (a b)
(cond ((eq? a fail) fail)
((p a b) b)
(else fail)))))
(cond ((null? rest)
(bottom '(too few arguments)))
(else (neq? (fold-left comp first rest)
fail)))))))
Example:
((predicate-iterator eq?) 'foo 'foo 'foo) => #t
See also:
<,
=,
char<?,
char=?,
string<?,
string=?.
| <<[pred] | [Index] | [product]>> |