Nandarin

From Esolang
Jump to: navigation, search

Language by User:Whtspc, based on nand-logic like his earlier language ferNANDo

Programs are made up of 'words' separated by spaces. All words are false by default (when an unknown word is encountered a boolean variable is made with the name of the word and is set to false), except for words starting with character t. Words starting with character 't' are always true, words starting with a 'f' are always false. (even after 'nanding' the word! (Nanding such words will not result in error, but will be overruled by their default value)). Nandarin is an experiment to make poetic (meta-)programs. Nandarin is not turing-complete.

commands

t x y z		- let x = y NAND z
f t x		- print x
f f t x y	- move program pointer to previous 'x'+1 if y is true
f f f t x y	- move program pointer to next 'x'+1 if y is true
f f f f		- halt

sample programs

Hello, World!

fernando two Helloworld

Truthmachine

replace the word input with 0 or 1,

Truthmachine input f f
f f f t ifzero 0 f f f t ifone 1
f t INPUT_IS_NOT_EQUAL_TO_0_OR_1 f f f f
ifzero f t 0 f f f f
ifone f t 1 f f t ifone t

in the first line this input is set to true,

in the next line program pointer jumps to label depending on which value is set to true,

the third line tackles a wrong input, displays error message and halts,

the line starting with ifzero prints 0 and halts,

the line starting with ifone prints 1 and jumps back to this printing instruction (forever).

Golfed version (THIS PROGRAM ISN'T WORKING! WE'LL BE BACK!)

does not handle wrong input

replace i with 0 or 1

t i f f f f f t a 0 b t 1 f f t b t a f t 0