guile-user
[Top][All Lists]
Advanced

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

Re: Playing with guile (vs python). Generate file for GDP suitable for g


From: Ludovic Courtès
Subject: Re: Playing with guile (vs python). Generate file for GDP suitable for gnuplot.
Date: Sat, 11 Feb 2017 15:12:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hello!

Sorry for the late reply.

Germán Diago <address@hidden> skribis:

> (define (file->lines filename)
>   "Returns a list of lines contained in a file"
>   (call-with-input-file
>       filename
>     (lambda (p)
>       (let loop ([line (read-line p)])
>         (if (eof-object? line) (list)
>             (cons
>              (substring line 0 (1- (string-length line)))
>              (loop (read-line p))))))))

UTF-8 I/O is usually faster in Guile 2.0.  You might want to make sure
your file is opened as UTF-8:

  (with-fluids ((%default-port-encoding "UTF-8"))
    (call-with-input-file file …))

Ludo’.




reply via email to

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