From Esolang
Jump to navigation Jump to search


A simple, functional esoteric programming language

The name is an acronym standing for "Not A B.f. Derivative."

Click here to go to the compiler's GitHub repo

Possibly going to be used as a basis for a functional graphical programming language.


Code is organized into modules and the module file directories can be passed into the compiler with -I<folder name> like headers are included into gcc.

Modules can either be nabd code or C++ headers with a corresponding object file (determined by file extension).

For reference, look at the standard library implementation as that is a C++ library


I've placed spaces, but they're not required

Instruction Description
$ _ $ Reads code from the module within dollar signs. If a module contains $, an escape sequence (\$) can be used
_ = _ > _ . Define a function with name (first _) and parameter (second _) returning an expression (last _). Polymorphism is allowed.
_ ( _ ) Call function (first _) with parameter (second _)
[ _ , _ , _ , ... ] Expression denoting a list with type first _ of comma separated sub expressions
'_' Expression denoting a string, just like in other programming languages
0d_# Expression denoting a decimal number.
0x_# Enter a number as hex
{ _ , _ } Expression denoting a tuple
! _ ? _ : _ If an expression converted to a number is > 0, then expression is first, otherwise second


  • String - a character string
  • Number - a decimal number
  • Tuple - two objects of different types packed together
  • List - a collection of objects of the same types

Note: all types can be converted to each other and will not error out. For instance, if a string is implicitly cast as a number, or the cast fails to convert it properly to a number, the first character will be converted to its ascii representation

Code is organized into functions, and the first function called is main, which takes a list of strings as an argument


Hello World:

$std$main=args>print('Hello, world!\n').

Truth Machine:


Or, more cleanly:

i1InfI0Stop = loop >
    ! loop ? i1Inf0Stop(print(0d1#)) : print(0d0#).
main = args >

Guess The Number:


startGame = randNum > [
    print('Guess a number btwn 0 and 10: '),
    guessFor({ randNum, 0d2# }),
    print('The answer was '),
    print('\nEnter \'1\' to play again or \'0\' to quit: '),
    ! parseNum(input(0d0#)) ?
        startGame(round(random({ 0d0#, 0d10# }))) :
        0d0# ].

guessFor = numAndAttempts > [
    print('Guess (integer): '),
    checkGuess({ parseNum(input(0d0#)), numAndAttempts }) ].

checkGuess = inputAndTupNumAtt >
    ! eq({
    }) ?
        print('You won!\n') :
        ! snd(snd(inputAndTupNumAtt)) ?
            ! gt({
            }) ? [
                print('Too high!\n'),
                }) ] : [
                print('Too low!\n'),
                }) ] :
            print('You lose!\n'). 

main = args >
        print('Welcome to Guess the Number!\n'),
        startGame(round(random({ 0d0#, 0d10# }))) ], 0d0# }).

Standard Library Functions

These are built-in functionality to add a lot to the language. It will be increased overtime.

Function Description Is Implemented?
print prints the value passed in to stdout and returns the string printed to console Yes
input read a string from stdin. Does nothing with parameter Yes
len returns the length of what's passed in. For tuples it's always 2, for numbers it's 1, and for lists and strings it's the actual length Yes
swap takes the first item of the list parameter and interprets it as a number and returns a copy of the second item with its first-parameter-th index replaced by the third element. If the index is outside the second parameter, then it simply returns the original parameter. Yes
parseNum don't just cast to a number, but try to actually parse a number out Yes
gt takes two inputs via a tuple, compares them, and returns 1 if param 1 > param 2 or -1 otherwise Yes
ls same as greater but with < Yes
eq same as greater but with = Yes
gte same as greater but with >= Yes
lse same as greater but with <= Yes
ne same as greater but with != Yes
seedRandom takes a dummy parameter and seeds a random given the current time. Returns 0 Yes
random given a tuple with range min to max, return a random number Yes
dup duplicates an item and creates a tuple of the two Yes
round returns input rounded to the nearest int Yes
floor returns input rounded down Yes
ceil returns input rounded up Yes
fst get first item of tuple Yes
snd get second item of tuple Yes
elem get first element of tuple and then get the item of the second tuple item Yes
inc increment a number Yes
dec decrement a number Yes