Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!decwrl!orc!mipos3!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: grep as apply (was Re: = @array?) Message-ID: <1990Feb23.190455.2653@iwarp.intel.com> Date: 23 Feb 90 19:04:55 GMT References: <15193@bfmny0.UU.NET> <100197@convex.convex.com> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 21 In-Reply-To: tchrist@convex.COM (Tom Christiansen) In article <100197@convex.convex.com>, tchrist@convex (Tom Christiansen) writes: | @array += 3; | | is nice (and I don't even know APL :-) but also unnecessary since you | can always use: | | grep($_ += 3, @array); Ahem. grep($_ += 3 || 1, @array); or you have just lost your zero elements. Remember, grep is both apply *and* select. Get that idiom *down*! $,=' ';print grep(s/^.//, sort "2another","4hacker,","1Just","3Perl"); -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/