101 lines
3.8 KiB
HTML
101 lines
3.8 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>List Syntax (Guile Reference Manual)</title>
|
||
|
|
||
|
<meta name="description" content="List Syntax (Guile Reference Manual)">
|
||
|
<meta name="keywords" content="List 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="Lists.html" rel="up" title="Lists">
|
||
|
<link href="List-Predicates.html" rel="next" title="List Predicates">
|
||
|
<style type="text/css">
|
||
|
<!--
|
||
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
||
|
div.example {margin-left: 3.2em}
|
||
|
span.r {font-family: initial; font-weight: normal; font-style: normal}
|
||
|
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="List-Syntax">
|
||
|
<div class="nav-panel">
|
||
|
<p>
|
||
|
Next: <a href="List-Predicates.html" accesskey="n" rel="next">List Predicates</a>, Up: <a href="Lists.html" accesskey="u" rel="up">Lists</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="List-Read-Syntax"><span>6.6.9.1 List Read Syntax<a class="copiable-link" href="#List-Read-Syntax"> ¶</a></span></h4>
|
||
|
|
||
|
<p>The syntax for lists is an opening parentheses, then all the elements of
|
||
|
the list (separated by whitespace) and finally a closing
|
||
|
parentheses.<a class="footnote" id="DOCF9" href="#FOOT9"><sup>9</sup></a>.
|
||
|
</p>
|
||
|
<div class="example lisp">
|
||
|
<pre class="lisp-preformatted">(1 2 3) ; <span class="r">a list of the numbers 1, 2 and 3</span>
|
||
|
("foo" bar 3.1415) ; <span class="r">a string, a symbol and a real number</span>
|
||
|
() ; <span class="r">the empty list</span>
|
||
|
</pre></div>
|
||
|
|
||
|
<p>The last example needs a bit more explanation. A list with no elements,
|
||
|
called the <em class="dfn">empty list</em>, is special in some ways. It is used for
|
||
|
terminating lists by storing it into the cdr of the last pair that makes
|
||
|
up a list. An example will clear that up:
|
||
|
</p>
|
||
|
<div class="example lisp">
|
||
|
<pre class="lisp-preformatted">(car '(1))
|
||
|
⇒
|
||
|
1
|
||
|
(cdr '(1))
|
||
|
⇒
|
||
|
()
|
||
|
</pre></div>
|
||
|
|
||
|
<p>This example also shows that lists have to be quoted when written
|
||
|
(see <a class="pxref" href="Expression-Syntax.html">Expression Syntax</a>), because they would otherwise be
|
||
|
mistakenly taken as procedure applications (see <a class="pxref" href="Simple-Invocation.html">Simple Procedure Invocation</a>).
|
||
|
</p>
|
||
|
|
||
|
</div>
|
||
|
<div class="footnotes-segment">
|
||
|
<hr>
|
||
|
<h4 class="footnotes-heading">Footnotes</h4>
|
||
|
|
||
|
<h5 class="footnote-body-heading"><a id="FOOT9" href="#DOCF9">(9)</a></h5>
|
||
|
<p>Note that there is no separation character between
|
||
|
the list elements, like a comma or a semicolon.</p>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|