From m3047 at inwa.net Sat Oct 6 01:00:22 2007 From: m3047 at inwa.net (Fred Morris) Date: Sat, 6 Oct 2007 01:00:22 -0700 Subject: SPUG: Primes In-Reply-To: <200709251751.32923.m3047@inwa.net> References: <00b101c7ffa0$bcbe0b10$0400a8c0@mlaptop> <200709251751.32923.m3047@inwa.net> Message-ID: <200710060100.23019.m3047@inwa.net> Somebody told me this wasn't math, just accounting. But I can't seem to find it exactly described in the literature. Have fun. Let me know. #!/usr/bin/perl # Expects -p:max-to-test where max-to-test is an integer. use Getopt::Std; use vars '$opt_p'; use strict; # Annoying hidden voodoo. getopts('p:'); ($opt_p =~ m/^\d+$/) or die 'p must be an unsigned decimal integer'; my $i = 2; # First possible value. my %numbers; sub next_number($$) { my $i = shift; my $k = shift; my $next_i = $i + $k; if (exists $numbers{$next_i}) { push @{$numbers{$next_i}}, $k; } else { $numbers{$next_i} = [$k]; } return; } while ($i < $opt_p) { if (exists $numbers{$i}) { map next_number($i,$_), @{$numbers{$i}}; delete $numbers{$i}; } else { printf "%8d\n", $i; next_number($i,$i); } $i += 1; } exit(0); From krahnj at telus.net Sat Oct 6 04:34:55 2007 From: krahnj at telus.net (John W. Krahn) Date: Sat, 06 Oct 2007 04:34:55 -0700 Subject: SPUG: Primes In-Reply-To: <200710060100.23019.m3047@inwa.net> References: <00b101c7ffa0$bcbe0b10$0400a8c0@mlaptop> <200709251751.32923.m3047@inwa.net> <200710060100.23019.m3047@inwa.net> Message-ID: <470772DF.2030309@telus.net> Fred Morris wrote: > Somebody told me this wasn't math, just accounting. But I can't seem to find > it exactly described in the literature. Have fun. Let me know. > > #!/usr/bin/perl > # Expects -p:max-to-test where max-to-test is an integer. use warnings; > use Getopt::Std; > use vars '$opt_p'; > use strict; > > # Annoying hidden voodoo. > getopts('p:'); Or without the package variable: getopts( 'p:', \my %opt ); > ($opt_p =~ m/^\d+$/) or die 'p must be an unsigned decimal integer'; > > my $i = 2; # First possible value. > my %numbers; > > sub next_number($$) { Don't use prototypes. With warnings enabled this will warn. > my $i = shift; > my $k = shift; > > my $next_i = $i + $k; > if (exists $numbers{$next_i}) { > push @{$numbers{$next_i}}, $k; > } > else { > $numbers{$next_i} = [$k]; > } No need to test for key existence, perl will autovivify the array. my $next_i = $i + $k; push @{ $numbers{ $next_i } }, $k; > return; > } > > while ($i < $opt_p) { > > if (exists $numbers{$i}) { > map next_number($i,$_), @{$numbers{$i}}; Where is the list that map returns being assigned? > delete $numbers{$i}; next_number( $i, $_ ) for @{ delete $numbers{ $i } }; > } > else { > printf "%8d\n", $i; > next_number($i,$i); > } > > $i += 1; > } > > exit(0); John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall From dtreder at gmail.com Sat Oct 6 10:50:59 2007 From: dtreder at gmail.com (Doug Treder) Date: Sat, 06 Oct 2007 10:50:59 -0700 Subject: SPUG: Primes In-Reply-To: <200710060100.23019.m3047@inwa.net> References: <00b101c7ffa0$bcbe0b10$0400a8c0@mlaptop> <200709251751.32923.m3047@inwa.net> <200710060100.23019.m3047@inwa.net> Message-ID: <4707CB03.9010109@gmail.com> Maybe this was unintentional, but I found it hilarious. For those not in on the joke, this algorithm is (or is very similar to) the Sieve of Erastothenes, and is widely known as the earliest known algorithm of any kind (not just for finding prime numbers). I show this one in my last class as an example of coding in Lingua::Romana::Perligata, a fun module by Damian Conway. It's very succinct as: #!/usr/bin/perl # Sieve of Eratosthenes print STDOUT 'maximum:'; my $maxim = ; my (@list) = (2..$maxim); while ($next = shift @list) { print STDOUT $next, "\n"; @list = grep {$_ % $next} @list; } which is the literal translation, using Lingua::Romana::Perligata of: #! /usr/local/bin/perl -w use Lingua::Romana::Perligata; adnota Illud Cribrum Eratothenis maximum inquementum tum biguttam egresso scribe. meo maximo vestibulo perlegamentum da. da duo tum maximum conscribementa meis listis. dum listis decapitamentum damentum nexto fac sic nextum tum novumversum scribe egresso. lista sic hoc recidementum nextum cis vannementa da listis. cis. (original code and translation from Damian Conway) -Doug Fred Morris wrote: > Somebody told me this wasn't math, just accounting. But I can't seem to find > it exactly described in the literature. Have fun. Let me know. > > #!/usr/bin/perl > # Expects -p:max-to-test where max-to-test is an integer. > > use Getopt::Std; > use vars '$opt_p'; > use strict; > > # Annoying hidden voodoo. > getopts('p:'); > > ($opt_p =~ m/^\d+$/) or die 'p must be an unsigned decimal integer'; > > my $i = 2; # First possible value. > my %numbers; > > sub next_number($$) { > > my $i = shift; > my $k = shift; > > my $next_i = $i + $k; > if (exists $numbers{$next_i}) { > push @{$numbers{$next_i}}, $k; > } > else { > $numbers{$next_i} = [$k]; > } > > return; > } > > while ($i < $opt_p) { > > if (exists $numbers{$i}) { > map next_number($i,$_), @{$numbers{$i}}; > delete $numbers{$i}; > } > else { > printf "%8d\n", $i; > next_number($i,$i); > } > > $i += 1; > } > > exit(0); > > _____________________________________________________________ > Seattle Perl Users Group Mailing List > POST TO: spug-list at pm.org > SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list > MEETINGS: 3rd Tuesdays > WEB PAGE: http://seattleperl.org/ > > From m3047 at inwa.net Sat Oct 6 11:01:51 2007 From: m3047 at inwa.net (Fred Morris) Date: Sat, 6 Oct 2007 11:01:51 -0700 Subject: SPUG: Primes In-Reply-To: <470772DF.2030309@telus.net> References: <200710060100.23019.m3047@inwa.net> <470772DF.2030309@telus.net> Message-ID: <200710061101.51195.m3047@inwa.net> Good to know! -- Fred Morris On Saturday 06 October 2007 04:34, John W. Krahn wrote: > Fred Morris wrote: > > [...] > > my $next_i = $i + $k; > > if (exists $numbers{$next_i}) { > > push @{$numbers{$next_i}}, $k; > > } > > else { > > $numbers{$next_i} = [$k]; > > } > > No need to test for key existence, perl will autovivify the array. > > my $next_i = $i + $k; > push @{ $numbers{ $next_i } }, $k; > From m3047 at inwa.net Sat Oct 6 11:20:55 2007 From: m3047 at inwa.net (Fred Morris) Date: Sat, 6 Oct 2007 11:20:55 -0700 Subject: SPUG: laughing Re: Primes In-Reply-To: <4707CB03.9010109@gmail.com> References: <200710060100.23019.m3047@inwa.net> <4707CB03.9010109@gmail.com> Message-ID: <200710061120.55234.m3047@inwa.net> I'm laughing alright. Yes, looks like you've got yer implementation of the Sieve there below. Or for an official definition: http://www.nist.gov/dads/HTML/sieve.html On Saturday 06 October 2007 10:50, Doug Treder wrote: > Maybe this was unintentional, but I found it hilarious. The joke is, like Einstein purportedly said of radio (comparing it to telegraph): "you pull its tail in New York and it meows in Los Angeles, except that there is no cat!" So back to the topic at hand: > For those not in on the joke, this algorithm is (or is very similar to) > the Sieve of Erastothenes, and is widely known as the earliest known > algorithm of any kind (not just for finding prime numbers). Should say "...this algorithm is not (but I want to claim it is similar to) the Sieve of Eratosthenes, which is widely known as the earliest known algorithm of any kind (not just for finding prime numbers)." and I'll leave it to Babylonian, Egyptian and biblical scholars to demolish the rest of the hyperbole. -- Fred Morris From m3047 at inwa.net Sat Oct 6 11:38:33 2007 From: m3047 at inwa.net (Fred Morris) Date: Sat, 6 Oct 2007 11:38:33 -0700 Subject: SPUG: Primes In-Reply-To: <200710060100.23019.m3047@inwa.net> References: <200709251751.32923.m3047@inwa.net> <200710060100.23019.m3047@inwa.net> Message-ID: <200710061138.33762.m3047@inwa.net> Sieve of Atkin, by DJB claims "50847534 primes up to 1000000000 in just 8 seconds on a Pentium II-350": http://cr.yp.to/primegen.html Written in C, YMMV. From m3047 at inwa.net Sat Oct 6 17:16:23 2007 From: m3047 at inwa.net (Fred Morris) Date: Sat, 6 Oct 2007 17:16:23 -0700 Subject: SPUG: Sophistry Re: Primes In-Reply-To: <200710061101.51195.m3047@inwa.net> References: <470772DF.2030309@telus.net> <200710061101.51195.m3047@inwa.net> Message-ID: <200710061716.23232.m3047@inwa.net> Eratosthenes clearly calls out the procedure for his Sieve and you have to allocate the entire range and then you mark them off... yes/no, yes/no... Here, the limit could be dynamic: the algorithm consumes the resources it needs, when it needs them. The Sieve, while it may be conceptually posited as a story to understand what is going on here, never exists at one point in space/time: you might see it with appropriate time-lapse photography. In reality though the holes appear as we learn something about them and disappear as we pass them. In the case of the actual Sieve, the "holes" are dumb. Here the "holes" tell you their factors. Notwithstanding the foregoing, an important observation which applies to Sieves does apply here. 1) When we find a prime P, the first hole we need to tell about it is P squared. This means that the holes no longer have a complete list of (prime) factors as it did in the naive version, but a hole H still contains a list of all factors <= sqrt(H), which is sufficient to compute the complete list of factors with little difficulty. 2) The limit still can be utilized as a hint for some optimizations. Once we get past the square root of the limit, a prime is still a prime but we don't need to post it forward because it's past the limit. (Here, without the subroutine... although I still feel more comfortable making sure something exists before I attempt to do something with it.) (Why the map in void context? A Pythonism or something, I guess.) (Is this the best way to find primes? Wot, you're gonna use Perl to find primes?) #!/usr/bin/perl use Getopt::Std; use vars qw/ %Options /; use strict; #use warnings; getopts('p:t', \%Options ); my $limit = $Options{p}; ($limit =~ m/^\d+$/) or die 'p must be an unsigned decimal integer'; my $truncate = exists $Options{t} ? sqrt($limit) : $limit; my $i = 2; # First possible value. my %numbers; while ($i < $limit) { if (exists $numbers{$i}) { map push( @{$numbers{$i+$_}},$_), @{$numbers{$i}}; delete $numbers{$i}; } else { printf "%8d\n", $i; push( @{$numbers{$i*$i}},$i) if ($i < $truncate); } $i += 1; } exit(0); __END__ Fred Morris From cmeyer at helvella.org Thu Oct 11 11:50:28 2007 From: cmeyer at helvella.org (Colin Meyer) Date: Thu, 11 Oct 2007 11:50:28 -0700 Subject: SPUG: Meeting Announcement -- 16 October, 2007 Message-ID: <20071011185028.GB32293@infula.helvella.org> October 2007 Seattle Perl Users Group (SPUG) Meeting ==================================================== Topic: Integrating 3rd-Party Web Apps with mod_perl2 Filters Speaker: J. Gryphon Shafer Meeting Date: Tuesday, 16 October 2007 Meeting Time: 6:30 - 8:30 p.m. Location: Whitepages.com offices, downtown Seattle Cost: Admission is free and open to the public Info: http://seattleperl.org/ ==================================================== This coming Tuesday, October 16th, is the next meeting of the THE SEATTLE PERL USERS GROUP. This month, Gryphon Shafer will present a talk entitled "Integrating 3rd- Party Web Apps with mod_perl2 Filters" Learn how to use mod_perl2 input and output filters to more easily integrate 3rd-party web applications without having to touch source code. Write simple filters and stack them so similar functional needs across several applications can share filters, allowing for more code reuse. Use filters to integrate different 3rd-party authentication mechanisms into one site-wide system. Learn why beer is good for you. Gryphon Shafer is the Director of Technology for Petfinder, part of Animal Planet, Discovery Communications. He leads his department as a fully-telecommute organization spread across the country and works out of his home in Port Orchard. So, be sure to bring your friends, stray pets (ahem), and, of course, don't forget to bring yourself! We'll see YOU at the next SPUG meeting! ================ Thanks again to all the SPUG members that show up at meetings or participate on the list to make the group worthwhile in the first place, and all the JAPHs out there for just being. Meeting Location ================ Whitepages.com is located on the 16th floor of the Rainier Square Tower (1301 5th Avenue, Seattle) which is across from the 5th Avenue Theater. See the directions[1] for a quick primer on how to reach us from various locations across Puget Sound. There are plenty of locations to park in the area, including on the street. If you're looking for off-street parking, you can park in the Rainier Square garage which has an entrance on Union St. After 6PM, the building management restricts access to most floors. Our host is trying to take care of this, but if unsuccessful, they will station someone on the 1st floor near the elevator bank and 5th Avenue entrance to let people in. Worst case scenario, give the host a call on his cell phone[2] and he'll run down to let you in. Our hosts are providing a generous assortment of free sodas, fruit drinks, teas, and coffee, and also have some snacks. You definitely won't dehydrate here. See you there! [1] - http://www.whitepagesinc.com/locations: [2] - 206 354 7789 Colin From chesseditor at yahoo.com Sun Oct 14 09:48:16 2007 From: chesseditor at yahoo.com (Eric) Date: Sun, 14 Oct 2007 09:48:16 -0700 (PDT) Subject: SPUG: Perl classes in the Seattle area? Message-ID: <818798.65900.qm@web50310.mail.re2.yahoo.com> Does anyone know of any Perl classes in the Seattle area? I've taken several continuing ed computer courses at BCC, but they don't currently list any Perl classes. Thank you. Eric Harman ____________________________________________________________________________________ Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. http://mobile.yahoo.com/go?refer=1GNXIC From jsl at blarg.net Sun Oct 14 11:16:42 2007 From: jsl at blarg.net (Jim Ludwig) Date: Sun, 14 Oct 2007 11:16:42 -0700 Subject: SPUG: Perl classes in the Seattle area? In-Reply-To: <818798.65900.qm@web50310.mail.re2.yahoo.com> (message from Eric on Sun, 14 Oct 2007 09:48:16 -0700 (PDT)) Message-ID: Eric wrote: >> Does anyone know of any Perl classes in the >> Seattle area? I've taken several continuing ed >> computer courses at BCC, but they don't >> currently list any Perl classes. The University of Washington Extension offers a certificate program in Perl Programming: http://www.extension.washington.edu/ext/certificates/per/per_crs.asp Those are the only local Perl programming classes which come to mind. jim From andrew at sweger.net Sun Oct 14 12:56:16 2007 From: andrew at sweger.net (Andrew Sweger) Date: Sun, 14 Oct 2007 12:56:16 -0700 (PDT) Subject: SPUG: Perl classes in the Seattle area? In-Reply-To: <818798.65900.qm@web50310.mail.re2.yahoo.com> Message-ID: On Sun, 14 Oct 2007, Eric wrote: > Does anyone know of any Perl classes in the Seattle area? > I've taken several continuing ed computer courses at BCC, > but they don't currently list any Perl classes. I was going to point you toward Tim's TeachMePerl.com, but his server seems to be down. -- Andrew B. Sweger -- The great thing about multitasking is that several things can go wrong at once. From methylgrace at yahoo.com Mon Oct 15 10:02:32 2007 From: methylgrace at yahoo.com (grace hensley) Date: Mon, 15 Oct 2007 10:02:32 -0700 (PDT) Subject: SPUG: spug-list Digest, Vol 52, Issue 4 In-Reply-To: Message-ID: <814214.35458.qm@web36509.mail.mud.yahoo.com> Dear Eric- I took the UW Perl class mentioned, and loved it. It is a year-long (three quarters) course. If you have some perl, you can probably get into this quarter's class a little late. As I was a newbie, it was good for me to start from the beginning. Contact Doug Treder at dtreder at imdb.com. Good luck, Grace H. From tim at consultix-inc.com Tue Oct 16 09:35:47 2007 From: tim at consultix-inc.com (Tim Maher) Date: Tue, 16 Oct 2007 09:35:47 -0700 Subject: SPUG: Perl classes in the Seattle area? In-Reply-To: References: <818798.65900.qm@web50310.mail.re2.yahoo.com> Message-ID: <20071016163547.GA22603@jumpy.consultix-inc.com> On Sun, Oct 14, 2007 at 12:56:16PM -0700, Andrew Sweger wrote: > On Sun, 14 Oct 2007, Eric wrote: > > > Does anyone know of any Perl classes in the Seattle area? > > I've taken several continuing ed computer courses at BCC, > > but they don't currently list any Perl classes. > > I was going to point you toward Tim's TeachMePerl.com, but his server > seems to be down. > > Andrew B. Sweger My mighty i386 web server (running Linux since 1992!) is indeed down for the count, but likely to be replaced by this weekend. In the meantime, our schedule of Seattle public classes is shown below, and I'll be happy to answer questions about our training services. Consultix Seattle Classes, Fall 2007 ----------------------------------------- Perl Programming 10/22-10/24 3 Perl Modules, plus CGI 10/25-10/26 1.5 Shell Programming 11/12-11/14 3 UNIX/Linux Utilities 11/15-11/16 2 Minimal Perl 12/03 1 Basic OO Perl 12/04-12/05 2 Perl Hashes & Arrays 12/06 1 ----------------------------------------- -Tim *--------------------------------------------------------------------* | Tim Maher, PhD (206) 781-UNIX http://www.consultix-inc.com | | tim at ( Consultix-Inc, TeachMeLinux, or TeachMeUnix ) dot Com | | CLASSES: Contact us about our newly expanded tutoring program! | *-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--* | >> My "Minimal Perl for UNIX People" is an Amazon Best Seller! << | | # Download chapters, read reviews, and order at MinimalPerl.com # | *--------------------------------------------------------------------* From MichaelRWolf at att.net Sun Oct 21 18:29:58 2007 From: MichaelRWolf at att.net (Michael R. Wolf) Date: Sun, 21 Oct 2007 18:29:58 -0700 Subject: SPUG: Web Design Lecture -- Steve Krug -- Yes, Virginia, there is a perfect Web page Message-ID: <000e01c8144b$102c71b0$0300a8c0@mlaptop> This meeting may be of interest to web designers. Steve Krug is the featured speaker at October's Puget Sound SIGCHI meeting - 6 p.m. Thursday, Oct. 25, at Adobe in the Fremont area of Seattle. PS SIGCHI - The Puget Sound (local chapter of the ACM) SIGCHI (Special Interest Group on Computer Human Interaction) Steve Krug is a nationally known speaker, author, and web designer. His book ranks in the top 100 on Amazon, and in the top 5 of certain Computer & Internet subcategories. Here's the particulars about the Thursday meeting: http://pssigchi.acm.org/html/meetings/10_25_2007.html -- Michael R. Wolf All mammals learn by playing! MichaelRWolf at att.net From billw at onedrous.org Mon Oct 22 12:09:33 2007 From: billw at onedrous.org (Bill Warner) Date: Mon, 22 Oct 2007 12:09:33 -0700 (PDT) Subject: SPUG: forks.pm? Message-ID: Hi all, http://search.cpan.org/~rybskej/forks-0.26/lib/forks.pm Does anyone have any experience with the forks.pm module? I was part way into writing IPC for a forking application when I discovered this and realized this is just exactly what I want. It seems potentially complicated under the hood, though, so I'm wondering if it's mature. Thanks, -Bill From jobs-noreply at seattleperl.org Tue Oct 23 15:50:09 2007 From: jobs-noreply at seattleperl.org (SPUG Jobs) Date: Tue, 23 Oct 2007 15:50:09 -0700 (PDT) Subject: SPUG: Senior Software Dev, E-Commerce, Tukwila Message-ID: It is either contract to hire or direct full-time (depending on the situation of the candidate- leaving an full time job, looking for contract first, etc). Location: Tukwila (1 day per week), with telecommuting option the rest of the week. Sector- Ecommerce. Parsimony is developed in Perl and is responsible for all critical business operations including sales, ordering, fulfillment, inventory control, customer relationship management, statistics, website operations, time keeping, and accounting. Parsimony is responsible for the success of the company and enables others to do their job. Were looking to take Parsimony to the next level and are seeking a Senior Software Developer to get it there! Skills to have: Have strong business judgment. You will be interacting with senior level management to understand their problems and develop solutions that address their needs. If you understand the business value of the code you're writing, that will help immensely. Be proficient in Perl. Parsimony is written in Perl and at the time of this job description is almost 250,000 lines of Perl. Even if you choose to write something in another language, you'll need to be able to read everything that the original code base does and understand it. It does quite a lot as it turns out. Be familiar with SQL. Parsimony relies on an SQL database for its backend storage. You should be familiar enough with SQL or willing to pick it up. Be comfortable in a Linux environment. All software is developed in Linux. This is a startup and the environment is full of people willing to try new things. If you're looking to develop something and launch it in the same day without running it through the process cabal, then this Client is for you. High impact. Parsimony enables people throughout the company to do their job. As such, any development that you do is valued and helps drive the business even further. Solid foundation. Despite being a startup, there is an IT group in place that handles networking, data center, and desk-side. You won't be trouble shooting the basics which will allow you to focus on development. World class development team. The hiring bar this Client is high. The team consists of former Amazon employees as well as the former head of technology at Zumiez. You will be impressed. If all this sounds exciting to you - you should email Jason Henson at jhenson at comsys.com This is a contract to hire opportunity, the initial contract will be set for 1 year, with the understanding of possibly being hired on to the Client. There is the ability to telecommute for this opportunity spending 1-2 days in the Tukwila office. If qualified/interested in this position, please forward your resume to jhenson at comsys.com Jason T. Henson 11245 SE 6th St Suite 200 Bellevue, WA 98004 (425) 372-5134 Office (425) 372-5200 Fax jhenson at comsys.com Comsys IT Partners Ask me about our referral program From m3047 at inwa.net Tue Oct 23 21:58:38 2007 From: m3047 at inwa.net (Fred Morris) Date: Tue, 23 Oct 2007 21:58:38 -0700 Subject: SPUG: Senior Software Dev, E-Commerce, Tukwila In-Reply-To: References: Message-ID: <200710232158.38074.m3047@inwa.net> http://www.carpenters.org/misclassification/ On Tuesday 23 October 2007 15:50, SPUG Jobs wrote: > It is either contract to hire or direct full-time (depending on the > situation of the candidate- leaving an full time job, looking for contract > first, etc). > > Location: Tukwila (1 day per week), with telecommuting option the rest of > the week.