[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
version difference
From: |
matt |
Subject: |
version difference |
Date: |
Tue, 14 Aug 2007 23:23:33 +0200 (MEST) |
Hello,
I'm having some version difficulties with read-line and list-ref. (The
problems appeared when switching from 1.6.7 to 1.8.2).
I have a script which reads some data from a text file into a list, and
then populates some variables with that data.
The text file looks like this:
cat par.txt
10
13.1708130701843
18.3615121206645
29.5879195536459
5.41594228367692
18.1629768370565
2.67456811999717
3.06183233424074
2.67554033575883
2.59114410363339
2.67244619822827
and the script follows:
(begin
(define rad1 0)
(define rad2 0)
(define rad3 0)
(define rad4 0)
(define rad5 0)
(define el1 0)
(define el2 0)
(define el3 0)
(define el4 0)
(define el5 0)
(define (read-lines file)
(let ((ls '()))
(with-input-from-file file
(lambda ()
(do ((line (read-line) (read-line)))
((eof-object? line))
(set! ls (cons line ls)))
(reverse ls)))))
(define parameterfilename "par.txt")
(define parlines (read-lines parameterfilename))
(use-modules (srfi srfi-13))
(define rad1 (string->number (string-trim-both (list-ref parlines 1))))
(define rad2 (string->number (string-trim-both (list-ref parlines 2))))
(define rad3 (string->number (string-trim-both (list-ref parlines 3))))
(define rad4 (string->number (string-trim-both (list-ref parlines 4))))
(define rad5 (string->number (string-trim-both (list-ref parlines 5))))
(define el1 (string->number (string-trim-both (list-ref parlines 6))))
(define el2 (string->number (string-trim-both (list-ref parlines 7))))
(define el3 (string->number (string-trim-both (list-ref parlines 8))))
(define el4 (string->number (string-trim-both (list-ref parlines 9))))
(define el5 (string->number (string-trim-both (list-ref parlines 10))))
(display rad1)
(display "\n")
(display el4)
(display "\n")
)
(exit)
At one point, I was getting an error that read-line wasn't defined. I'm
not sure why, but now I'm no longer getting those errors, but instead
getting the following:
ERROR: In procedure list-ref:
ERROR: Argument 2 out of range: 1
The read-lines snippet is from the online PLEAC cookbook, which
is supposed to be for Guile-1.8.
I found a several old posts about a previous breakage of read-line, but
that was back in Guile 1.3. I'm pretty confused about the difference
between readline and read-line, and the manual didn't help clarify that.
Any tips?
Thanks!
Matt
- version difference,
matt <=