Files
JargonFile/original/html/O/one-liner-wars.html
2014-03-27 18:54:56 +00:00

18 lines
3.0 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>one-liner wars</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="../O.html" title="O"/><link rel="previous" href="one-line-fix.html" title="one-line fix"/><link rel="next" href="ooblick.html" title="ooblick"/></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">one-liner wars</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="one-line-fix.html">Prev</a> </td><th width="60%" align="center">O</th><td width="20%" align="right"> <a accesskey="n" href="ooblick.html">Next</a></td></tr></table><hr/></div><dt><a id="one-liner-wars"/><dt xmlns="" id="one-liner-wars"><b>one-liner wars</b>: <span xmlns="http://www.w3.org/1999/xhtml" class="grammar">n.</span></dt></dt><dd><p> A game popular among hackers who code in the language APL (see
<a href="../W/write-only-language.html"><i class="glossterm">write-only language</i></a> and
<a href="../L/line-noise.html"><i class="glossterm">line noise</i></a>). The objective is to see who can code the most
interesting and/or useful routine in one line of operators chosen from
APL's exceedingly <a href="../H/hairy.html"><i class="glossterm">hairy</i></a> primitive set. A similar
amusement was practiced among <a href="../T/TECO.html"><i class="glossterm">TECO</i></a> hackers and is
now popular among <a href="../P/Perl.html"><i class="glossterm">Perl</i></a> aficionados.</p><p>Ken Iverson, the inventor of APL, has been credited with a one-liner
that, given a number <tt class="literal">N</tt>, produces a list of
the prime numbers from 1 to <tt class="literal">N</tt> inclusive.
It looks like this:</p><table border="0" bgcolor="#E0E0E0"><tr><td><pre class="programlisting">
(2=0+.=T&#8709;.|T)/T&#8592;&#953;N
</pre></td></tr></table><p>Here's a <a href="../P/Perl.html"><i class="glossterm">Perl</i></a> program that prints
primes:</p><table border="0" bgcolor="#E0E0E0"><tr><td><pre class="programlisting">
perl -wle '(1 x $_) !~ /^(11+)\1+$/ &amp;&amp; print while ++ $_'
</pre></td></tr></table><p>In the Perl world this game is sometimes called Perl Golf because the
player with the fewest (key)strokes wins.</p></dd><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="one-line-fix.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="../O.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ooblick.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">one-line fix </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> ooblick</td></tr></table></div></body></html>