Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,13 +1,26 @@
|
|||
{{implementation|Brainf***}}RCBF is a set of [[Brainf***]] compilers and interpreters written for Rosetta Code in a variety of languages. Below are links to each of the versions of RCBF.
|
||||
{{implementation|Brainf***}}RCBF is a set of [[Brainf***]] compilers and interpreters written for Rosetta Code in a variety of languages. <br>
|
||||
Below are links to each of the versions of RCBF.
|
||||
|
||||
An implementation need only properly implement the following instructions:
|
||||
* [ (left bracket)
|
||||
* ] (right bracket)
|
||||
* + (plus sign)
|
||||
* - (minus sign)
|
||||
* < (less than sign)
|
||||
* > (greater than sign)
|
||||
* , (comma)
|
||||
* . (period)
|
||||
{| class="wikitable"
|
||||
!Command
|
||||
!Description
|
||||
|-
|
||||
| style="text-align:center"| <code>></code> || Move the pointer to the right
|
||||
|-
|
||||
| style="text-align:center"| <code><</code> || Move the pointer to the left
|
||||
|-
|
||||
| style="text-align:center"| <code>+</code> || Increment the memory cell under the pointer
|
||||
|-
|
||||
| style="text-align:center"| <code>-</code> || Decrement the memory cell under the pointer
|
||||
|-
|
||||
| style="text-align:center"| <code>.</code> || Output the character signified by the cell at the pointer
|
||||
|-
|
||||
| style="text-align:center"| <code>,</code> || Input a character and store it in the cell at the pointer
|
||||
|-
|
||||
| style="text-align:center"| <code>[</code> || Jump past the matching <code>]</code> if the cell under the pointer is 0
|
||||
|-
|
||||
| style="text-align:center"| <code>]</code> || Jump back to the matching <code>[</code> if the cell under the pointer is nonzero
|
||||
|}
|
||||
Any cell size is allowed, EOF support is optional, as is whether you have bounded or unbounded memory.
|
||||
<br>
|
||||
|
|
|
|||
58
Task/Execute-Brain----/PicoLisp/execute-brain-----2.l
Normal file
58
Task/Execute-Brain----/PicoLisp/execute-brain-----2.l
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
(de brackets (Lst)
|
||||
(let S NIL
|
||||
(make
|
||||
(for (I . X) Lst
|
||||
(case X
|
||||
("[" (push 'S I))
|
||||
("]"
|
||||
(unless S (quit "Unbalanced '['"))
|
||||
(link (list (pop 'S) I)) ) ) )
|
||||
(when S (quit "Unbalanced ']'")) ) ) )
|
||||
|
||||
(de lupbra (Lst N)
|
||||
(find
|
||||
'((I)
|
||||
(or
|
||||
(= (car I) N)
|
||||
(= (cadr I) N) ) )
|
||||
Lst ) )
|
||||
|
||||
(de brain (L)
|
||||
(let
|
||||
(D (0)
|
||||
DH 1
|
||||
DL 1
|
||||
CH 1
|
||||
CL (length L)
|
||||
B (brackets L) )
|
||||
(loop
|
||||
(case (get L CH)
|
||||
(>
|
||||
(inc 'DH)
|
||||
(when (> DH DL)
|
||||
(setq D (insert DH D 0))
|
||||
(inc 'DL) ) )
|
||||
(<
|
||||
(dec 'DH)
|
||||
(when (< DH 1)
|
||||
(setq D (insert DH D 0))
|
||||
(inc 'DL)
|
||||
(one DH) ) )
|
||||
(+ (inc (nth D DH)))
|
||||
(- (dec (nth D DH)))
|
||||
(. (prin (char (get D DH))))
|
||||
("," (set (nth D DH) (char (key))))
|
||||
("["
|
||||
(when (=0 (get D DH))
|
||||
(setq CH (cadr (lupbra B CH))) ) )
|
||||
("]"
|
||||
(when (n0 (get D DH))
|
||||
(setq CH (car (lupbra B CH))) ) ) )
|
||||
(inc 'CH)
|
||||
(T (> CH CL)) ) ) )
|
||||
|
||||
(brain (chop ">+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
|
||||
>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.---
|
||||
-----.[-]>++++++++[<++++>- ]<+.[-]++++++++++." ) )
|
||||
|
||||
(bye)
|
||||
Loading…
Add table
Add a link
Reference in a new issue