my first Goo program

"Paul Dufresne" <[email protected]> Fri, 14 Oct 2005 16:13:01 -0400
Newsgroups gmane.comp.lang.goo.general
Message-ID <[email protected]>
#/
Fortune library, show one line of a file at random
Copyright (C) 2005 Paul Dufresne

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301=20
USA

I can be contacted at [email protected] or
14 rue St-Joseph Est
Qu=E9bec, QC G1K 3A5
Canada
/#

(use goo/random)

(dv filename "/home/paul/mygoo/fortune.txt")

(dm read-file (filename|<str> =3D> <col>)
  (def output-col (vec))
  (def myport (open <file-in-port> filename))
  (until (eof-object? (peek myport))
    (def ligne (gets myport))
    (add! output-col ligne))
  (close myport)
  output-col)

(dm show-fortune (col|<col>)
  (msg out (elt col (random (len col)))))

(dm main ()
  (def mycol (read-file filename))
  (show-fortune mycol))

(main)
#/ End of program /#

I know, it was not big enough to release under LGPL. :-)
First, I wanted to use with-port rather than until(eof-object?... but I
was unable.
Second, how would I generate a C program from it?
I used emacs Goo mode (was installed from the Ubuntu package, nice!) to
evaluate and
test program as I was writing it, and I suppose I am using the virtual
machine under
the hood, that is I guess I am using g2m under the hood.

--=20
http://www.fastmail.fm - One of many happy users:=0D
  http://www.fastmail.fm/docs/quotes.html


_______________________________________________
Googoogaga mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/googoogaga