We can do better: FALSE

13

2

The interpreter executable for FALSE is 1020 bytes large. I think we can do better than THIS:

��Û������������������ˆ��È���ˆB0�ˇ*,x�r�pH@NÆ˝T,�g�Œ$F(FIÏa®.GÏu0C˙íp%NÆ˝ÿJÄg�™,@"$<��ÌNÆˇ‚JÄg�í*�"�$&<��a®NÆˇ÷,�"NÆˇ‹F�k�r‹Ç*BA˙¸C˙Ra�ºª∆j��Úp�@�0j�^@�[f(¸A˙�8¸+(¸`�ˇ¯&Ã`‘@�]f8¸Nu c êàTÄ1@ˇ˛`º@�aj�T@�!kÆ@�{fª∆j��ö�}fÙ`ö@�"fB(¸A˙�(¸`��� Lª∆j
�"g›`ÚRçB ���gB êàTÄ1@ˇ˛(¸"NÆ8¸¸L`�ˇT@�'fp�8¸+<(¿`�ˇ@@�`f
 $Uå8¿`�ˇ0A˙�ˆ∞(�fVàr�8ÿQ…ˇ¸`�ˇ2g��p–¡`‡A˙TC˙^a��∫ ��gB\ êáÄ��� ‰à(¸��Ú G!@�!@�A˙¬"$<��ÓNÆˇ‚(�g��$"�$&ñáNÆˇ–"NÆˇ‹"N,x�NÆ˛bap�NuaÓ`"JNÆ˝Np
Nu@�:j�˛ûr�¬¸�
@�0“Ä�0k�:jp�`‰8¸+<(¡`�˛d@�{j�˛®@�aÂH8¸AÏ8¿8¸+`�˛H  êà‚àSÄ8ÿQ»ˇ¸Nu�+ —ï�- ëï�* ¡Ì�*Ä�/ "É¿H¡*Å�.    `%ld�A˙ˇ˙"$
NƸFXç�! ]Nê�: ] ù�; ]+�= ∞ïW¿HÄH¿*Ä�? ] gNê�$�+�%�Xç�\ *≠�+@��@ -�+m��+U�*Ä�_�Dï�& ¡ï�| Åï�~�Fï�> ∞ï[¿HÄH¿*Ä�#L›�HÁ�¿ o�NêJùg WNê`Pè�,"$NÆ˛»�^"NÆ˛Œ+��¯ Âà+5���fl"NÆ˛ò"NÆ˛òa.out���Û���������������������È����KÔ˜�IÔ¯�(à,x�C˙�p%NÆ˝ÿJÄfNu,@NÆˇƒ,�NÆˇ *�`dos.library�"N,x�NÆ˛bp�Nu����Ú

Challenge

Write a FALSE interpreter in any language (doesn't have to be an executable!). As usual, shortest bytes wins. Make sure to try to get it under 1020 though :)

Language Specs

Literals

  • 123 put integer onto the stack
  • 'c put character code onto the stack

Stack

  • $ DUP
  • % DROP
  • \ SWAP
  • @ ROT
  • ø PICK (dup the nth stack item)

Arithmetic

  • + ADD
  • - SUBTRACT
  • * MULTIPLY
  • / DIVIDE
  • _ negate (negative numbers are entered 123_)
  • & bitwise AND
  • | bitwise OR
  • ~ bitwise NOT

Comparison (false is zero, true is all bits set (-1 or ~0) so that bitwise operators may be used)

  • > greater than
  • = equals

Lambdas and flow control (tests are for non-zero)

  • [...] define and put a lambda onto the stack
  • ! execute lambda
  • ? conditional execute: condition[true]?.
    • An if-else can be expressed as: condition$[\true\]?~[false]?
  • # while loop: [condition][body]#

Names

  • a-z put a reference to one of the 26 available variables onto the stack
  • : store into a variable
  • ; fetch from a variable

Input and Output

  • ^ read a character (-1 for end-of-input)
  • , write a character
  • "string" write a string (may contain embedded newlines)
  • . write top of stack as a decimal integer
  • ß flush buffered input/output

Other

  • {...} comment
  • whitespace is ignored, may be needed to separate consecutive integers

Examples

Copy file:

{ copy.f: copy file. usage: copy < infile > outfile  }

ß[^$1_=~][,]#

Factorial:

{ factorial program in false! }

[$1=~[$1-f;!*]?]f:          { fac() in false }

"calculate the factorial of [1..8]: "
ß^ß'0-$$0>~\8>|$
"result: "
~[\f;!.]?
["illegal input!"]?"
"

Primes to 100:

{ writes all prime numbers between 0 and 100 }

99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#

RK.

Posted 2015-09-06T21:20:23.040

Reputation: 497

Question was closed 2016-12-23T23:00:32.040

I think the code you posted might not be displaying correctly. It probably contains unprintable characters. Can you provide a link to where you got the code? – mbomb007 – 2015-09-06T21:26:00.273

Sure! http://strlen.com/files/lang/false/False12b.zip

– RK. – 2015-09-06T21:27:38.200

Please include the language specification of FALSE in your challenge to make the post self-contained. – Martin Ender – 2015-09-06T21:27:49.300

4It might be a good idea to specify a controlled subset of FALSE. The inline machinecode facility of the language would make this considerably harder to implement portably, and the IO primitives might also limit participation by users of some languages. – JohnE – 2015-09-06T21:33:25.633

What would you suggest removing? – RK. – 2015-09-06T21:35:25.537

@RK. The ` should be removed, as the inline machine code facility of the language would make this considerably harder to implement portably.(thanks @JohnE) The I/O can stay, imo. – clap – 2015-09-07T04:43:02.850

Can you give some example programs with explanations? – Beta Decay – 2015-09-07T07:16:22.147

I took some from the FALSE page on strlen. – RK. – 2015-09-07T13:19:06.147

@ConfusedMr_C I have no idea how your comment didn't show up in my notifications, but OK! – RK. – 2015-09-21T15:54:27.227

You say that a letter pushes a reference. What happens when you try to use an operator on a reference? E.g. 3 a + Or can we be guaranteed that variables always occur adjacent to a : or ;? – Conor O'Brien – 2016-12-23T19:19:03.323

2Also, can we be guaranteed to have a valid FALSE program as input? – Conor O'Brien – 2016-12-23T19:20:08.330

I want to do this is betaload, but it's too complex. Things like ' would need to recognize every character. That's too bad, because FALSE is really very similar to Underload.

– Esolanging Fruit – 2016-12-23T20:01:11.060

@ConorO'Brien I think math with references would be undefined behavior. Should we just edit the question and guarantee a valid input program so that the question can be on-topic? – mbomb007 – 2016-12-27T17:34:06.700

@mbomb007 idk, there are still more problems. E.g. how does the flush command work? – Conor O'Brien – 2016-12-27T20:40:07.097

@ConorO'Brien Python has sys.stdout.flush(). – mbomb007 – 2016-12-27T20:53:00.913

No answers