emacs.d/clones/lisp/www.cliki.net/Issue MERGE-PREDICATE-CALL.html

55 lines
4.5 KiB
HTML
Raw Normal View History

2022-10-07 15:47:14 +02:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CLiki: Issue MERGE-PREDICATE-CALL</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=Issue%20MERGE-PREDICATE-CALL">
<link rel="stylesheet" href="static/css/style.css">
<link rel="stylesheet" href="static/css/colorize.css">
</head>
<body>
<span class="hidden">CLiki - Issue MERGE-PREDICATE-CALL</span>
<div id="content"><div id="content-area"><div id="article-title">Issue MERGE-PREDICATE-CALL</div><div id="article"><a href="Issue.html" class="category">Issue</a>: MERGE-PREDICATE-CALL<p>References: <a href="https://www.cliki.net/site/HyperSpec/Body/fun_merge.html" class="hyperspec">MERGE</a><p><dl><p><dt>Problem Description:</dt><p><dd>
The page for <a href="https://www.cliki.net/site/HyperSpec/Body/fun_merge.html" class="hyperspec">MERGE</a> says<p><blockquote>
The first argument to the <i>predicate</i> function is an element of <i>sequence-1</i> as returned by the <i>key</i> (if supplied); the second argument is an element of <i>sequence-2</i> as returned by the <i>key</i> (if supplied). <i>Predicate</i> should return <i>true</i> if and only if its first argument is strictly less than the second (in some appropriate sense). If the first argument is greater than or equal to the second (in the appropriate sense), then <i>predicate</i> should return <i>false</i>. <b>merge</b> considers two elements <tt>x</tt> and <tt>y</tt> to be equal if <tt>(funcall predicate x y)</tt> and <tt>(funcall predicate y x)</tt> both yield <i>false</i>.</blockquote><p>If this were true for every call to the <i>predicate</i>, this requirement, also given on that page, could not be satisfied (because test for equality requires the argument order to be reversed):<p><blockquote>The merging operation is guaranteed stable; if two or more elements are considered equal by the <i>predicate</i>, then the elements from <i>sequence-1</i> will precede those from <i>sequence-2</i> in the result.</blockquote><p>In fact, the optimal algorithm for MERGE (optimal in the sense of minimizing the number of calls to the predicate) will <i>always</i> call the <i>predicate</i> with the arguments in the reverse order (one from <i>sequence-2</i> followed by one from <i>sequence-1</i>).
</dd>
</dl></div></div>
<div id="footer" class="buttonbar"><ul><li><a href="Issue&#32;MERGE-PREDICATE-CALL.html">Current version</a></li>
<li><a href="https://www.cliki.net/site/history?article=Issue%20MERGE-PREDICATE-CALL">History</a></li>
<li><a href="https://www.cliki.net/site/backlinks?article=Issue%20MERGE-PREDICATE-CALL">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=Issue%20MERGE-PREDICATE-CALL&amp;from-revision=3722793483">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>