Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!wuarchive!bcm!convex!tchrist From: tchrist@convex.com (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: Arithmetic functions Message-ID: <1991Feb23.001155.3630@convex.com> Date: 23 Feb 91 00:11:55 GMT References: <1991Feb20.113935.14427@pronto.mh.nl> <2069019@bfmny0.BFM.COM> Reply-To: tchrist@convex.COM (Tom Christiansen) Distribution: comp Organization: CONVEX Software Development, Richardson, TX Lines: 41 From the keyboard of tneff@bfmny0.BFM.COM (Tom Neff): :> min(LIST) - numerically lowest of LIST :> max(LIST) - numerically highest of LIST : :I would not restrict this to numeric context. : : min("def","ghi","abc","jkl") : :might profitably return "abc". What's wrong with: $s = (sort(("def","ghi","abc","jkl")))[0]; or ($s) = sort(("def","ghi","abc","jkl")); and $n = (sort bynum ((3,5,7,1,-4)))[0]; or ($n) = sort bynum ((3,5,7,1,-4)); What's the motivation for making these and the others built-ins? Efficient numeric operations in perl? They're certainly pretty trivial to implement with using existing facilities. I remember once wanting an abs function, but I contented myself with: sub abs { ($_[0] < 0) ? -$_[0] : $_[0]; } I'm kind of dubious that the speedups you'd get by building these things in would be enough to make complex numeric calculations in perl very much more worthwhile than they are now (that is, not particularly). --tom -- "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." -- Doug Gwyn Tom Christiansen tchrist@convex.com convex!tchrist