in reply to Brace For This
The array @[ has one arrayref for each of the characters of "Just Another Perl Hacker". You are generating the character index from the number of sub-arrayrefs and elements counted recursively.#!/usr/bin/perl -w use strict; @[=[ [ [[[[]]], [[]]], [[[]], []], [[]] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[[]]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[[]]] + ], [ [[[[]]], []] + ], [ [[[[]]], [[]]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]], []], [[[]]], [[]] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]], []], [[[]]], [[]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[[]]] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]], []] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[]] + ], [ [[[[]]], []] + ], [ [[[[]]], [[]]], [[[[]]]] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[]] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]], []], [[[]]] + ], [ [[[[]]], []] + ], [ [[[[]]], [[]]], [[[]], []] + ], [ [[[[]]], [[]]], [[[[]]], []], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]], []], [[]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[]]], [] + ], [ [[[[]]], [[]]], [[[[]]], []], [[[[]]]], [[]]], [[[[]], []], [[]] + ] ]; sub mysub { my $count = 0; $count += 2**mysub($_) for @{ shift() }; $count; } print chr mysub $_ for @{ @[[$[]}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Brace For This
by MeowChow (Vicar) on Apr 27, 2001 at 19:54 UTC | |
by jmcnamara (Monsignor) on Apr 29, 2001 at 18:47 UTC |