| Deutsch English Français Italiano |
|
<v6mbui$1vpsc$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <NoSpam_762@not_there.org>
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Wed, 10 Jul 2024 16:13:08 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <v6mbui$1vpsc$1@dont-email.me>
References: <87a5q7gzm1.fsf@axel-reichert.de> <XPVFq67p4V6ivNUR3@bongo-ra.co> <m2y1dqrxt7.fsf@MacBook-Pro-2.home>
Injection-Date: Wed, 10 Jul 2024 18:13:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6f6282e3be4159d4eef0e2cf40c4caf3";
logging-data="2090892"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A7nWKc7fAJaRzIIa5ZEzS"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:pyQ65iv+ktHRj64WI96L4hPa5cY=
Bytes: 1668
Raymond Wiker wrote:
> For people who don't like extended loop, I think this a better
> implementation:
>
> (defun read-numbers-from-file/2 (file-path n)
> (with-open-file (f file-path :direction :input)
> (let ((res nil))
> (dotimes (i n)
> (push (parse-integer (read-line f nil)) res))
> (nreverse res))))
Gauche Scheme
(with-input-from-file "output.dat"
(lambda res
(until (read) eof-object? => x
(push! res x))
(reverse res)))
===>
(4 3 2 1 3 4 2 1 4 2 3 1 2 4 3 1 3 2 4 1 2 3 4 1 4 3 1 2
3 4 1 2 4 1 3 2 1 4 3 2 3 1 4 2 1 3 4 2 4 2 1 3 2 4 1 3
4 1 2 3 1 4 2 3 2 1 4 3 1 2 4 3 3 2 1 4 2 3 1 4 3 1 2 4
1 3 2 4 2 1 3 4 1 2 3 4)