source: project/release/4/combinators/trunk/logical-combinators.scm @ 21916

Last change on this file since 21916 was 18918, checked in by Kon Lovett, 11 years ago

More sections

File size: 636 bytes
Line 
1;;;; logical-combinators.scm
2;;;; Kon Lovett, Mar '09
3
4(module logical-combinators
5
6  (;export
7    andf
8    orf)
9
10  (import scheme chicken data-structures srfi-1)
11
12  (declare
13    (type
14      (andf (procedure (#!rest) *))
15      (orf (procedure (#!rest) *)) ) )
16
17;; Eager 'or' & 'and'
18
19(define (andf . args)
20  (let loop ((args args) (prev #t))
21    (if (null? args) prev
22        (let ((cur (car args)))
23          (and cur
24               (loop (cdr args) cur) ) ) ) ) )
25
26(define (orf . args)
27  (let loop ((args args))
28    (and (not (null? args))
29         (or (car args)
30             (loop (cdr args)) ) ) ) )
31
32) ;module logical-combinators
Note: See TracBrowser for help on using the repository browser.