esolang

dirac

FALSE grown up. Lambdas, scopes and raw memory, all spelled in one or two characters.

Palaiologos, 2022 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: 63=?

The idea

Palaiologos made dirac in early 2022, after FALSE. The name stands for Delightfully Intricate Reasonably Amazing Calculator. Like FALSE it is a stack of integers with lambdas in brackets, but it adds lexical scopes, loops that take lambdas, and blocks of memory to read and write byte by byte.

Read the story

Most commands are two characters. The first letter names a family, I for input and output, M for memory, B for bits, C for comparisons and F for flow, and the second picks the command. Numbers are signed and 64 bits wide, which the specification's own test measures.

The machine

CommandDoes
12 'A H3FF "text"Push a number, a character code, a hex number, or a string from the back after a 0
+ - * / % B| B& B^ B~ B< B>Arithmetic and bits
C> C< C>= C<= C= C!Compare, pushing 1 or 0
# $ ^ @ &210Duplicate, drop, swap, copy the n-th, rebuild the top
name ; : ~; ~:Push a variable, set it, read it, in this scope or the outermost one
[ ] ! ?Push a lambda, run it, run it if a value is true
F# F~ F$ F%While, do while, if else, range loop
I. I: I< I, I; I>Read or print a character, a decimal or a hex number
M< M> M. M, M: M;Allocate and free a block, read and write bytes or qwords

A backquote, ` , reverses the top three. F% takes a start, an end, a step and a lambda, and gives the lambda each counter from the start up to the end, without the end itself.

Example

The first example.

The first example. 2 plus 2 plus the code of 0 is 52, and OR 15 makes 63, which prints as a number and as the character ?.

The factorial runs a range loop from 1 to 11 that multiplies each counter in.

Expected: 3628800

The Fibonacci function prints 0 and 1, then lets F% add the last two numbers each round.

Expected: 0 1 1 2 3 5 8 13 21 34 55

The scope test from the specification sets a to 0, then sets it to 1 from two lambdas deeper with ~;, which reaches the outermost a.

Expected: Ok

Patterns it teaches

Further

Cell-based

Stack-based

Write your own in Run Convert a program from dirac

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: dirac.

Command line

shib run dirac -e '2 2+'\''0+H0F B|#I;'\''=I,I,'
shib manual dirac

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/dirac.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org