156 lines
6.3 KiB
HTML
156 lines
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!-- This manual documents Guile version 3.0.10.
|
|
|
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
|
Inc.
|
|
|
|
Copyright (C) 2021 Maxime Devos
|
|
|
|
Copyright (C) 2024 Tomas Volf
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
|
|
copy of the license is included in the section entitled "GNU Free
|
|
Documentation License." -->
|
|
<title>Array Syntax (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="Array Syntax (Guile Reference Manual)">
|
|
<meta name="keywords" content="Array Syntax (Guile Reference Manual)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content=".texi2any-real">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
<link href="index.html" rel="start" title="Top">
|
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Arrays.html" rel="up" title="Arrays">
|
|
<link href="Array-Procedures.html" rel="next" title="Array Procedures">
|
|
<style type="text/css">
|
|
<!--
|
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|
div.example {margin-left: 3.2em}
|
|
span:hover a.copiable-link {visibility: visible}
|
|
-->
|
|
</style>
|
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<div class="subsubsection-level-extent" id="Array-Syntax">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Array-Procedures.html" accesskey="n" rel="next">Array Procedures</a>, Up: <a href="Arrays.html" accesskey="u" rel="up">Arrays</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<h4 class="subsubsection" id="Array-Syntax-1"><span>6.6.13.1 Array Syntax<a class="copiable-link" href="#Array-Syntax-1"> ¶</a></span></h4>
|
|
|
|
<p>An array is displayed as <code class="code">#</code> followed by its rank, followed by a
|
|
tag that describes the underlying vector, optionally followed by
|
|
information about its shape, and finally followed by the cells,
|
|
organized into dimensions using parentheses.
|
|
</p>
|
|
<p>In more words, the array tag is of the form
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example-preformatted"> #<rank><vectag><@lower><:len><@lower><:len>...
|
|
</pre></div>
|
|
|
|
<p>where <code class="code"><rank></code> is a positive integer in decimal giving the rank of
|
|
the array. It is omitted when the rank is 1 and the array is non-shared
|
|
and has zero-origin (see below). For shared arrays and for a non-zero
|
|
origin, the rank is always printed even when it is 1 to distinguish
|
|
them from ordinary vectors.
|
|
</p>
|
|
<p>The <code class="code"><vectag></code> part is the tag for a uniform numeric vector, like
|
|
<code class="code">u8</code>, <code class="code">s16</code>, etc, <code class="code">b</code> for bitvectors, or <code class="code">a</code> for
|
|
strings. It is empty for ordinary vectors.
|
|
</p>
|
|
<p>The <code class="code"><@lower></code> part is a ‘<samp class="samp">@</samp>’ character followed by a signed
|
|
integer in decimal giving the lower bound of a dimension. There is one
|
|
<code class="code"><@lower></code> for each dimension. When all lower bounds are zero,
|
|
all <code class="code"><@lower></code> parts are omitted.
|
|
</p>
|
|
<p>The <code class="code"><:len></code> part is a ‘<samp class="samp">:</samp>’ character followed by an unsigned
|
|
integer in decimal giving the length of a dimension. Like for the lower
|
|
bounds, there is one <code class="code"><:len></code> for each dimension, and the
|
|
<code class="code"><:len></code> part always follows the <code class="code"><@lower></code> part for a
|
|
dimension. Lengths are only then printed when they can’t be deduced
|
|
from the nested lists of elements of the array literal, which can happen
|
|
when at least one length is zero.
|
|
</p>
|
|
<p>As a special case, an array of rank 0 is printed as
|
|
<code class="code">#0<vectag>(<scalar>)</code>, where <code class="code"><scalar></code> is the result of
|
|
printing the single element of the array.
|
|
</p>
|
|
<p>Thus,
|
|
</p>
|
|
<dl class="table">
|
|
<dt><code class="code">#(1 2 3)</code></dt>
|
|
<dd><p>is an ordinary array of rank 1 with lower bound 0 in dimension 0.
|
|
(I.e., a regular vector.)
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#@2(1 2 3)</code></dt>
|
|
<dd><p>is an ordinary array of rank 1 with lower bound 2 in dimension 0.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#2((1 2 3) (4 5 6))</code></dt>
|
|
<dd><p>is a non-uniform array of rank 2; a 2x3 matrix with index ranges 0..1
|
|
and 0..2.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#u8(0 1 2)</code></dt>
|
|
<dd><p>is a uniform u8 array of rank 1.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#2u32@2@3((1 2) (2 3))</code></dt>
|
|
<dd><p>is a uniform u32 array of rank 2 with index ranges 2..3 and 3..4.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#2()</code></dt>
|
|
<dd><p>is a two-dimensional array with index ranges 0..-1 and 0..-1, i.e.
|
|
both dimensions have length zero.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#2:0:2()</code></dt>
|
|
<dd><p>is a two-dimensional array with index ranges 0..-1 and 0..1, i.e. the
|
|
first dimension has length zero, but the second has length 2.
|
|
</p>
|
|
</dd>
|
|
<dt><code class="code">#0(12)</code></dt>
|
|
<dd><p>is a rank-zero array with contents 12.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>In addition, bytevectors are also arrays, but use a different syntax
|
|
(see <a class="pxref" href="Bytevectors.html">Bytevectors</a>):
|
|
</p>
|
|
<dl class="table">
|
|
<dt><code class="code">#vu8(1 2 3)</code></dt>
|
|
<dd><p>is a 3-byte long bytevector, with contents 1, 2, 3.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="Array-Procedures.html">Array Procedures</a>, Up: <a href="Arrays.html">Arrays</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|