Jump to content

Execute Brain****: Difference between revisions

(Added Quackery.)
Line 5,485:
=={{header|Quackery}}==
 
<lang Quackery> [ stack ] is tape is switch.arg ( --> s[ )
[ stackswitch.arg put ] is input$switch ( x --> s )
 
[ stackswitch.arg release ] is otherwise ( is counter --> ( --> s )
 
[ switch.arg share != iff ]else[ done
[ stack ] is input$ ( --> s )
pokeotherwise tape put]'[ input$do put]done[ ] is getcharcase ( x --> )
 
[ dip witheachtuck releaseunrot ]poke swap ] is brainf***poketape ( $[ $n n --> [ n )</lang>
[ 1 counter tally counter share
tape share size = if
[ tape take 0 join tape put ] ] is stepright ( --> )
 
[ 1+ over size over = if [ tapedip take[ 0 join tape put] ] ] is stepright ( [ n --> [ n )
[ counter share 0 = iff
[ 0 tape take join tape put ]
else [ -1 counter tally ] ] is stepleft ( --> )
 
[ dup 0 = iff [ 0 rot join swap ] else [ 1 - ] ] is stepleft ( [ n --> [ n )
[ tape take counter share
2dup peek 1 + unrot poke tape put ] is increment ( --> )
 
[ 2dup peek 1 + unrotpoketape ] poke tape put ] is increment ( [ n --> [ n )
[ tape take counter share
2dup peek 1 - unrot poke tape put ] is decrement ( --> )
 
[ tape2dup sharepeek counter1 share- peek emitpoketape ] is print is decrement ( [ n --> [ n )
 
[ 2dup peek 1emit ] - unrot poke tape put ] is decrementprint ( [ n --> [ n )
 
[ input$temp take dup $ "" = iff 0 else behead
elseswap [temp -1put counter tallypoketape ] ] is stepleftgetchar ( [ n --> [ n )
tape take counter share
poke tape put input$ put ] is getchar ( --> )
[ tape share counter share2dup peek 0 = ] is zero ( [ n --> [ n b )
 
[ temp put $ "" swap witheach
[ tape share counter share peek 0 = ] is zero ( --> b )
[ doneswitch
[ char [> dropcase [ $ "stepright " join ] done
[char drop< case [ $ "stepleft " join ] done
[char drop+ case [ $ "increment " join ] done
[char drop- case [ $ "decrement " join ] done
[char drop. case [ $ "print " join ] done
[char drop, case [ $ "getchar " join ] done
char [ dropcase [ $ "[ zero if done " join ]
[char drop] case [ $ "zero until ] " join ]
otherwise ( ignore ) ] ]
0 nested 0 rot quackery temp release 2drop ] is brainf*** ( $ $ --> )</lang>
 
{{out}}
[ input$ put
' [ 0 ] tape put 0 counter put
$ "" swap witheach
[ dup char > = iff
[ drop $ "stepright " join ] done
dup char < = iff
[ drop $ "stepleft " join ] done
dup char + = iff
[ drop $ "increment " join ] done
dup char - = iff
[ drop $ "decrement " join ] done
dup char . = iff
[ drop $ "print " join ] done
dup char , = iff
[ drop $ "getchar " join ] done
dup char [ = iff
[ drop $ "[ zero if done " join ]
done
dup char ] = iff
[ drop $ "zero until ] " join ]
done
drop ]
quackery
' [ input$ tape counter ]
witheach release ] is brainf*** ( $ $ --> )</lang>
 
Testing <code>brainf***</code> in Quackery shell with Brainf*** code from [[Reverse a string#Brainf***]].
1,462

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.