F♭ (pronounced F-flat) is a toy language.
Numeric literals in F♭ are arbitary precision decimals. The values may be input as integer or floats in binary, hexadecimal or octal form.
3, 3.1415 ,.14)-3, +3, +3.1415, -3.1415, +.14, -.14)0, -0)8e5, -123e-2)0xDEAD, -0xBEEF)0xDEAD.BEEF, -0xDEAD.BEEF)0x1.1p5, -0x1.1p-2, 0x1.921FB4D12D84Ap+1)10%)10_001, 0xDEAD_BEEF)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 ]
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 ]
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.
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 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) ] ]
Regular expressions values are converted from strings:
f♭> '/\.*/g' :regexp
[ /\.*/g ]
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 ]