We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Ringfuck

From Esolang
Jump to navigation Jump to search
Not to be confused with Ryan Hornby's 2023 SIGBOVIK submission.

Ringfuck is a brainfuck extension/derivative whose memory is a stack of concentric rings.

Instructions

Command Description
> Turns the current ring one cell clockwise
< Turns the current ring one cell anticlockwise
( Moves the head inward one ring; ignored on ring 0
) Moves the head outward one ring, creating it if needed
* Turns every ring one cell clockwise
+ Increments the cell at twelve o'clock
- Decrements it
[ Jumps past the matching ] if that cell is 0
] Jumps back to the matching [ if it is not 0
. Outputs the cell as a character
, Reads one byte into the cell; 0 at end of input
: Outputs the cell as a decimal number
# Debug: dumps every ring and its angle

Examples

Mini-interpreter

import sys
P=2,3,5,7,11,13,17,19,23,29,31,37
c=open(sys.argv[1]).read();J={};s=[]
for k,v in enumerate(c):
	if'['==v:s+=k,
	if']'==v:a=s.pop();J[a]=k;J[k]=a
M={};T=[0]*12;S=h=i=0;I=sys.stdin.buffer.read()
while i<len(c):
	o=c[i];x=h,(T[h]+S)%P[h];V=M.get(x,0)
	if o in'<>':T[h]+=o=='>'or-1
	if o=='(':h-=h>0
	if o==')':h+=h<11
	if o=='*':S+=1
	if o in'+-':M[x]=V+(o=='+'or-1)
	if o in'.:':print(end=(chr(V%256),str(V))[o==':'])
	if o==',':M[x]=(I+b'\0')[0];I=I[1:]
	if o in'[]'and(V!=0)==(o==']'):i=J[i]
	i+=1

cat

,[.,]

"Hello World!"

++++++++[)++++[)++)+++)+++)+((((-])+)+)-))+[(](-])).)---.+++++++..+++.)).(-.(.+++.------.--------.))+.)++.

FizzBuzz

)+)+))++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++[-*+((([-)))>+>>>+<<<<(((])))>>>>[-(((
+)))](([-))<<+>>+((]))[-((+))]<[-]+<<[->>>>+++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++
+++++.+++++++++++++++++..-----------------------------------------------
------------------------------------------------------------------------
---<<[-]<<]>[->>>+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++.+++++..-
------------------------------------------------------------------------
-------------------------------------------------<<[-]<]>[-<<<:>>>]>>+++
+++++++.---------->>>>>]

Primes

+)+)+)+*)+*<+*<+*<+*<+*<+*<+*<+*<+*<+<++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++[-*+>[-]+(((([-))))>+>+<<((((]))))>>[-((((+))))]<[-<[-]>]((([-)))+>+
<(((])))>[-(((+)))]<[-<[-]>](([-))+>+<((]))>[-((+))]<[-<[-]>]([-)+>+<(])
>[-(+)]<[-<[-]>]<[-<:>>>>++++++++++.----------<<<]<<]

Collatz

))))>>>>+[[-]>[-],[----------[--------------------------------------<<<<
<[-<<<<<+>>>>>]<<<<<[->>>>>++++++++++<<<<<]<[-<<<<<+>>>>>]<+>]]<]+[[-]<<
<<:>++++++++++.----------<[->+>[-<->>+<]<[->+<]<]>+>[-<->>[>+<[-<<<+++++
+>>>]]<<<++++>>]<[->>[>+<[-<<<+>>>]]<<]>>>]

Truth Machine

)
,>++++++[<-------->-]
<[>+++++++[>+++++++<-]>[.]]
>++++++[>++++++++<-]>.

Fibonacci

))>>+<<++++++++++++++++++++[->:<<++++++++++.----------<<[->+<<+>]<[->+<]
>>[-<<+>>]>>]

Computational class

As as an extension of brainfuck (and derivative) ringfuck is Turing complete.

See also