Skip to content

Quick Start

Jayson Harshbarger edited this page Apr 17, 2016 · 8 revisions

F♭ is an experiment. Currently, it can be only be used by cloning the github repo.

git clone https://github.com/Hypercubed/f-flat_node.git
cd f-flat_node
npm install
npm start

In the following examples it is assumed the stack is clear

The stack

f♭> 1
[ 1 ]

f♭> 2 3
[ 1 2 3 ]

f♭> swap
[ 1 3 2 ]

f♭> drop
[ 1 3 ]

f♭> dup
[ 1 3 3 ]

f♭> clr
[  ]

Undo

f♭> 2 5
[ 2 5 ]

f♭> * 1 +
[ 11 ]

f♭> !
[ 39916800 ]

f♭> undo
[ 11 ]

f♭> undo
[ 2 5 ]

f♭> undo
[  ]

Math

f♭> 1 1 +
[ 2 ]
f♭> 2 dup *
[ 4 ]
f♭> -2 sqrt
[ 0+1.4142135623730950488i ]

Definitions

f♭> sqr: [ dup * ] ;
[  ]

f♭> cube: [ dup dup * * ] ;
[  ]

f♭> 2 sqr
[ 4 ]

f♭> 3 cube
[ 4 27 ]

f♭> i sqr
[ 4 27 -1 ]

Print

f♭> "Hello" println
Hello
[  ]

Conditions

f♭> 1 1 +
[ 2 ]

f♭> 2 =
[ true ]

f♭> "One plus one is two"
[ true 'One plus one is two' ]

f♭> 'One plus one is not two'
[ true 'One plus one is two' 'One plus one is not two' ]

f♭> choose
[ 'One plus one is two' ]

Lists

f♭> [ 20 30 40 ]
[ [ 20 30 40 ] ]

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

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

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

f♭> undo
[ [ 1 2 3 ] [ 4 5 6 ] ]

f♭> <<
[ [ 1 2 3 [ 4 5 6 ] ] ]

f♭> undo
[ [ 1 2 3 ] [ 4 5 6 ] ]

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

Maps

f♭> { hello: "a greeting" }
[ { hello: 'a greeting' } ]

f♭> { goodbye: "a parting" }
[ { hello: 'a greeting' } { goodbye: 'a parting' } ]

f♭> <<
[ { hello: 'a greeting' goodbye: 'a parting' } ]

f♭> @hello
[ 'a greeting' ]

Strings

f♭> "foo"
[ 'foo' ]

f♭> "bar"
[ 'foo' 'bar' ]

f♭> +
[ 'foobar' ]

f♭> 0 @
[ 'f' ]
f♭> "this is a test"
[ 'this is a test' ]

f♭> " "
[ 'this is a test' ' ' ]

f♭> /
[ [ 'this' 'is' 'a' 'test' ] ]
f♭> "this is a test"
[ 'this is a test' ]

f♭> 2 10 slice
[ 'is is a ' ]