Wow! That is very cool. Although the -q flag used with any other option
isn't really a quine.
D:\>perl d:\camel.pl -qr | perl
syntax error at - line 2, near "."
Execution of - aborted due to compilation errors.
Perhaps this should be a future enhancement that camel.pl outputs a quine
(or null in the case of inverts( even if it's not the original camel code
:-)
Of course when I use my IDE to view the code, the syntax colouring is
completely wrong. Do any of you have IDE's that actually colour correctly
and can find the real matching brackets? [ BTW That was not an invitation
to start a religous war. ] Then again with code like this I wonder whether
Gimp would be a better IDE. :-)
Find the matching bracket is certainly is a non trivial function. Anyone
care to show me an elegant solution?
Alistair
> ----------------------------------------------------------------------
> Alistair McGlinchy, [EMAIL PROTECTED]
> Sizing and Performance, Central IT, ext. 5012, ph +44 20 7268-5012
> Marks and Spencer, 3 Longwalk Rd, Stockley Park, Uxbridge UB11 1AW, UK
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 23, 2002 9:41 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Thirty Two Camels
>
> Some brilliant golfing from Mtv Europe and Ronald J Kimball has
> allowed me to increase the number of camels from 32 to 128.
>
> There are now seven options:
>
> perl camel.pl normal camel
> perl camel.pl q quine (program prints itself)
> perl camel.pl m mirror (camel looking in the mirror)
> perl camel.pl i inverted camel
> perl camel.pl u upside-down camel
> perl camel.pl r rotated camel
> perl camel.pl h horizontally-squashed camel
> perl camel.pl v vertically-squashed camel
>
> The above options can be combined, for example:
>
> perl camel.pl hv small camel
>
> Here is the new generator program, gencamel.pl:
>
> use Acme::EyeDrops qw(sightly);
> my $src = <<'END_SRC_STR';
> $~=uc pop;open$%;chop(@~=<0>);$~=~R&&(@~=map{$-=$_+$_;
> join'',map/.{$-}(.)/,@~}$%..33);$|--&$~=~H&&next,
> $~!~Q&&y,!-~,#,,$~=~I&&y~ #~# ~,$~=~M&&($_=reverse),
> print$~=~V?/(.).?/g:$_,$/for$~=~U?reverse@~:@~
> END_SRC_STR
> $src =~ tr/\n//d;
> my $prog = sightly( { Regex => 1,
> Shape => 'camel',
> SourceString => $src } );
> my @a = split(/\n/, $prog);
> my $max = 0; length > $max and $max = length for @a;
> $_ .= ' ' x ($max - length) for @a; $\ = "\n";
> print ' ' x ($max+2); print " $_ " for @a; print ' ' x ($max+2);
>
> You can create camel.pl (shown below) with:
>
> perl gencamel.pl >camel.pl
>
> As always, any golfing improvements to:
>
> $~=uc pop;open$%;chop(@~=<0>);$~=~R&&(@~=map{$-=$_+$_;
> join'',map/.{$-}(.)/,@~}$%..33);$|--&$~=~H&&next,
> $~!~Q&&y,!-~,#,,$~=~I&&y~ #~# ~,$~=~M&&($_=reverse),
> print$~=~V?/(.).?/g:$_,$/for$~=~U?reverse@~:@~
>
> are most welcome.
>
> Enjoy,
> /-\ndrew
>
>
> camel.pl:
> (Save all text between ----- lines below, including
> leading and trailing space-filled lines)
> --------------------------------------------------------------------
>
> ''=~('('.'?'
> .'{'.( '`'|'%').("\["^
> '-').('`'| '!').('`'|',').'"'
> .'\\'.'$'. ('~'). '='.('['^'.').("\`"|
> '#').('{'^'[').('['^ '+').('`'|'/').(('[')^
> '+').';'.('`'|"\/").( '['^'+').('`'|'%').('`'
> |'.').'\\'.'$'.'%'. ';'.('`'|'#').('`'|"\(").(
> '`'|'/').('['^ '+').'('.'\\'.'@'.'~'.'='.'<'
> .('^'^('`'|'.' )).'>'.')'.';'.'\\'.'$'.'~'.'='.
> '~'.('{'^"\)"). '&'.'&'.'('.'\\'.'@'.'~'.'='.("\`"|
> '-').('`'|'!'). ('['^'+').'\\'.'{'.'\\'.'$'.'-'.('=').
> '\\'.'$'.('_'). '+'.'\\'.'$'.'_'.';'.('`'|'*').('`'|'/')
> .('`'|(')')).( '`'|'.')."'"."'".','.('`'|'-').('`'|'!').
> ('['^'+').'/'. '.'.'\\'.'{'.'\\'.'$'.'-'.'\\'.'}'.'('.'.'
> .')'.'/'.','.'\\'.'@'.'~'.'\\'.'}'.'\\'.'$'.'%'.'.'."\.".(
> '^'^('`'|'-')).('^'^('`'|'-')).')'.';'.'\\'.'$'.'|'.'-'.'-'
> .'&'.'\\'.'$'.'~'.'='.'~'.('`'^'(').'&'.'&'.('`'|'.').('`'
> |'%').('['^'#').('['^'/').','.'\\'.'$'.'~'.'!'.'~'.('{'^'*'
> ).'&'.'&'.('['^'"').','.'!'.'-'.'~'.','.'#'.','.','.('\\').
> '$'.'~'.'='.'~'.('`'^')').'&'.'&'.('['^'"').'~'.('{'^'[').
> '#'.'~'.'#'.('{'^'[').'~'.','.'\\'.'$'.'~'.'='."\~".( '`'
> ^'-').'&'.'&'.'('.'\\'.'$'.'_'.'='.('['^')').("\`"| '%'
> ).('['^'-').('`'|'%').('['^')').('['^'(') .(('`')| '%'
> ).')'.','.('['^'+').('['^')').('`'|')' ).('`'| '.'
> ).''. ('['^'/').'\\'.'$'.'~'.'='.'~' .("\{"^ '-'
> ).'?'.'/'.'('.'.'.')'.'.'.'?' ."\/".( '`'
> |("'")). "\:".'\\'. ('$'). ('_'). ((
> "\,")). '\\'.'$' .'/'.( ('`')| ((
> '&'))). ('`'|'/' ).''. ('['^ (
> ')')). '\\'.'$' .'~' .'='
> .'~'.( '{'^'.'). '?'. ('['
> ^')') .(('`')| '%') .''.
> ('['^ "\-").( '`'| '%')
> .''. ("\["^ ')') .''.
> ('[' ^(( '(') )).(
> '`'| '%' ).+ (((
> ((( ((( ((( (((
> ((( ((( ((( (((
> ((( ((( ((( ((
> (( '\\')) ))
> )) ))))) ))
> )) )))))))) ))
> ))) )))) ))))) ))
> ).+ ('@'). '~'. ':'
> .''. '\\'.'@' .(( '~')
> ).'"'. ('}').
> ')');$:= '.'^'~'
>
> --------------------------------------------------------------------
-----------------------------------------------------------------------
Registered Office:
Marks & Spencer p.l.c
Michael House, Baker Street,
London, W1U 8EP
Registered No. 214436 in England and Wales.
Telephone (020) 7935 4422
Facsimile (020) 7487 2670
www.marksandspencer.com
Please note that electronic mail may be monitored.
This e-mail is confidential. If you received it by mistake, please let us know and
then delete it from your system; you should not copy, disclose, or distribute its
contents to anyone nor act in reliance on this e-mail, as this is prohibited and may
be unlawful.
The registered office of Marks and Spencer Financial Services Limited, Marks and
Spencer Unit Trust Management Limited, Marks and Spencer Life Assurance Limited and
Marks and Spencer Savings and Investments Limited is Kings Meadow, Chester, CH99 9FB.