Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

It's documented in The Book, somewhere... -- Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


devel / comp.lang.lisp / Re: Reading data into list from "include" file

SubjectAuthor
* Reading data into list from "include" fileAxel Reichert
+- Re: Reading data into list from "include" fileRaymond Wiker
+* Re: Reading data into list from "include" fileJulieta Shem
|+* Re: Reading data into list from "include" fileMadhu
||`- Re: Reading data into list from "include" fileAxel Reichert
|`- Re: Reading data into list from "include" fileAxel Reichert
`* Re: Reading data into list from "include" fileSpiros Bousbouras
 +* Re: Reading data into list from "include" fileRaymond Wiker
 |`- Re: Reading data into list from "include" fileAxel Reichert
 `- Re: Reading data into list from "include" fileAxel Reichert

1
Reading data into list from "include" file

<87a5q7gzm1.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17573&group=comp.lang.lisp#17573

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Reading data into list from "include" file
Date: Mon, 18 Dec 2023 19:00:22 +0100
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <87a5q7gzm1.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="83e0ed23d54c595117e35c41f735334a";
logging-data="3804834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fS77tCdmYt9QP0BeXd9DrtT4cYBKbv6k="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:21Z7lxoZ9lTK1EsmgAol327PGCU=
sha1:ihZTl2/zIw/TDOv7RaGXUdgAXzU=
 by: Axel Reichert - Mon, 18 Dec 2023 18:00 UTC

Hello,

I have an ASCII file that gets written by some other (non-lispy) process
and contains (a known number of) integers, one per line, e.g. like this:

8
7 7
5

Now I want to read these numbers into a list, so that instead of
hard-coding the numbers like

(let ((my-list (list 8 7 7 5)))
(do-something-with-the-list))

I can have something like

(let ((my-list (unknown-code-to-read-from-an-include-file)))
(do-something-with-the-list))

Unfortunately, I have no elegant solution how
"unknown-code-to-read-from-an-include-file" should look (in Common Lisp
or Emacs Lisp). The best I could come up with is

(require 'f) ; An Emacs library for file handling
(let ((my-list (mapcar #'string-to-number
(split-string (f-read "ascii-file.el")))))
(do-something-with-the-list))

"f-read" returns a string, so I need to convert into a list of strings
and then into a list of numbers. Works, but looks clumsy.

A simple "load-file" will not do, since it just returns T (for successful
reading), not the three integer numbers read, so "my-list" is no list,
but the truthiness value.

Any ideas?

Best regards

Axel

Re: Reading data into list from "include" file

<m234vztlqv.fsf@MacBook-Pro-2.home>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17574&group=comp.lang.lisp#17574

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rwiker@gmail.com (Raymond Wiker)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Mon, 18 Dec 2023 19:21:28 +0100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <m234vztlqv.fsf@MacBook-Pro-2.home>
References: <87a5q7gzm1.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2ff7c8e2f73c89af3a4fccb5b326b7d3";
logging-data="3809616"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oAcrbOi2FHLDbXwf8xoTh"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:yxFxZlc57BDTgoiUT/5Y/JwB5kg=
sha1:VJ8NCxk4ftGc6DqIaVLRUvqMLQ0=
 by: Raymond Wiker - Mon, 18 Dec 2023 18:21 UTC

Axel Reichert <mail@axel-reichert.de> writes:

> Hello,
>
> I have an ASCII file that gets written by some other (non-lispy) process
> and contains (a known number of) integers, one per line, e.g. like this:
>
> 8
> 7
> 7
> 5
>
> Now I want to read these numbers into a list, so that instead of
> hard-coding the numbers like
>
> (let ((my-list (list 8 7 7 5)))
> (do-something-with-the-list))
>
> I can have something like
>
> (let ((my-list (unknown-code-to-read-from-an-include-file)))
> (do-something-with-the-list))
>
> Unfortunately, I have no elegant solution how
> "unknown-code-to-read-from-an-include-file" should look (in Common Lisp
> or Emacs Lisp). The best I could come up with is
>
> (require 'f) ; An Emacs library for file handling
> (let ((my-list (mapcar #'string-to-number
> (split-string (f-read "ascii-file.el")))))
> (do-something-with-the-list))
>
> "f-read" returns a string, so I need to convert into a list of strings
> and then into a list of numbers. Works, but looks clumsy.
>
> A simple "load-file" will not do, since it just returns T (for successful
> reading), not the three integer numbers read, so "my-list" is no list,
> but the truthiness value.
>
> Any ideas?
>
> Best regards
>
> Axel

Something like this, perhaps?

(defun read-numbers-from-file (file-path)
(with-open-file (f file-path :direction :input)
(loop for line = (read-line f nil)
while line
collect (parse-integer line))))

Re: Reading data into list from "include" file

<87jzpb74lq.fsf@yaxenu.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17575&group=comp.lang.lisp#17575

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.niel.me!news.gegeweb.eu!gegeweb.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jshem@yaxenu.org (Julieta Shem)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Mon, 18 Dec 2023 15:22:41 -0300
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <87jzpb74lq.fsf@yaxenu.org>
References: <87a5q7gzm1.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="98629becbc8d899dfff76416f80caea1";
logging-data="3809756"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SsmCNxYvdNfieQhgEI85bJqOSfgIMB1g="
Cancel-Lock: sha1:PzE7a9gunJTS6Y/5dozLfcCIofY=
sha1:ntC2sUOE7oQ50rI9M3veYOncimI=
 by: Julieta Shem - Mon, 18 Dec 2023 18:22 UTC

Axel Reichert <mail@axel-reichert.de> writes:

> Hello,
>
> I have an ASCII file that gets written by some other (non-lispy) process
> and contains (a known number of) integers, one per line, e.g. like this:
>
> 8
> 7
> 7
> 5
>
> Now I want to read these numbers into a list, so that instead of
> hard-coding the numbers like
>
> (let ((my-list (list 8 7 7 5)))
> (do-something-with-the-list))
>
> I can have something like
>
> (let ((my-list (unknown-code-to-read-from-an-include-file)))
> (do-something-with-the-list))
>
> Unfortunately, I have no elegant solution how
> "unknown-code-to-read-from-an-include-file" should look (in Common Lisp
> or Emacs Lisp). The best I could come up with is
>
> (require 'f) ; An Emacs library for file handling
> (let ((my-list (mapcar #'string-to-number
> (split-string (f-read "ascii-file.el")))))
> (do-something-with-the-list))
>
> "f-read" returns a string, so I need to convert into a list of strings
> and then into a list of numbers. Works, but looks clumsy.
>
> A simple "load-file" will not do, since it just returns T (for successful
> reading), not the three integer numbers read, so "my-list" is no list,
> but the truthiness value.
>
> Any ideas?

The task seems straightforward and it looks you solved it. It will look
a lot better if you abstract your strategy away in a procedure. So your
code will look like

(do-something-with (file->list-of-numbers "ascii.file.txt")).

I don't much ELISP, but we might not be too far off with

(defun file->list-of-numbers (fname)
(mapcar #'string-to-number
(split-string (f-read fname))))

Re: Reading data into list from "include" file

<XPVFq67p4V6ivNUR3@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17576&group=comp.lang.lisp#17576

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Tue, 19 Dec 2023 11:07:26 -0000 (UTC)
Organization: To protect and to server
Message-ID: <XPVFq67p4V6ivNUR3@bongo-ra.co>
References: <87a5q7gzm1.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Dec 2023 11:07:26 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="570739"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:5iqBRV5BJkh47lVwdOFOUsat7fJJHVddmtYuwBdu7Q4=
X-Notice: Filtered by postfilter v. 0.9.3
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Tue, 19 Dec 2023 11:07 UTC

On Mon, 18 Dec 2023 19:00:22 +0100
Axel Reichert <mail@axel-reichert.de> wrote:
> Hello,
>
> I have an ASCII file that gets written by some other (non-lispy) process
> and contains (a known number of) integers, one per line, e.g. like this:
>
> 8
> 7
> 7
> 5
>
> Now I want to read these numbers into a list, so that instead of
> hard-coding the numbers like
>
> (let ((my-list (list 8 7 7 5)))
> (do-something-with-the-list))
>
> I can have something like
>
> (let ((my-list (unknown-code-to-read-from-an-include-file)))
> (do-something-with-the-list))

[...]

> A simple "load-file" will not do, since it just returns T (for successful
> reading), not the three integer numbers read, so "my-list" is no list,
> but the truthiness value.

Actually LOAD returns T for successful *evaluation* .In your example , it
read and evaluated each of the forms 8 , 7 , 7 , 5 .Each of those evaluates
to itself [i.e. the respective number] so obviously the evaluation was
successful.

I will give a modified version of the code in
<m234vztlqv.fsf@MacBook-Pro-2.home> because I don't like LOOP .

(defun read-numbers-from-file
(file-path non ; non = number of numbers
&aux (vec (make-array non)))
(with-open-file (f file-path :direction :input)
(dotimes (i non (map 'list (function identity) vec))
(let ((num (read f nil)))
(unless num (error "Wrong number of numbers in the file"))
(setf (aref vec i) num)))))

If you decide that you'd rather have the numbers in a vector rather than
in a list , it's trivial to modify the above code to get that.

--
What is deadly is a language community that is /not/ delighted with its
language and itself.
Kenny Tilton
groups.google.com/d/msg/comp.lang.lisp/Ege9MyXRvH4/Y5mpGo4BKQkJ

Re: Reading data into list from "include" file

<m2y1dqrxt7.fsf@MacBook-Pro-2.home>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17578&group=comp.lang.lisp#17578

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rwiker@gmail.com (Raymond Wiker)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Tue, 19 Dec 2023 16:56:04 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <m2y1dqrxt7.fsf@MacBook-Pro-2.home>
References: <87a5q7gzm1.fsf@axel-reichert.de> <XPVFq67p4V6ivNUR3@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="a043fd6655836f8ba611c55416dd9d0f";
logging-data="126265"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sQWfLlQmRIdR1VBmdPHjm"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:eV0cFxZH2MtAZZQ/O17WINtP3/Y=
sha1:NAkcfE0KyaGaPRi0GIb8FL0t9UE=
 by: Raymond Wiker - Tue, 19 Dec 2023 15:56 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> On Mon, 18 Dec 2023 19:00:22 +0100
> Axel Reichert <mail@axel-reichert.de> wrote:
>> Hello,
>>
>> I have an ASCII file that gets written by some other (non-lispy) process
>> and contains (a known number of) integers, one per line, e.g. like this:
>>
>> 8
>> 7
>> 7
>> 5
>>
>> Now I want to read these numbers into a list, so that instead of
>> hard-coding the numbers like
>>
>> (let ((my-list (list 8 7 7 5)))
>> (do-something-with-the-list))
>>
>> I can have something like
>>
>> (let ((my-list (unknown-code-to-read-from-an-include-file)))
>> (do-something-with-the-list))
>
> [...]
>
>> A simple "load-file" will not do, since it just returns T (for successful
>> reading), not the three integer numbers read, so "my-list" is no list,
>> but the truthiness value.
>
> Actually LOAD returns T for successful *evaluation* .In your example , it
> read and evaluated each of the forms 8 , 7 , 7 , 5 .Each of those evaluates
> to itself [i.e. the respective number] so obviously the evaluation was
> successful.
>
> I will give a modified version of the code in
> <m234vztlqv.fsf@MacBook-Pro-2.home> because I don't like LOOP .
>
> (defun read-numbers-from-file
> (file-path non ; non = number of numbers
> &aux (vec (make-array non)))
> (with-open-file (f file-path :direction :input)
> (dotimes (i non (map 'list (function identity) vec))
> (let ((num (read f nil)))
> (unless num (error "Wrong number of numbers in the file"))
> (setf (aref vec i) num)))))
>
> If you decide that you'd rather have the numbers in a vector rather than
> in a list , it's trivial to modify the above code to get that.

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))))

Re: Reading data into list from "include" file

<m3h6kd143g.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17579&group=comp.lang.lisp#17579

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Wed, 20 Dec 2023 17:24:43 +0530
Organization: Motzarella
Lines: 56
Message-ID: <m3h6kd143g.fsf@leonis4.robolove.meer.net>
References: <87a5q7gzm1.fsf@axel-reichert.de> <87jzpb74lq.fsf@yaxenu.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1552eb9e3ccf790f7049f7bc2b726d48";
logging-data="581760"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Dp8EIMMy1F4RZAiVmbIpV6U7EqN6Rli0="
Cancel-Lock: sha1:AePUQ+IUCDBrZjICDhl1DpKwKS4=
sha1:2ImWUSdHsbj/gbpbiLmu7+qPSb8=
 by: Madhu - Wed, 20 Dec 2023 11:54 UTC

* Julieta Shem <87jzpb74lq.fsf@ yaxenu.org> :
Wrote on Mon, 18 Dec 2023 15:22:41 -0300:
> Axel Reichert <mail @axel-reichert.de> writes:
>> I have an ASCII file that gets written by some other (non-lispy) process
>> and contains (a known number of) integers, one per line, e.g. like this:
>>
>> 8
>> 7
>> 7
>> 5
>>
>> Now I want to read these numbers into a list, so that instead of
>> hard-coding the numbers like
>>
>> (let ((my-list (list 8 7 7 5)))
>> (do-something-with-the-list))
>>
<snip>
>> (require 'f) ; An Emacs library for file handling
>> (let ((my-list (mapcar #'string-to-number
>> (split-string (f-read "ascii-file.el")))))
>> (do-something-with-the-list))
>>
>> "f-read" returns a string, so I need to convert into a list of strings
>> and then into a list of numbers. Works, but looks clumsy.
>>
>> A simple "load-file" will not do, since it just returns T (for successful
>> reading), not the three integer numbers read, so "my-list" is no list,
>> but the truthiness value.
>>
>> Any ideas?
>
> The task seems straightforward and it looks you solved it. It will look
> a lot better if you abstract your strategy away in a procedure. So your
> code will look like
>
> (do-something-with (file->list-of-numbers "ascii.file.txt")).
>
> I don't much ELISP, but we might not be too far off with
>
> (defun file->list-of-numbers (fname)
> (mapcar #'string-to-number
> (split-string (f-read fname))))

In elisp, for the specific case where Axel controls the file being read
it may be as simple to leverage the lisp reader.

(car (read-from-string (concat "(" (f-read "file.txt") ")")))

(with-temp-buffer
(insert "(")
(insert-file-contents "/dev/shm/barf")
(goto-char (point-max))
(insert ")")
(goto-char (point-min))
(read (current-buffer)))

Re: Reading data into list from "include" file

<87il4rfjwu.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17584&group=comp.lang.lisp#17584

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Thu, 21 Dec 2023 20:13:53 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <87il4rfjwu.fsf@axel-reichert.de>
References: <87a5q7gzm1.fsf@axel-reichert.de> <87jzpb74lq.fsf@yaxenu.org>
<m3h6kd143g.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="da0c06f03f0742f6f0aec191d072b13b";
logging-data="1256383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lVF3tknrVyOBrElqfV8ESGEc1mg9aew0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:zKZKGwW1pRl3wy1ASmmACPdPCsU=
sha1:EzdcA6F3cEzOCc6W8zewZvY1g0g=
 by: Axel Reichert - Thu, 21 Dec 2023 19:13 UTC

Madhu <enometh@meer.net> writes:

> (car (read-from-string (concat "(" (f-read "file.txt") ")")))

Nice, thanks! I had found "read-from-string", but could not come up with
the idea to create a Lisp expression.

Best regards

Axel

Re: Reading data into list from "include" file

<87edfffjuy.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17585&group=comp.lang.lisp#17585

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Thu, 21 Dec 2023 20:15:01 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <87edfffjuy.fsf@axel-reichert.de>
References: <87a5q7gzm1.fsf@axel-reichert.de> <87jzpb74lq.fsf@yaxenu.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="da0c06f03f0742f6f0aec191d072b13b";
logging-data="1256383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vyauFWM7PPDpWvSHZgMlBikMmbswCywE="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:8Iee9b3lRa0rY8zi5MOLx2powHg=
sha1:s5NrbQB43TEdyJwF6CrQ6+UA7Hk=
 by: Axel Reichert - Thu, 21 Dec 2023 19:15 UTC

Julieta Shem <jshem@yaxenu.org> writes:

> The task seems straightforward and it looks you solved it. It will look
> a lot better if you abstract your strategy away in a procedure. So your
> code will look like
>
> (do-something-with (file->list-of-numbers "ascii.file.txt")).

Yes, sure, that is better. Thanks!

Axel

Re: Reading data into list from "include" file

<87a5q3fjjt.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17586&group=comp.lang.lisp#17586

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Thu, 21 Dec 2023 20:21:42 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <87a5q3fjjt.fsf@axel-reichert.de>
References: <87a5q7gzm1.fsf@axel-reichert.de> <XPVFq67p4V6ivNUR3@bongo-ra.co>
<m2y1dqrxt7.fsf@MacBook-Pro-2.home>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="da0c06f03f0742f6f0aec191d072b13b";
logging-data="1256383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aJwboJjFR6AlXn644rOWfR7S4iOpmWQ8="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:2bwba33FNY8zhtx749U8GrClWoU=
sha1:uYHNTyoeH6Ov88tmR9fxgjr8Nrc=
 by: Axel Reichert - Thu, 21 Dec 2023 19:21 UTC

Raymond Wiker <rwiker@gmail.com> writes:

> For people who don't like extended loop,

.... count me in.

> (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))))

Yes, that will be the Common Lisp version. Thanks to you, too!

Axel

Re: Reading data into list from "include" file

<875y0rfjfs.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17587&group=comp.lang.lisp#17587

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.lisp
Subject: Re: Reading data into list from "include" file
Date: Thu, 21 Dec 2023 20:24:07 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <875y0rfjfs.fsf@axel-reichert.de>
References: <87a5q7gzm1.fsf@axel-reichert.de> <XPVFq67p4V6ivNUR3@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="da0c06f03f0742f6f0aec191d072b13b";
logging-data="1256383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18h/CjyMQA813/vrDEd0ZDc7bcaNZbS0mU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:rty+sxXUyr4u/vMnucicUzcKKEQ=
sha1:KciaJ5N5gffs8tFBld8z2ByiGIA=
 by: Axel Reichert - Thu, 21 Dec 2023 19:24 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

>> A simple "load-file" will not do, since it just returns T (for successful
>> reading), not the three integer numbers read, so "my-list" is no list,
>> but the truthiness value.
>
> Actually LOAD returns T for successful *evaluation* .In your example , it
> read and evaluated each of the forms 8 , 7 , 7 , 5 .Each of those evaluates
> to itself [i.e. the respective number] so obviously the evaluation was
> successful.

Yes, sure, my formulation was too short for still being precise. I meant
to state it like you did above. Thanks for the clarification.

Best regards

Axel

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor