397 <- forked from: 405 <- 508 forked from: Shorten Brainf*ck Interpreter

by Susisu forked from 405 <- 508 forked from: Shorten Brainf*ck Interpreter (diff: 7)
397 <- forked from: 405 <- 508 forked from: Shorten Brainf*ck Interpreter

♥0 | Line 14 | Modified 2010-07-25 16:48:00 | MIT License
play

ActionScript3 source code

/**
 * Copyright Susisu ( http://wonderfl.net/user/Susisu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bpqi
 */

// forked from bkzen's 405 <- 508 forked from: Shorten Brainf*ck Interpreter
// forked from Susisu's Shorten Brainf*ck Interpreter
package{
    import flash.display.Sprite;
    import flash.text.TextField;
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="60")]
    public class BrainfuckInterpreter extends Sprite{
        public function BrainfuckInterpreter(){
            var code:String="++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.";
            var result:TextField=new TextField();
            result.text=b(code);
            addChild(result);
        }
        //Please shorten this!
        // 405 char!
        // 397
        public function b(c:*):*{var a:*=new Vector.<int>(9),r:*="",d:*=c.split(r),l:*=d.length,i:int,j:*,p:int,t:*,n:*,e:*="-+<>.][";for(;i<l;i++){n=1<<e.indexOf(d[i]),a[p]+=(n&3)&&(n|1)-2,p+=(n>>=2)&3&&(n|1)-2,r+=(n>>=2)&1?String.fromCharCode(a[p]):"",t=0;if((n>>=1)&&((n=(n|1)-2)>0?!a[p]:a[p]))for(j=i+n;n>0?j<l:j>=0;j+=n){if(d[j]==(n>0?"[":"]"))t++;if(d[j]==(n>0?"]":"[")&&!t--){i=j;break;}}}return r}
    }
}
        /*どうでもいいことを思いついたのでちょっと短く
        public function b(c:*):*
        {
            var a:*=new Vector.<int>(9),
            r:*="",d:*=c.split(r),
            l:*=d.length,i:int,
            j:*,p:int,t:*,n:*,
            e:*="-+<>.][";
            for(;i<l;i++)
            {
                n=1<<e.indexOf(d[i]),
                a[p]+=(n&3)&&(n|1)-2,
                p+=(n>>=2)&3&&(n|1)-2,
                r+=(n>>=2)&1?String.fromCharCode(a[p]):"",
                t=0;
                if((n>>=1)&&((n=(n|1)-2)>0?!a[p]:a[p]))
                for(j=i+n;n>0?j<l:j>=0;j+=n)
                {
                    if(d[j]==(n>0?"[":"]"))t++;
                    if(d[j]==(n>0?"]":"[")&&!t--)
                    {
                        i=j;break;
                    }
                }
             }
             return r
         }*/

Forked