Advertisement
PonaFly

llistofribs(20-n3)

Apr 19th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #lang scheme
  2. (define (listribs)
  3. (define in (open-input-file "peaks.txt"))
  4. (define out (open-output-file "out.txt" #:exists 'replace ))
  5. (define (iter Nstr )
  6. (define line (read-line in))
  7. (if (equal? line eof) (close-output-port out)
  8. (if (= Nstr 0) (iter (+ 1 Nstr))
  9. (help (function (reverse(cdr (string->list line))) '() 0 0 ) Nstr ))))
  10.  
  11. (define (help lst Nstr)
  12. (if (empty? lst) (iter (+ 1 Nstr))
  13. (cond
  14. ( (>= Nstr (car lst)) (display (cons Nstr (car lst)) out) (display #\newline out) (help (cdr lst) Nstr))
  15. (else (help (cdr lst) Nstr)))))
  16. (iter 0))
  17.  
  18. (define (function lst result number degree)
  19. (if (empty? lst) result
  20. (let ((ch (char->integer(car lst))))
  21. (if (and (>= ch 48) (<= ch 57)) (function (cdr lst) result (+ number (*(- ch 48) (expt 10 degree))) (+ degree 1))
  22. (function (cdr lst) (if (= number 0) result (cons number result)) 0 0)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement