Article View: comp.lang.misc
Article #2887Re: standard extensions to programming languages
From: Tom Christiansen
Date: Mon, 04 Mar 1991 15:44
Date: Mon, 04 Mar 1991 15:44
30 lines
1559 bytes
1559 bytes
From the keyboard of peter@ficc.ferranti.com (Peter da Silva):
:In article <3439.27ca4e40@iccgcc.decnet.ab.com> herrickd@iccgcc.decnet.ab.com (daniel lance herrick) writes:
:> when what I want is
:> (q, r) = dividend divided by divisor
:
:Than you need a different programming language.
Pretty easy in perl: functions can return scalars or lists. It's
quite common to say:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
Which is nice -- I like the named variables. Others just stick it in
one array, convenient if you're doing stats on various files:
@statb = stat($filename);
For your division and remainder problem, you could just define a trivial
subroutine as follows:
sub divrem { ($_[0] / $_[1], $_[0] % $_[1]); }
and then say stuff like:
($q, $r) = &divrem(7,2);
--tom
Technical Details
Message-ID:
<1991Mar04.154439.10325@convex.com>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!newsReferences:
<1991Feb25.201406.18643@bingvaxu.cc.binghamton.edu> <3439.27ca4e40@iccgcc.decnet.ab.com> <.LR9UA4@xds13.ferranti.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!news From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.misc Subject: Re: standard extensions to programming languages Message-ID: <1991Mar04.154439.10325@convex.com> Date: 4 Mar 91 15:44:39 GMT References: <1991Feb25.201406.18643@bingvaxu.cc.binghamton.edu> <3439.27ca4e40@iccgcc.decnet.ab.com> <.LR9UA4@xds13.ferranti.com> Sender: news@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 30 Nntp-Posting-Host: pixel.convex.com