Created
May 12, 2018 15:35
-
-
Save indraniel/d9d8f2a1d2b856b8a0887340f9f594ee to your computer and use it in GitHub Desktop.
An example file reading script with chicken scheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env csi -ss | |
;; An example file reading script with chicken scheme | |
(use extras) | |
(define (read-it file) | |
(let ((fh (open-input-file file))) | |
(let loop((c (read-line fh))) | |
(if (eof-object? c) | |
(close-input-port fh) | |
(begin | |
(print c) | |
(loop (read-line fh))))))) | |
(define (main args) | |
(define file (if (null? args) '() (car args))) | |
(if (null? file) | |
(display "Please supply a file name to read!\n") | |
(read-it file))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another alternative can be: