chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Unit ports documentation needs an example or two for


From: Daniel Leslie
Subject: Re: [Chicken-users] Unit ports documentation needs an example or two for non-gods
Date: Wed, 23 May 2012 07:29:07 -0700

I'm personally not aware of any eggs that specifically match your request. 
But there are these eggs, which I tend to use more often than others:

Misc Macros
More Macros
lookup-table
Sequences
SRFI-99

Less general, but still often useful:
SRFI-45
lazy-seq

-Dan

On Wed, May 23, 2012 at 6:35 AM, Matt Welland <address@hidden> wrote:
 (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 mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]