[Chicken-users] Unit ports documentation needs an example or two for non-gods

2012-05-23 Thread Matt Welland
 (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
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


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

2012-05-23 Thread Daniel Leslie
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 http://wiki.call-cc.org/eggref/4/miscmacros
More Macros http://wiki.call-cc.org/eggref/4/moremacros
lookup-table http://wiki.call-cc.org/eggref/4/lookup-table
Sequences http://wiki.call-cc.org/eggref/4/sequences
SRFI-99 http://wiki.call-cc.org/eggref/4/srfi-99

Less general, but still often useful:
SRFI-45 http://wiki.call-cc.org/eggref/4/srfi-45
lazy-seq http://wiki.call-cc.org/eggref/4/lazy-seq

-Dan

On Wed, May 23, 2012 at 6:35 AM, Matt Welland estifo...@gmail.com 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
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


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

2012-05-23 Thread Kevin Wortman
You can do that with

(call-with-input-file PATH read-lines)

or

(read-lines my-file.txt)

The latter comes from this page
http://wiki.call-cc.org/chicken-for-python-programmers
which documents a few down-and-dirty idioms.

Kevin

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


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

2012-05-23 Thread Matt Welland
Thanks Kevin and Daniel, great hints. Much appreciated.

On Wed, May 23, 2012 at 7:48 AM, Kevin Wortman kwort...@gmail.com wrote:

 You can do that with

 (call-with-input-file PATH read-lines)

 or

 (read-lines my-file.txt)

 The latter comes from this page
 http://wiki.call-cc.org/chicken-for-python-programmers
 which documents a few down-and-dirty idioms.

 Kevin

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users