this post was submitted on 19 Jun 2023
6 points (100.0% liked)

Esoteric Languages

240 readers
1 users here now

Icon base by Lorc under CC BY 3.0

founded 1 year ago
MODERATORS
 

https://esolangs.org/wiki/tiny

Tiny is a small integer RPN based language created by User:Ron.hudson. It is a console/character type interpretive programming language, in which all statements are either assignments or those that print quoted strings.

top 6 comments
sorted by: hot top controversial new old
[–] ProgramPhoenix 1 points 1 year ago* (last edited 1 year ago) (2 children)

Sounds like brainfuck with some extra arithmetic operations, but are there better loops?

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (2 children)

You can do a loop by storing the "@" program counter in the stack, Performing the body and the check for exit, if exit then jump to next step after the loop, pop the "$" and store in "$" and "@" to return to the top of the loop. After the loop clean the stack by poping the stored top of loop address and discarding it.

$ cat hiloop
10 "Print a greeting 10 times \n" '%02d'
20 [10] c
30 [@] $ "top of loop will be the line after this one \n"
40 [c] ? "  Hello World Greeting! \n"
50 [c 1 -] c
60 [c 0 = ! $ * ] $ @
70 "Done \n\n"  [$]
80 .

$ tiny hiloop
Print a greeting 10 times 
top of loop will be the line after this one 
10  Hello World Greeting! 
09  Hello World Greeting! 
08  Hello World Greeting! 
07  Hello World Greeting! 
06  Hello World Greeting! 
05  Hello World Greeting! 
04  Hello World Greeting! 
03  Hello World Greeting! 
02  Hello World Greeting! 
01  Hello World Greeting! 
Done 

Explained:  
10 print a header and set output format
20 initialize counter
30 Push the address of the next step (@) onto the stack ($) and print a line to mark the top of our loop.
40 print the greeting with a helpful counter number
50 decrement the counter
60 if the counter has not reached zero go to the top of the loop, restoring the loop-top back to the stack
70 if 60 falls thru we are done, clean up the stack by poping once.
80 end of program sentinel

I think it is much more expressive than BrainFuck.

[–] ProgramPhoenix 1 points 1 year ago (1 children)

btw. thanks for the example

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

You're Welcome, I have yet to figgure out a good way to do a top exit loop (where the loop act zero or more times) w/o using a flag or jumping to a specific line number to exit.

[–] ProgramPhoenix 1 points 1 year ago

i guess everything is much more expressive than brainfuck :D. But it reminded me of it when i first saw it

[–] ProgramPhoenix 1 points 1 year ago

OK i see now how it works. The page could may contain an example for loops resp. jumps.

load more comments
view more: next ›