[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Unit ports documentation needs an example or two for non
From: |
Matt Welland |
Subject: |
[Chicken-users] Unit ports documentation needs an example or two for non-gods |
Date: |
Wed, 23 May 2012 06:35:11 -0700 |
(port-map FN THUNK)
where does the port go?
I was sort of hoping for something like this to work:
csi> (define inp (open-input-file "~/.bashrc"))
csi> (define a (port-map inp read-line))
csi> (close-input-file inp)
but it took guessing to figure out the intended usage. How about some trivial examples in the docs?
By trial and error I figured this out:
(define a (with-input-from-file "~/.bashrc" (lambda ()(port-map (lambda (x) x) read-line))))
That is ugly. I just want to get a file into a list:
E.g. in Ruby: foo=`cat ~/.bashrc`
port-fold doesn't improve it:
(define b (with-input-from-file "~/.bashrc" (lambda ()(reverse (port-fold cons '() read-line)))))
Is there an egg or unit for down-n-dirty, get-the-job-done-yesterday, screw the "right thing" programming?
(use ducttape)
(define a (file->list "~/.bashrc"))
....
Such a unit or egg deserves mention on the front page. I dug though the docs and never did find an easy way to do what I want.
- [Chicken-users] Unit ports documentation needs an example or two for non-gods,
Matt Welland <=