1
0
Fork 0
cl-sites/guile.html_node/Dictionary-Types.html
2024-12-17 12:49:28 +01:00

100 lines
4.7 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>Dictionary Types (Guile Reference Manual)</title>
<meta name="description" content="Dictionary Types (Guile Reference Manual)">
<meta name="keywords" content="Dictionary Types (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="Data-Types.html" rel="up" title="Data Types">
<link href="Association-Lists.html" rel="next" title="Association Lists">
<link href="Structures.html" rel="prev" title="Structures">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
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="subsection-level-extent" id="Dictionary-Types">
<div class="nav-panel">
<p>
Next: <a href="Association-Lists.html" accesskey="n" rel="next">Association Lists</a>, Previous: <a href="Structures.html" accesskey="p" rel="prev">Structures</a>, Up: <a href="Data-Types.html" accesskey="u" rel="up">Data Types</a> &nbsp; [<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="subsection" id="Dictionary-Types-1"><span>6.6.19 Dictionary Types<a class="copiable-link" href="#Dictionary-Types-1"> &para;</a></span></h4>
<p>A <em class="dfn">dictionary</em> object is a data structure used to index
information in a user-defined way. In standard Scheme, the main
aggregate data types are lists and vectors. Lists are not really
indexed at all, and vectors are indexed only by number
(e.g. <code class="code">(vector-ref foo 5)</code>). Often you will find it useful
to index your data on some other type; for example, in a library
catalog you might want to look up a book by the name of its
author. Dictionaries are used to help you organize information in
such a way.
</p>
<p>An <em class="dfn">association list</em> (or <em class="dfn">alist</em> for short) is a list of
key-value pairs. Each pair represents a single quantity or
object; the <code class="code">car</code> of the pair is a key which is used to
identify the object, and the <code class="code">cdr</code> is the object&rsquo;s value.
</p>
<p>A <em class="dfn">hash table</em> also permits you to index objects with
arbitrary keys, but in a way that makes looking up any one object
extremely fast. A well-designed hash system makes hash table
lookups almost as fast as conventional array or vector references.
</p>
<p>Alists are popular among Lisp programmers because they use only
the language&rsquo;s primitive operations (lists, <em class="dfn">car</em>, <em class="dfn">cdr</em>
and the equality primitives). No changes to the language core are
necessary. Therefore, with Scheme&rsquo;s built-in list manipulation
facilities, it is very convenient to handle data stored in an
association list. Also, alists are highly portable and can be
easily implemented on even the most minimal Lisp systems.
</p>
<p>However, alists are inefficient, especially for storing large
quantities of data. Because we want Guile to be useful for large
software systems as well as small ones, Guile provides a rich set
of tools for using either association lists or hash tables.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Association-Lists.html">Association Lists</a>, Previous: <a href="Structures.html">Structures</a>, Up: <a href="Data-Types.html">Data Types</a> &nbsp; [<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>