<?xml version="1.0" encoding="windows-1252"?>
<node id="81750" title="(tye)Re2: (Golf): Sieve of Eratosthenes" created="2001-05-19 18:41:03" updated="2005-08-14 03:51:28">
<type id="11">
note</type>
<author id="22609">
tye</author>
<data>
<field name="doctext">
&lt;p&gt;
BTW, the above was based on solving the Sieve using functional programming techniques and then analysing what the computer ends up doing when that code is run and then reimplementing that in a procedural style.  I find that technique often gives you interesting insights.
&lt;/p&gt;&lt;p&gt;
Anyway, I tried to reverse engineer what [tilly]'s solution was from his description and came up with this:
&lt;code&gt;sub sieve2 {
    grep{@_[map$a*$_,2..@_/($a=$_)]=0if$_[$_]&gt;1}@_=0..pop;
}

for( @ARGV ) {
    print "$_: ",join(" ",sieve2($_)),$/;
}
&lt;/code&gt;
which is 54 characters.  It is [strict.pm|strict] compliant "to the letter" but not "in spirit".  But it is even more Sieve-like than my previous one (I just don't like algorithms where you give an upper bound and once you get there you have to start over if you want to go further).
&lt;/p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- 
&lt;a href="/index.pl?node=tye&amp;lastnode_id=1072"&gt;tye&lt;/a&gt; 
(but my friends call me "Tye")</field>
<field name="root_node">
81695</field>
<field name="parent_node">
81697</field>
</data>
</node>
