Changeset 12526 in project


Ignore:
Timestamp:
11/16/08 01:25:14 (12 years ago)
Author:
azul
Message:

Tweaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/stream-ext/trunk/stream-ext.scm

    r12518 r12526  
    9393(define symbol->stream (compose string->stream symbol->string))
    9494
    95 (define (stream->string-safe obj)
    96   (if (stream? obj)
    97     (stream->string obj)
    98     obj))
    99 
    100 (define (string->stream-safe obj)
    101   (if (string? obj)
    102     (string->stream obj)
    103     obj))
    104 
    105 (define (stream-wrap-proc proc)
    106   (lambda args
    107     (receive results
    108              (apply proc (map stream->string-safe args))
    109       (apply values (map string->stream-safe results)))))
     95(define (stream-convert-safe check? convert)
     96  (lambda (obj)
     97    (if (check? obj)
     98      (convert obj)
     99      obj)))
     100
     101(define (stream-wrap-proc-generic convert-inputs convert-outputs)
     102  (lambda (proc)
     103    (lambda args
     104      (receive results
     105               (apply proc (map convert-inputs args))
     106        (apply values (map convert-outputs results))))))
     107
     108(define stream-wrap-proc-string
     109  (stream-wrap-proc-generic
     110    (stream-convert-safe stream? stream->string)
     111    (stream-convert-safe string? string->stream)))
     112
     113(define stream-wrap-proc-list
     114  (stream-wrap-proc-generic
     115    (stream-convert-safe stream? stream->list)
     116    (stream-convert-safe list? list->stream)))
     117
     118(define stream-wrap-proc-stream
     119  (stream-wrap-proc-generic
     120    (lambda (obj)
     121      (cond
     122        ((list? obj) (list->stream obj))
     123        ((string? obj) (string->stream obj))
     124        (else obj)))
     125    identity))
    110126
    111127(define stream-downcase (cut stream-map char-downcase <>))
Note: See TracChangeset for help on using the changeset viewer.