Conditional operator in Python?
Tim Peters
tim.one at home.com
Fri Apr 6 01:57:32 EDT 2001
[Tim]
> hard-to-believe-that-semantically-significant-leading-zeroes-
> ever-seemed-like-"a-good-idea"-to-anyone-ly y'rs - tim
[Andrew Dalke]
> I do remember a letter to the editor in CACM
You shouldn't read that. CACM has become the National Enquirer of
comp.lang.python wannabes.
> a few years ago
Ah, OK -- nevermind. Just be sure you don't do it again.
> complaining about all the CS oriented computer science languages
> which didn't have a very useful feature in COBOL - a data type
> which understood that leading zeros are important for identifier
> numbers. Eg, 04/03/01 as a date or 001-453-23264 as a part number.
Hmm. 04/03/01 sure looks like 4/3 to me! What's the matter with strings?
They don't automagically have a "field" concept, or automagically verify that
assignments to fields contain data of the proper form, that's what. But it's
easy enough to write a Python factory function to produce classes with those
abilities, given a format description string (call it, oh, "picture").
OTOH, trailing zeroes can be useful in real-world arithmetic, and the REXX
language defines (e.g.) 4.73 - 1.03 to be 3.70, not 3.7, and way not
3.7000000000000002. I'm going to inflict that on Python someday.
> But that's neither here nor there, and since the thread
> in CACM went nowhere over several months of agumentative
> debate, perhaps I shouldn't have brought it up here.
Na, we routinely settle debates in one arrogant msg here that the trade rags
can't resolve in a decade. Just another part of c.l.py's job.
> So, umm, what do you think of Riemann-Stiljes integration
> as it pertains to mark&sweep garbage collection of boxed
> integers?
If you view time as the horizontal axis and bytes of boxed integers reclaimed
per instant as the vertical, the area under "the curve" is the cumulative
boxed-byte-seconds (BBS) reclaimed. The connection to R-S integration is
thus immediate, as "the curve" is really a discontinuous step function.
> How does that compare to Knuth's view?
Uncle Don and I have never disagreed on this point! Don't go looking to stir
up trouble, Andrew. If you must, join me in complaining about his C coding
style. Like:
t=TT-1; while (t) {
for (j=KK-1;j>0;j--) ul[j+j]=ul[j],u[j+j]=u[j]; /* "square" */
for (j=KK+KK-2;j>KK-LL;j-=2)
ul[KK+KK-1-j]=0.0,u[KK+KK-1-j]=u[j]-ul[j];
for (j=KK+KK-2;j>=KK;j--) if(ul[j]) {
ul[j-(KK-LL)]=ulp-ul[j-(KK-LL)],
u[j-(KK-LL)]=mod_sum(u[j-(KK-LL)],u[j]);
ul[j-KK]=ulp-ul[j-KK],u[j-KK]=mod_sum(u[j-KK],u[j]);
}
if (is_odd(s)) { /* "multiply by z" */
for (j=KK;j>0;j--) ul[j]=ul[j-1],u[j]=u[j-1];
ul[0]=ul[KK],u[0]=u[KK]; /* shift the buffer cyclically */
if (ul[KK]) ul[LL]=ulp-ul[LL],u[LL]=mod_sum(u[LL],u[KK]);
}
if (s) s>>=1; else t--;
}
for (j=0;j<LL;j++) ran_u[j+KK-LL]=u[j];
for (;j<KK;j++) ran_u[j-LL]=u[j];
taken from an especially impenetrable section of
http://www-cs-staff.stanford.edu/~uno/programs/rng-double.c
Time to rewrite the TAoCP series in Python, yes?
> And what if the cosmological constant is positive?
It appears that Perl 6 is determined to test that empirically.
> (Phew - swerved that conversation just in time!)
failing-to-see-the-connection-to-transfinite-cardinals-ly y'rs - tim
More information about the Python-list
mailing list