F-Flat

F♭ (pronounced F-flat) is a toy language.


Project maintained by Hypercubed Hosted on GitHub Pages — Theme by mattgraham

Values

Numbers

Numeric literals in F♭ are arbitary precision decimals. The values may be input as integer or floats in binary, hexadecimal or octal form.

Complex numbers

F♭ supports complex values. Complex values are not input directly but created through expressions:

f♭> 3 i 2 * +
[ 3+2i ]

f♭> -1 sqrt
[ 3+2i 0+1i ]

The word complex can be used to convert a string or array to a complex value.

f♭> '3+2i' complex
[ 3+2i ]

f♭> [0,1] complex
[ 3+2i 0+1i ]

Later we will learn that words prefixed with a colon (:) are immediate words. That is they work inside lazy arrays.

f♭> [ '3+2i' complex ]
[ [ '3+2i' complex ] ]

f♭> ln
[ 2 ]

f♭> clr
[  ]

f♭> [ '3+2i' :complex ]
[ [ 3+2i ] ]

f♭> ln
[ 1 ]

Number-Like

F♭ supports infinity and nan literals. In addtion to -infinity as the result of a calculation.

f♭> infinity
[ Infinity ]

f♭> -1 *
[ -Infinity ]

f♭> nan
[ -Infinity NaN ]

Booleans and null

F♭ supports true, false and null values. A null is considered an unknown. When comparing boolean values the values are considered sorted in this order: false, null, true.

Strings

String literals in F♭ use single ('), double ("), and backtick quotes (`) where double quoted strings supports unicode escapes and backticks are string templates.

f♭> 'Hello world!'
[ 'Hello world!' ]

f♭> "\u0048\u0065\u006C\u006C\u006F\u0020\u0077\u006F\u0072\u006C\u0064"
[ 'Hello world!' 'Hello world' ]

f♭> clr `3 === $(1 2 +)`
[ '3 === 3' ]

Dates

Dates are input as strings and convered to date values usingthedate word.

f♭> '1/1/1990' date
[ Mon Jan 01 1990 00:00:00 GMT-0700 (MST) ]

As with complex values, strings can be converted to dates using the immediate version :date

f♭> [ '1/1/1990' :date ]
[ [ Mon Jan 01 1990 00:00:00 GMT-0700 (Mountain Standard Time) ] ]

Regex

Regular expressions values are converted from strings:

f♭> '/\.*/g' :regexp
[ /\.*/g ]

Keys

A key can be added to the stack without execution by either post-fixing the word with a colon (:) or converting a string to a key using a colon (:).

f♭> x:
[ x ]

f♭> 'y' :
[ x y ]