Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Re: Data structure challenge

by gjb (Vicar)
on Mar 17, 2004 at 22:13 UTC ( #337533=note: print w/replies, xml ) Need Help??

in reply to Re: Data structure challenge
in thread Data structure challenge

Wouldn't a pack(a[U*log_10(U)], 'z') do the trick?

Thanks Aristotle, I was too lazy/huried to check the correct syntax. The length of the string we want to allocate is N = U*ceil(log_10(U)), so I hoped pack(aN, '') would create a string of N '\0' characters using some low level memory allocation function. Unfortunately that doesn't seem to happen, the resulting string consists of N spaces, so there goes constant time... :(

Just my 2 cents, -gjb-

Replies are listed 'Best First'.
Re^3: Data structure challenge
by Aristotle (Chancellor) on Mar 18, 2004 at 18:08 UTC

    That isn't valid Perl. What exactly were you thinking of?

    I too though that if there's any way to achieve this, pack will be it, but there doesn't seem to be any pack format that would leave any part of the result string uninitialized.

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337533]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2018-07-17 23:40 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (381 votes). Check out past polls.