Talk:Th

From Esolang
Jump to navigation Jump to search

Computational class

Since you added the tag "Unknown computational class", I propose the addition of control-flow instructions. Since the language as it stands now lacks these, it is definitely not turing-complete. An if-then-else instruction would be nice but due to the two-element atom restriction, only an if-then instruction would possible. Therefore, to make an if-then-else possible, I suggest couple([a],[b]) which returns a new type (the couple) of [a] and [b]. You might want to add syntactic sugar for couple([a],[b]) in the form of ([a],[b]) -- that is, without a function name.

Then, I suggest the instruction choose([cond],[couple]) where [cond] is something that will be evaluated to true or false, all numbers being true except 0, all strings being true except the empty string, nil being always false and a couple evaluating to true if both its items are true, and false otherwise. [couple] is the couple that will be chosen from based on [cond]: if [cond] is true, it returns the first element of [couple], else it returns the second. Also, a nand([a],[b]) instruction, returning the boolean NAND of the arguments casted to booleans), would be needed since then boolean logic can be performed (NAND logic).

Then, an if-then-else expression can be written: choose([conditional],couple([then-atom],[else-atom])), or with syntactic sugar, choose([conditional],([then-atom],[else-atom])).

Then, to enable looping to make this a turing-complete language, I suggest adding the instruction while([cond],[thing]), which evaluates [thing] an infinite number of times, checking before each execution whether [cond] is still true and stopping the loop otherwise. It might return nil.

Furthermore (I keep going on, sorry!), I would suggest specifying what all the functions return. I specified it for the ones I introduced here, and I propose that print returns nil and let returns the value of its right argument. +, -, *, / and read are clear already.

I believe with these additions, one might be able to convert an arbitrary BF program to Th code, making it turing-complete. T.J.S.1 (talk) 08:37, 12 June 2014 (UTC)