develooper Front page | perl.golf | Postings from August 2002

Re: this must be golfable

Thread Previous | Thread Next
From:
Phil Carmody
Date:
August 11, 2002 06:35
Subject:
Re: this must be golfable
Message ID:
20020811133459.71650.qmail@web21110.mail.yahoo.com
--- Eugene van der Pijll <E.C.vanderPijll@phys.uu.nl> wrote:
> And on 11 sextil 2002 said Phil Carmody:
> > One way:
> > 
> > perl -pe '$_=y/o |./10/d?pack(B8,$_):""'

I'd just realised 
    perl -pe '$_=y/o |./10/d&&pack(B8,$_)'
works.

>   perl -pe '$_=y/|.//d?pack(B8,$_):""'
>   perl -ne 'y/|.//d&&print pack B8,$_'

which implies that 
    perl -pe '$_=y/|.//d&&pack(B8,$_)'
should work too.
:-)

> In perl there are 256 binary digits.

<<<
Likewise, the "b" and "B" fields pack a string 
that many bits long.  Each byte of the
input field of pack() generates 1 bit of the 
result.  Each result bit is based on the
least-significant bit of the corresponding 
input byte, i.e., on "ord($byte)%2".  In par´┐Ż
ticular, bytes "0" and "1" generate bits 0 
and 1, as do bytes "\0" and "\1".
>>>

YLSNED.


So - the reverse direction seems fair game now. It can't be much
longer than
the above, can it?

Ta,
Phil



=====
-- 
The good Christian should beware of mathematicians, and all those who make 
empty prophecies. The danger already exists that the mathematicians have 
made a covenant with the devil to darken the spirit and to confine man in 
the bonds of Hell. -- Common mistranslation of St. Augustine (354-430)

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About