emacs.d/clones/lisp/www.cliki.net/xarray.html
2022-10-07 15:47:14 +02:00

70 lines
No EOL
4.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CLiki: xarray</title>
<link rel="alternate" type="application/atom+xml" title="ATOM feed of edits to current article"
href="https://www.cliki.net/site/feed/article.atom?title=xarray">
<link rel="stylesheet" href="static/css/style.css">
<link rel="stylesheet" href="static/css/colorize.css">
</head>
<body>
<span class="hidden">CLiki - xarray</span>
<div id="content"><div id="content-area"><div id="article-title">xarray</div><div id="article">This package implements a generalized interface for array-like
objects. The idea is that we should be able to index an object as
<div class="code"><span class="nonparen"><span class="paren1">(<span class="nonparen">xref object 1 2 3</span>)</span>
</span></div>
to retrieve or set an element. This would be easy to do it aref was a
generic function, but it is not. I describe a simple interface with a
few generic functions (xdims queries dimensions, xtype element type,
etc), any objects that has these methods is called "xrefable".<p>The nice part is that views on an array can also be xrefable. For an
two-dimensional array <code>*a*</code>,
<div class="code"><span class="nonparen"><span class="paren1">(<span class="nonparen">slice <span class="special">*a*</span> <span class="keyword">:all</span> 4</span>)</span>
</span></div>
selects the 4th column of an array.¹ This view is also xrefable, so
you can use<p><div class="code"><span class="nonparen"><span class="paren1">(<span class="nonparen"><a href="https://www.cliki.net/site/HyperSpec/Body/any_setf.html" class="symbol">setf</a> <span class="paren2">(<span class="nonparen">xref <span class="paren3">(<span class="nonparen">slice <span class="special">*a*</span> <span class="keyword">:all</span> 4</span>)</span> 2</span>)</span> 9</span>)</span>
</span></div>
to set element 2 to <code>9</code>. Changes will be made in the original array
<code>*a*</code>, since this is a view. But for functions that just expect an
array, they can use the interface (xref, xdims, etc) and not care
where it is coming from.<p>¹ The slice interface is similar to author's <a href="https://www.cliki.net/affi" class="new">affi</a> package, but now
arbitrary index vectors are allowed.<p>Homepage: <a href="https://github.com/blindglobe/xarray">https://github.com/blindglobe/xarray</a><p>License: <a href="MIT.html" class="category">MIT</a><p>See Also: <a href="cl-slice.html" class="internal">cl-slice</a><p><hr>
Topics: <a href="language&#32;extension.html" class="category">language extension</a></div></div>
<div id="footer" class="buttonbar"><ul><li><a href="xarray.html">Current version</a></li>
<li><a href="https://www.cliki.net/site/history?article=xarray">History</a></li>
<li><a href="https://www.cliki.net/site/backlinks?article=xarray">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=xarray&amp;from-revision=3800034317">Edit</a></li><li><a href="https://www.cliki.net/site/edit-article?create=t">Create</a></li></ul></div>
</div>
<div id="header-buttons" class="buttonbar">
<ul>
<li><a href="https://www.cliki.net/">Home</a></li>
<li><a href="https://www.cliki.net/site/recent-changes">Recent Changes</a></li>
<li><a href="CLiki.html">About</a></li>
<li><a href="Text&#32;Formatting.html">Text Formatting</a></li>
<li><a href="https://www.cliki.net/site/tools">Tools</a></li>
</ul>
<div id="search">
<form action="https://www.cliki.net/site/search">
<label for="search_query" class="hidden">Search CLiki</label>
<input type="text" name="query" id="search_query" value="" />
<input type="submit" value="search" />
</form>
</div>
</div>
<div id="pageheader">
<div id="header">
<span id="logo">CLiki</span>
<span id="slogan">the common lisp wiki</span>
<div id="login"><form method="post" action="https://www.cliki.net/site/login">
<label for="login_name" class="hidden">Account name</label>
<input type="text" name="name" id="login_name" class="login_input" />
<label for= "login_password" class="hidden">Password</label>
<input type="password" name="password" id="login_password" class="login_input" />
<input type="submit" name="login" value="login" id="login_submit" /><br />
<div id="register"><a href="https://www.cliki.net/site/register">register</a></div>
<input type="submit" name="reset-pw" value="reset password" id="reset_pw" />
</form>
</div>
</div>
</div>
</body></html>