Execute Brain****: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) |
(Added Quackery.) |
||
Line 5,482: | Line 5,482: | ||
[[/Python|Implementation in Python]]. |
[[/Python|Implementation in Python]]. |
||
=={{header|Quackery}}== |
|||
<lang Quackery> [ stack ] is tape ( --> s ) |
|||
[ stack ] is counter ( --> s ) |
|||
[ stack ] is input$ ( --> s ) |
|||
[ 1 counter tally counter share |
|||
tape share size = if |
|||
[ tape take 0 join tape put ] ] is stepright ( --> ) |
|||
[ counter share 0 = iff |
|||
[ 0 tape take join tape put ] |
|||
else [ -1 counter tally ] ] is stepleft ( --> ) |
|||
[ tape take counter share |
|||
2dup peek 1 + unrot poke tape put ] is increment ( --> ) |
|||
[ tape take counter share |
|||
2dup peek 1 - unrot poke tape put ] is decrement ( --> ) |
|||
[ tape share counter share peek emit ] is print ( --> ) |
|||
[ input$ take dup $ "" = iff 0 else behead |
|||
tape take counter share |
|||
poke tape put input$ put ] is getchar ( --> ) |
|||
[ tape share counter share peek 0 = ] is zero ( --> b ) |
|||
[ 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***]]. |
|||
<pre>/O> $ "[-]>,[>,]<[.<]" $ "!sdrawkcab siht tnirP" brainf*** |
|||
... |
|||
Print this backwards!</pre> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |