From: Mike Stok Date: 2001-02-06T12:15:26+09:00 Subject: [ruby-talk:10396] Re: [OT now] Re: Structured text matching? On Tue, 6 Feb 2001, Michael Schuerig wrote: > Very interesting! I've never looked into Parse::RecDescent, but after a > quick glimpse over an article by Randal Schwartz, it's pretty > impressive. Damian Conway does a lot of impressive stuff and useful stuff in perl, e.g. Getopt::Declare, Parse::RecDescent, ways to do classless OO in perl, wats to do programming by contract in perl, etc. But it's the plain amazing stuff which makes me smile: In the Ruby examples directory I find sieve.rb which is elegant in its way: # sieve of Eratosthenes max = Integer(ARGV.shift || 100) sieve = [] for i in 2 .. max sieve[i] = i end for i in 2 .. Math.sqrt(max) next unless sieve[i] (i*i).step(max, i) do |j| sieve[j] = nil end end puts sieve.compact.join ", " [mike@ratdog sample]$ ruby sieve.rb 10 2, 3, 5, 7 and in /usr/local/src/perl/modules/Lingua-Romana-Perligata-0.01/demo I find demo_eratosthenes.pl which is elegant in its expression, if not its algorithm: use Lingua::Romana::Perligata # 'converte', # 'discribe' # 'investiga', ; maximum tum val inquementum tum biguttam tum stadium egresso scribe. vestibulo perlegementum da meo maximo . maximum tum novumversum egresso scribe. da II tum maximum conscribementa meis listis. dum damentum nexto listis decapitamentum fac sic lista sic hoc tum nextum recidementum cis vannementa da listis. next tum biguttam tum stadium tum nextum tum novumversum scribe egresso. cis [builder@ratdog demo]$ perl demo_eratosthenes.pl maximum val: 10 10 next: 2 next: 3 next: 5 next: 7 See http://www.csse.monash.edu.au/~damian/papers/HTML/Perligata.html for an explanation. If you ever get a chance to catch Damian's talks then do. Sorry for the off topic post. Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60 stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA