Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (format namein nameout . str)
- (define in (open-input-file namein))
- (define out (open-output-file nameout #:exists 'replace))
- (define (iter)
- (define n (read-line in ))
- (if (equal? n eof) (close-output-port out) (help (string-split n) )))
- (define (help lst)
- (if (empty? lst) (iter)
- (let ((s (string->list (car lst))))
- (cond ( (equal? #\% (car s)) (display (list-ref str (-(char->integer(cadr s)) 48)) out) (display " " out) (help (cdr lst)))
- (else (let ((a (reverse s)))
- (if (equal? (car a) #\%) (begin (display (list->string (reverse (cdr a))) out) (display " " out) (help (cdr lst)))
- (begin (display (car lst) out) (display " " out) (help (cdr lst))))))))))
- (iter))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement