in reply to Interpreted

I offer this optimization:
tr/[]<>.,+-//cd; s/(([+-])\2*)/P$2=@{[length$1]};/g; s/(([<>])\2*)/Q@{[('+','-')[$2eq'<']]}=@{[length$1]};/g; s/\./print chrP;/g; s/,/P=ord getc;/g; s/\[/while(P){/g; s/]/}/g; s/P/\$m[Q]/g; s/Q/\$p/g;


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re: Re: Interpreted
by iamcal (Friar) on Apr 20, 2001 at 14:02 UTC
    very nice. slows the 'compiler' a little but a vast improvement to the generated code. since all the bf programs i've seen use long runs of +'s and -'s for data and >'s and <'s for finding/storing this makes a HUGE difference for larger scripts. The only optimisaion (golf?) i can offer is changing the tr/// to a y/// :)