Hypercubed / f-flat_node

F♭ (pronounced F-flat) is a toy language.
http://hypercubed.github.io/f-flat_node/
25 stars 4 forks source link
complex-numbers con concatenative-language programming-language stack toy-language

F♭

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

F♭ is a dynamically typed array-oriented concatenative language like Forth, Joy, and others. F♭ is meant to be used interactively, for example in a CLI REPL, like R or the command shell, or in a stack based calculator. This constraint dictates many of the language features.

Features

Flat functional concatenative language

Stack based

RPN

Dynamic Types

Arbitrary-precision decimal and complex number type.

JSON format is a valid f-flat programs.

Why?

Example

asciicast

Welcome to F♭ REPL Interpreter
F♭ Version 0.0.0 (C) 2000-2017 J. Harshbarger

f♭> 0.1 0.2 +
[ 0.3 ]

f♭> 0.3 =
[ true ]

f♭> clr
[]

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

f♭> 1 atan 4 *
[ 0+1i, 3.1415926535897932385 ]

f♭> * exp
[ -1-3.7356616720497115803e-20i ]

f♭> abs
[ 1 ]

f♭> clr
[]

f♭> "mersenne?" [ 2 swap ^ 1 - prime? ] ;
[]

f♭> 10 integers
[ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] ]

f♭> [ mersenne? ] map
[ [ true, true, true, false, true, false, true, false, false, false ] ]

f♭> clr
[]

f♭> 1000 !
[ 4.0238726007709377384e+2567 ]

f♭> clr
[]

f♭> i !
[ 0.49801566811835599106-0.15494982830181068731i ]

f♭> { first: "Manfred" }
[ { first: 'Manfred' } ]

f♭> { last: 'von Thun' }
[ { first: 'Manfred' }, { last: 'von Thun' } ]

f♭> +
[ { first: 'Manfred', last: 'von Thun' } ]

f♭> clr
[  ]

f♭> [ 1 2 3 ]
[ [ 1 2 3 ] ]

f♭> dup
[ [ 1 2 3 ] [ 1 2 3 ] ]

f♭> [ 2 * ]
[ [ 1 2 3 ] [ 1 2 3 ] [ 2 * ] ]

f♭> map
[ [ 1 2 3 ] [ 2 4 6 ] ]

f♭> +
[ [ 1 2 3 2 4 6 ] ]

f♭> +
[ [ 1 2 3 2 4 6 ] ]

f♭> clr
[  ]

f♭> dbl-sqr-cat: [ dup [ 2 * ] map + ] ;
[  ]

f♭> [ 1 2 3 ]
[ [ 1 2 3 ] ]

f♭>  dbl-sqr-cat
[ [ 1 2 3 2 4 6 ] ]

f♭> 'dbl-sqr-cat' see
[ '[ dup [ 2 * ] map + ]' ]

f♭> drop
[  ]

f♭> dbl-sqr-cat: expand
[ dup,2,*,*,Symbol((),swap,eval,dequote,+ ]

See other examples and guides here.

Project Goals

Influences

License

MIT