Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim) Newsgroups: comp.lang.perl Subject: Re: Even Parity Table Generation Message-ID: <122374@uunet.UU.NET> Date: 11 Feb 91 21:20:34 GMT References: <121817@uunet.UU.NET> <11387@jpl-devvax.JPL.NASA.GOV> Organization: UUNET Communications Services, Falls Church, VA Lines: 38 In article <11387@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >In article <121817@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: >: I hereby request another function: chr(), the opposite of ord(). >: Either that, or get rid of ord. > >How 'bout: > > sub chr {sprintf("%c",$_[0]);} Yes, I know that it can be done that way, or I can use pack, as I did. I suppose I can use use vec. Which is most efficient? However, I would rather have one primitive to SAY WHAT I MEAN rather than having to simulate it from a subroutine call and a more general primitive. I have heard that ord preceded pack/unpack and that's why it's there. >: Anyway, here it is: >[recursive solution omitted] > >I'd just say: > >[iterative solution deleted] Well, if we want to slice bits, how about: #!/usr/bin/perl for (0 .. 127) { $x = $_; $_ ^= $_>>4; $_ ^= $_>>2; $_ ^= $_>>1; printf "%x %x\n", $x, $x ^ (($_ & 1) << 7); } -- Root Boy Jim Cottrell I got a head full of ideas They're driving me insane