codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
; weather forecast (define (tempname) (let loop ((i 0)) (let ((f (string-append "temp" (number->string i)))) (if (file-exists? f) (loop (+ i 1)) f)))) (define (with-input-from-url url thunk) (let ((f (tempname))) (if (zero? (system (string-append wget " " f " " url))) (begin (with-input-from-file f thunk) (delete-file f #t)) (error 'with-input-from-url "system error in wget")))) (define wget "c:\\cygwin\\bin\\wget -qO") ; windows/cygwin ;(define wget "/usr/local/bin/wget -qO") ; unix/hp ;(define wget "/usr/bin/wget -q0") ; linux/ubuntu (define (weather-url state city) (string-append "http://weather.noaa.gov/pub/data/forecasts/city/" state "/" city ".txt")) (define (display-weather state city) (with-input-from-url (weather-url state city) (lambda () (do ((c (read-char) (read-char))) ((eof-object? c)) (display c))))) (display-weather "mo" "st_louis")
Private
[
?
]
Run code
Submit