F-Flat

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


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

Internal Core Words

[src]

@ (at)

returns the item at the specified index/key

seq x -> a

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

f♭> [ 1 2 3 ] -1 @
[ 3 ]
[src]
f♭> 'abc' 2 @
[ 'c' ]
[src]
f♭> [ 1 2 3 ] 1 @
[ 2 ]
[src]
f♭> 3.14159 2 @
[ 4 ]
[src]
f♭> { first: 'Manfred' last: 'von Thun' } 'first' @
[ 'Manfred' ]
[src]

choose

conditional (ternary) operator

bool a b -> c

f♭> true 1 2 choose
[ 1 ]
[src]

q<

moves the top of the stack to the tail of the queue

a ->

f♭> 1 2 4 q< 3
[ 1 2 3 4 ]
[src]

q>

moves the tail of the queue to the top of the stack

-> a

f♭> 1 2 q> 4 3
[ 1 2 3 4 ]
[src]

stack

replaces the stack with a quote containing the current stack

`a* -> [ a* ] )

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

unstack

push items in a quote to the stack without evaluation

[ A* ] -> A*

f♭> [ 1 2 * ] unstack
[ 1 2 * ]
[src]

clr

clears the stack

a* ->

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

depth

pushes the size of the current stack (number of items on the stack)

-> x

f♭> 0 1 2 depth
[ 0 1 2 3 ]
[src]

eval

evaluate quote or string

[A*] -> a*

f♭> [ 1 2 * ] eval
[ 2 ]
[src]

in

evalues the quote in a child environment

[A*] -> [a*]

f♭> [ 1 2 * ] in
[ [ 2 ] ]
[src]

in-catch

Evaluates the quotation in a child environment calls the second quotation in a child throws an error

[A*] [B*] -> [ {a*|b*} ]

[src]

throw

Throws an error

str ->

f♭> 'PC LOAD LETTER' throw
[ ]
[src]

send

pushes one element from stack to parent.

a ->

f♭> [ 1 2 3 send 4 ] in
[ 3 [ 1 2 4 ] ]
[src]

drop

drops the item on the bottom of the stack

a ->

> 1 2 3 drop
[ 1 2 ]
[src]

swap

swaps the items on the bottom of the stack

a b -> b c

> 1 2 3 swap
[ 1 3 2 ]
[src]

dup

duplicates the item on the bottom of the stack

a -> a a

> 1 2 3 dup
[ 1 2 3 3 ]
[src]

indexof

returns the position of the first occurrence of a specified value in a sequence

[a*] b -> x

f♭> [ '1' '2' '3' '4' ] '2' indexof
[ 1 ]
[src]

zip

[A*] [B*] -> [C*]

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

zipinto

[A*] [B*] [C*] -> [D*]

f♭> [ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ] zipinto
[ [ 1 4 7 8 9 2 5 7 8 9 3 6 7 8 9 ] ]
[src]

( (immediate quote)

pushes a quotation maker onto the stack

-> #(

[src]

) (immediate dequote)

collects stack items upto the last quote marker

#( a -> [ a ]

[src]

[ (lazy quote)

pushes a quotation maker onto the stack, increments depth

-> #(

[src]

] (lazy dequote)

decrements depth, collects stack items upto the last quote marker

#( A* -> [ A* ]

[src]

{ (immediate object quote)

pushes a quotation marker onto the stack

-> #(

[src]

} (immediate object dequote)

collects stack items upto the last quote marker, converts to an object

#( a* -> { A* }

[src]

template

converts a string to a string template

str -> [A*]

f♭> 'hello $(world)' template
[ [ '' 'hello ' + '(world)' eval string + '' + ] ]
[src]

sleep

wait x milliseconds

x ->

[src]

undo

restores the stack to state before previous eval

[src]

`match

str a -> bool

Matches a string a regex and returns an array containing the results of that search.

[src]

=~

a b -> bool

Returns a Boolean value that indicates whether or not the lhs matches the rhs.

[src]

_

-> #_

Match symbol

[src]