Array constructor in Guile?

Liste des GroupesRevenir à cl lisp 
Sujet : Array constructor in Guile?
De : mail (at) *nospam* axel-reichert.de (Axel Reichert)
Groupes : comp.lang.scheme comp.lang.lisp
Date : 18. Apr 2024, 08:02:29
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <87le5bp5sa.fsf@axel-reichert.de>
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
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

Date Sujet#  Auteur
18 Apr 24 * Array constructor in Guile?4Axel Reichert
18 Apr 24 +* Re: Array constructor in Guile?2Lawrence D'Oliveiro
18 Apr 24 i`- Re: Array constructor in Guile?1Axel Reichert
19 Apr 24 `- Re: Array constructor in Guile?1Stefan Monnier

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal