Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Power corrupts. And atomic power corrupts atomically.


devel / comp.lang.lisp / Re: Array constructor in Guile?

SubjectAuthor
* Array constructor in Guile?Axel Reichert
+* Re: Array constructor in Guile?Lawrence D'Oliveiro
|`- Re: Array constructor in Guile?Axel Reichert
`- Re: Array constructor in Guile?Stefan Monnier

1
Array constructor in Guile?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.scheme,comp.lang.lisp
Subject: Array constructor in Guile?
Date: Thu, 18 Apr 2024 08:02:29 +0200
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <87le5bp5sa.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Thu, 18 Apr 2024 08:02:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="652f99b4ec3bddeb3705b3b8ccbd6df6";
logging-data="2229437"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vLyIFNZEMBp0wmZ4N27pO80+JXB8gfpo="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:a3ujZUG4D6A9XJYH0iEMQrcOl8o=
sha1:ILG8qqzVNFD+OPyJ3lfcrTPYDAs=
 by: Axel Reichert - Thu, 18 Apr 2024 06:02 UTC

Hello,

Guile has a literal syntax for vectors

#(1 2 3)

so that

(vector-ref #(1 (+ 2 3) 4) 1)

returns

(+ 2 3)

but also a "constructor"

(vector 1 (+ 2 3) 4)

so that

(vector-ref (vector 1 (+ 2 3) 4) 1)

returns

5

There is a literal syntax for arrays, too,

#2((2 1) (5 6))

so that

(array-ref #2((2 1) (5 6)) 1 1)

returns

6

But I did not find an array "constructor" syntax that allows me to
create an array such as

#2((2 1) ((+ 2 3) 6))

resulting in

#2((2 1) (5 6))

as above. How can I then create a "calculated" array, apart from filling
an array with 0 first

(define m (make-array 0 2 2))

and then changing every element with

(array-set! m 2 0 0)
(array-set! m 1 0 1)
(array-set! m (+ 2 3) 1 0)
(array-set! m 6 1 1)

?

Common Lisp's hyperspec show

(make-array '(4 2 3) :initial-contents
'(((a b c) (1 2 3))
((d e f) (3 1 2))
((g h i) (2 3 1))
((j k l) (0 0 0))))

as an example.

Pointers appreciated!

Axel

Re: Array constructor in Guile?

<uvqico$24ql9$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.scheme,comp.lang.lisp
Subject: Re: Array constructor in Guile?
Date: Thu, 18 Apr 2024 07:33:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <uvqico$24ql9$1@dont-email.me>
References: <87le5bp5sa.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 18 Apr 2024 09:33:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e0bbc97582f840a25b6ae44a96748375";
logging-data="2255529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LrotPZCX0UMqrf6Ly5UqW"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:4FIUEOoCTPYblBW8cDD+CGa6pFk=
 by: Lawrence D'Oliv - Thu, 18 Apr 2024 07:33 UTC

On Thu, 18 Apr 2024 08:02:29 +0200, Axel Reichert wrote:

> But I did not find an array "constructor" syntax that allows me to
> create an array such as
>
> #2((2 1) ((+ 2 3) 6))
>
> resulting in
>
> #2((2 1) (5 6))

(list->array 2 `((2 1) (,(+ 2 3) 6)))

Re: Array constructor in Guile?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme comp.lang.lisp
Followup: comp.lang.scheme
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.scheme,comp.lang.lisp
Subject: Re: Array constructor in Guile?
Followup-To: comp.lang.scheme
Date: Thu, 18 Apr 2024 19:51:16 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <87h6fypnjf.fsf@axel-reichert.de>
References: <87le5bp5sa.fsf@axel-reichert.de> <uvqico$24ql9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Thu, 18 Apr 2024 19:51:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="652f99b4ec3bddeb3705b3b8ccbd6df6";
logging-data="2512935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1868ju+ps3ftoX5eCPbq2xUlE/XPyEsoq0="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:UBujyBt/CDokiN2TWmfaBrGYnl4=
sha1:oIJ8tBYbsuq3Jhopr5mkG7QAQFI=
 by: Axel Reichert - Thu, 18 Apr 2024 17:51 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:

> On Thu, 18 Apr 2024 08:02:29 +0200, Axel Reichert wrote:
>
>> But I did not find an array "constructor" syntax that allows me to
>> create an array such as
>>
>> #2((2 1) ((+ 2 3) 6))
>>
>> resulting in
>>
>> #2((2 1) (5 6))
>
> (list->array 2 `((2 1) (,(+ 2 3) 6)))

Great, thanks, did not see this idea.

Best regards

Axel

Re: Array constructor in Guile?

<jwva5lpxjh8.fsf-monnier+comp.lang.lisp@gnu.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.scheme comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: monn...@iro.umontreal.ca (Stefan Monnier)
Newsgroups: comp.lang.scheme,comp.lang.lisp
Subject: Re: Array constructor in Guile?
Date: Fri, 19 Apr 2024 15:08:04 -0400
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <jwva5lpxjh8.fsf-monnier+comp.lang.lisp@gnu.org>
References: <87le5bp5sa.fsf@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 19 Apr 2024 21:10:58 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d09361576182a34797557b6671965805";
logging-data="3324827"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Tzje/V7CPqVJSYDqPmXjhwaYa9Nez8+0="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:38unFM4REkQ0fBZIz/1NhciVDqQ=
sha1:+2x1dAomGDNrm0dSLxMWuR6d4r4=
 by: Stefan Monnier - Fri, 19 Apr 2024 19:08 UTC

> #2((2 1) ((+ 2 3) 6))

Hmm... I see they implemented quasiquotation for vectors but not
for arrays:

scheme@(guile-user)> `#(1 2 ,(+ 3 4))
$1 = #(1 2 7)
scheme@(guile-user)> `#2((1 2) (,(+ 3 4) 5))
$2 = #2((1 2) ((unquote (+ 3 4)) 5))
scheme@(guile-user)>

I suggest you file a feature request for that.

Stefan

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor