Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

RE: shortest

by Adam (Vicar)
on Sep 16, 2000 at 21:41 UTC ( [id://32821]=note: print w/replies, xml ) Need Help??


in reply to shortest

chop($_=<>);$a=chop()=>print qq'\n$a: ',$a&1?'odd':'even' while $_;
The code that was previously here has been replaced. It didn't work.

Replies are listed 'Best First'.
RE: RE: shortest
by myocom (Deacon) on Sep 17, 2000 at 02:50 UTC

    Perhaps it's me, but this doesn't seem to produce the expected results... It reports 'odd' for every digit except '1'.

      Yup. Actually Its worse then that. Try using a number with a zero in it. It stops at the zero. I guess I should have run it instead of just trusting that it would work. (I'll try to re-write it to make it work, and I'll post the current, bad, version here so that other's will understand the mistake.)
      chop($_=<>);print "\n$a: ",$a>>1?'odd':'even' while $a=chop; # The above snipit does not work. # When I posted it, I was thinking that the bit shift >> # would return the bit shifted off the end, but of course, # sanity eventualy prevailed and I realized that it does # not do that. (duh!) # Additionally, it has a bug in that it stops on the first # zero in the number. # # TEST TEST TEST!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://32821]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-03-29 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found