/
index.html
149 lines (121 loc) · 7.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="canonical" href="https://www.hexstreamsoft.com/libraries/map-bind/" />
<meta name="author" content="Jean-Philippe Paradis" />
<link rel="author" href="https://abc.hexstream.xyz/" />
<link rel="license" href="https://www.hexstreamsoft.com/UNLICENSE" />
<meta name="description" content="A macro that allows visual grouping of variables with their corresponding values (not necessarily 1:1) in calls to mapping operators when using an inline lambda." />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>map-bind | Libraries | HexstreamSoft</title>
<link href="https://www.hexstreamsoft.com/css/global.css" rel="stylesheet" type="text/css" />
<link href="https://www.hexstreamsoft.com/libraries/libraries.css" rel="stylesheet" type="text/css" />
<link href="index.css" rel="stylesheet" type="text/css" />
<script src="https://global.hexstream.dev/scripts/global.js"></script>
<script src="https://www.hexstreamsoft.com/scripts/global.js"></script>
<script src="https://www.hexstreamsoft.com/libraries/libraries.js" defer></script>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@HexstreamSoft" />
<meta name="twitter:title" content="map-bind" />
<meta name="twitter:description" content="A macro that allows visual grouping of variables with their corresponding values (not necessarily 1:1) in calls to mapping operators when using an inline LAMBDA." />
</head>
<body>
<nav id="top-nav">
<div class="main">
<div class="breadcrumbs">
<a href="https://www.hexstreamsoft.com/">HexstreamSoft</a>
<span class="crumb"><span class="s"> » </span><a href="https://www.hexstreamsoft.com/libraries/">Libraries</a></span>
<span class="crumb"><span class="s"> » </span><a class="here">map-bind</a></span>
</div>
<nav class="tabs" id="meta-nav">
<ul>
<li><a class="github" href="https://github.com/Hexstream/map-bind"><span>See on GitHub</span></a></li>
</ul>
</nav>
</div>
<p id="last-updated"><span>This page was last updated on </span><time datetime="2018-09-06">6 september 2018</time><span>.</span></p>
</nav>
<main>
<header id="page-header">
<h1>map-bind</h1>
</header>
<div class="tags contains-groups">
<div class="group prominent">
<span class="tag hv license">
<span class="h">License<span>:</span></span>
<span class="v">Public Domain</span>
</span>
<span class="s">, </span>
<span class="tag hv quicklisp">
<span class="h">Load it with Quicklisp<span>:</span></span>
<code class="v">(ql:quickload "map-bind")</code>
</span>
</div>
<div class="group">
<span class="tag hv">
<span class="h">Library type<span>:</span></span>
<span class="v">Visual macro</span>
</span>
<span class="s">, </span>
<span class="tag hv">
<span class="h">Project complexity<span>:</span></span>
<span class="v">Embarrassingly trivial</span>
</span>
</div>
</div>
<nav class="tabs" id="further-info">
<ul>
<li><a href="https://www.hexstreamsoft.com/libraries/releases/latest-versions/#map-bind">Latest release</a></li>
<li><a href="https://www.hexstreamsoft.com/libraries/dependencies/#map-bind">Dependencies</a></li>
</ul>
<ul>
<li><a href="https://www.hexstreamsoft.com/libraries/external-pages-xref/#map-bind">External library pages</a></li>
</ul>
</nav>
<section id="introduction">
<p><dfn><code class="relevant">map-bind</code></dfn> is a macro that allows visual grouping of variables with their corresponding values (not necessarily 1:1) in calls to mapping operators when using an inline <code>lambda</code>.<br />It does so in a way that automatically supports virtually every existing and future mapping operator, all <a href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_l.htm#lambda_list_keyword">lambda list keywords</a> and <code>funcall</code>/<code>apply</code>/<code>multiple-value-call</code> variations.</p>
<p>It does all this with a surprisingly simple <a href="https://github.com/Hexstream/map-bind/blob/master/main.lisp">implementation</a>!</p>
</section>
<section id="documentation">
<p>Here's an example designed to show many features at once:<br />
(color key: <span class="prologue">prologue</span> <span class="arg">arguments</span> <span class="val">values</span> <span class="lambda-body">lambda-body</span>)</p>
<div class="scroll">
<pre class="example"><code class="common-lisp">(<code class="relevant">map-bind</code> (<span class="prologue"><code>multiple-value-call</code> #'map 'vector</span>)
((<span class="arg"><var>symbol</var></span> <span class="val">#(a b c)</span>)
(<span class="arg"><var>number</var></span> <span class="val">'(1 2 3)</span>)
((<span class="arg">&rest <var>others</var> &key &allow-other-keys</span>) <span class="val">(values '(d e f) #(4 5 6))</span>)
((<span class="arg">&aux (<var>plus-ten</var> (+ <var>number</var> 10))</span>)))
<span class="lambda-body">(list (1- <var>number</var>) <var>symbol</var> <var>plus-ten</var> (reverse <var>others</var>))</span>)
==
(<span class="prologue">multiple-value-call #'map 'vector</span>
(lambda (<span class="arg"><var>symbol</var></span> <span class="arg"><var>number</var></span>
<span class="arg">&rest <var>others</var> &key &allow-other-keys</span>
<span class="arg">&aux (<var>plus-ten</var> (+ <var>number</var> 10))</span>)
<span class="lambda-body">(list (1- <var>number</var>) <var>symbol</var> <var>plus-ten</var> (reverse <var>others</var>))</span>)
<span class="val">#(a b c)</span>
<span class="val">'(1 2 3)</span>
<span class="val">(values '(d e f) #(4 5 6))</span>)
=>
<samp>#((0 A 11 (4 D)) (1 B 12 (5 E)) (2 C 13 (6 F)))</samp>
</code></pre>
</div>
<p><b>To use <code class="relevant">map-bind</code>, simply <code>(:import-from #:map-bind #:map-bind)</code>. Don't <code>(:use)</code>!</b></p>
</section>
</main>
<footer id="footer">
<div class="back-to-top left">
<a href="#">⬆</a>
</div>
<div class="main">
<a href="https://validator.w3.org/check?uri=http%3A%2F%2Fwww.hexstreamsoft.com%2Flibraries%2Fmap-bind%2F">✔ HTML5</a>
<a href="https://www.hexstreamsoft.com/README">✔ Public Domain</a>
<a href="https://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.hexstreamsoft.com%2Flibraries%2Fmap-bind%2F">✔ CSS3</a>
<a>✔ Mobile-friendly</a>
</div>
<div class="back-to-top right">
<a href="#">⬆</a>
</div>
</footer>
</body>
</html>