home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-05 | 695 b | 32 lines | [TEXT/Help] |
- {A multiple value implementation relying on conses Beurk…}
-
-
-
-
- (define (mret | l) l)
-
- (define (retfrom v | l)
- (retfrom2 v l))
-
- (define (retfrom2 v l)
- (cond (null? l) ()
- (cons ((0 l) (0 v))(retfrom2 (-1 v) (-1 l)))))
-
- {
- (define (count a b l nca ncb)
- (cond (null? l) (cons nca ncb)
- (eq? a (0 l)) (count a b (-1 l) (1+ nca) ncb)
- (eq? b (0 l)) (count a b (-1 l) nca (1+ ncb))
- (count a b (-1 l) nca ncb)))
-
- (define (count2 a b l)
- (cond (null? l) (mret 0 0)
- (eq? a (0 l)) (retfrom (count2 a b (-1 l)) 1+ I)
- (eq? b (0 l)) (retfrom (count2 a b (-1 l)) I 1+)
- (count2 a b (-1 l))))
-
-
- (count2 'a 'b '(a a b b a a b b d d a b) )
-
- }
-