JargonFile/original/html/H/HAKMEM.html

59 lines
6.2 KiB
HTML
Raw Normal View History

2014-03-27 14:54:56 -04:00
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>HAKMEM</title><link rel="stylesheet" href="../../jargon.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.61.0"/><link rel="home" href="../index.html" title="The Jargon File"/><link rel="up" href="../H.html" title="H"/><link rel="previous" href="hairy.html" title="hairy"/><link rel="next" href="hakspek.html" title="hakspek"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">HAKMEM</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="hairy.html">Prev</a><EFBFBD></td><th width="60%" align="center">H</th><td width="20%" align="right"><EFBFBD><a accesskey="n" href="hakspek.html">Next</a></td></tr></table><hr/></div><dt><a id="HAKMEM"/><dt xmlns="" id="HAKMEM"><b>HAKMEM</b>: <span xmlns="http://www.w3.org/1999/xhtml" class="pronunciation">/hak<61>mem/</span>, <span xmlns="http://www.w3.org/1999/xhtml" class="grammar">n.</span></dt></dt><dd><p> MIT AI Memo 239 (February 1972). A legendary collection of neat
mathematical and programming hacks contributed by many people at MIT and
elsewhere. (The title of the memo really is &#8220;<span class="quote">HAKMEM</span>&#8221;, which
is a 6-letterism for &#8216;hacks memo&#8217;.) Some of them are very
useful techniques, powerful theorems, or interesting unsolved problems, but
most fall into the category of mathematical and computer trivia. Here is a
sampling of the entries (with authors), slightly paraphrased:</p><p>Item 41 (Gene Salamin): There are exactly 23,000 prime numbers less
than
<tt class="literal">2<sup>18</sup></tt>.</p><p>Item 46 (Rich Schroeppel): The most <span class="emphasis"><em>probable</em></span>
suit distribution in bridge hands is 4-4-3-2, as compared to 4-3-3-3, which
is the most <span class="emphasis"><em>evenly</em></span> distributed. This is because the
world likes to have unequal numbers: a thermodynamic effect saying things
will not be in the state of lowest energy, but in the state of lowest
disordered energy.</p><p>Item 81 (Rich Schroeppel): Count the magic squares of order 5 (that
is, all the 5-by-5 arrangements of the numbers from 1 to 25 such that all
rows, columns, and diagonals add up to the same number). There are about
320 million, not counting those that differ only by rotation and
reflection.</p><p>Item 154 (Bill Gosper): The myth that any given programming language
is machine independent is easily exploded by computing the sum of powers of
2. If the result loops with period <tt class="literal">= 1</tt>
with sign <tt class="literal">+</tt>, you are on a sign-magnitude
machine. If the result loops with period <tt class="literal">=
1</tt> at <tt class="literal">-1</tt>, you are on a
twos-complement machine. If the result loops with period greater than 1,
including the beginning, you are on a ones-complement machine. If the
result loops with period greater than 1, not including the beginning, your
machine isn't binary &#8212; the pattern should tell you the base. If you
run out of memory, you are on a string or bignum system. If arithmetic
overflow is a fatal error, some fascist pig with a read-only mind is trying
to enforce machine independence. But the very ability to trap overflow is
machine dependent. By this strategy, consider the universe, or, more
precisely, algebra: Let <tt class="literal">X =</tt> the sum of
many powers of 2 = ...111111 (base 2). Now add
<tt class="literal">X</tt> to itself: <tt class="literal">X + X
=</tt> ...111110. Thus, <tt class="literal">2X = X -
1</tt>, so <tt class="literal">X = -1</tt>. Therefore
algebra is run on a machine (the universe) that is two's-complement.</p><p>Item 174 (Bill Gosper and Stuart Nelson): 21963283741 is the only
number such that if you represent it on the <a href="../P/PDP-10.html"><i class="glossterm">PDP-10</i></a>
as both an integer and a floating-point number, the bit patterns of the two
representations are identical.</p><p>Item 176 (Gosper): The &#8220;<span class="quote">banana phenomenon</span>&#8221; was
encountered when processing a character string by taking the last 3 letters
typed out, searching for a random occurrence of that sequence in the text,
taking the letter following that occurrence, typing it out, and iterating.
This ensures that every 4-letter string output occurs in the original. The
program typed BANANANANANANANA.... We note an ambiguity in the
phrase, &#8220;<span class="quote">the <tt class="literal">N</tt>th occurrence
of.</span>&#8221; In one sense, there are five 00's in 0000000000; in another,
there are nine. The editing program TECO finds five. Thus it finds only
the first ANA in BANANA, and is thus obligated to type N next. By Murphy's
Law, there is but one NAN, thus forcing A, and thus a loop. An option to
find overlapped instances would be useful, although it would require
backing up <tt class="literal">N</tt> &#8722; 1 characters before
seeking the next <tt class="literal">N</tt>-character
string.</p><p>Note: This last item refers to a
<a href="../D/Dissociated-Press.html"><i class="glossterm">Dissociated Press</i></a> implementation. See also
<a href="../B/banana-problem.html"><i class="glossterm">banana problem</i></a>.</p><p>HAKMEM also contains some rather more complicated mathematical and
technical items, but these examples show some of its fun flavor.</p><p>An HTML transcription of the entire document is available at <a href="http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html" target="_top">http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html</a>.</p></dd><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="hairy.html">Prev</a><EFBFBD></td><td width="20%" align="center"><a accesskey="u" href="../H.html">Up</a></td><td width="40%" align="right"><EFBFBD><a accesskey="n" href="hakspek.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">hairy<EFBFBD></td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"><EFBFBD>hakspek</td></tr></table></div></body></html>