merlyn@iwarp.intel.com (Randal Schwartz) (02/24/90)
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!"=/
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/24/90)
In article <1990Feb23.190455.2653@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: : 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*! Er, note that he's adding to @array in place. The selection only applies to the returned array value. If he'd said @array = grep($_ += 3, @array); then you'd be righter. : $,=' ';print grep(s/^.//, sort "2another","4hacker,","1Just","3Perl"); Pushed another Hal jerker, Larry
merlyn@iwarp.intel.com (Randal Schwartz) (02/24/90)
In article <7158@jpl-devvax.JPL.NASA.GOV>, lwall@jpl-devvax (Larry Wall) writes: | Er, note that he's adding to @array in place. The selection only applies | to the returned array value. If he'd said | | @array = grep($_ += 3, @array); | | then you'd be righter. Urrg. Does that mean I lose my Official Perl Hackers Club membership? I hope not! @a=split(/X*/," ,JPacehklnorstu");print@a[2,15,13,14,0,4,10,11,14,7,6,12,0,3,6,12,9,0,7,4,5,8,6,12,1]; -- /=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!"=/