Boron Function Reference

Version: 0.2.2
Date: Nov 20 2011

Contents

Function Groups

1   C Functions

These are the built-in functions implemented in C.

++

++ 'word

Arguments

'wordword!

Return

Value before increment.

Increments series or number bound to word.

--

-- 'word

Arguments

'wordword!

Return

Value before decrement.

Decrements series or number bound to word.

Abs

abs n

Arguments

nint!/decimal!/time!/bignum!

Return

Absolute value of n.

Add

add a b

Arguments

aint!/decimal!/vec3!
bint!/decimal!/vec3!/block!

Return

Sum of two numbers.

All

all tests

Arguments

testsblock!

Return

logic!

And

and a b

Arguments

alogic!/char!/int!
blogic!/char!/int!/block!

Return

Bitwise AND.

Any

any tests

Arguments

testsblock!

Return

Result of first true test or false.

Any-block?

any-block? value

Arguments

value

Return

True if value is a block type.

Any-word?

any-word? value

Arguments

value

Return

True if value is a block type.

Append

append series value /block

Arguments

seriesSeries or context!
value
/blockIf series and value are blocks, push value as a single item.

Return

Modified series or bound word!.

Atan

atan n

Arguments

nint!/decimal!

Return

Arc tangent of number.

Bind

bind words context

Arguments

wordsword!/block!
contextword!/context!

Return

Bound words

Binding?

binding? word

Arguments

wordword!

Return

context!/datatype!

Break

break

Return

NA

Exit from loop, while, foreach, or forall.

Catch

catch body /name word

Arguments

bodyblock!
/name
   wordword!/block!

Return

Result of block evaluation or thrown value.

Change

change series replacement /slice /part limit

Arguments

series
replacement
/sliceRemove slice and insert replacement.
/partRemove to limit and insert replacement.
   limit

Return

Series at end of change.

Change-dir

change-dir dir

Arguments

dirstring!/file!

Return

unset!

Set current working directory.

Checksum

checksum data /sha1 /crc16 /crc32

Arguments

databinary!/string!/file!
/sha1
/crc16IBM Bisync, USB
/crc32IEEE 802.3, MPEG-2

Return

int!/binary!

Computes sha1 checksum by default.

Clear

clear series

Arguments

seriesseries or none!

Return

Empty series or none!.

Erase to end of series.

Complement

complement value

Arguments

valuelogic!/char!/int!/binary!/bitset!

Return

Complemented value.

Compress

compress data

Arguments

datastring!/binary!

Return

binary!

Construct

construct object plan

Arguments

objectdatatype!/binary!
planblock!

Return

New value.

Make or append values with a detailed specification.

Copy

copy value /deep

Arguments

value
/deepIf value is a block, copy all sub-blocks.

Return

New value.

Cos

cos n

Arguments

nint!/decimal!

Return

Cosine of number.

Cpu-cycles

cpu-cycles loop block

Arguments

loopint! Number of times to evaluate block.
blockblock!

Return

int!/bignum!

Get the number of CPU cycles used to evaluate a block.

Current-dir

current-dir

Return

File! of current working directory.

Datatype?

datatype? value

Arguments

value

Return

True if value is a datatype!.

Each datatype has its own test function which is named the same as the type but ending with '?' rather than a '!'. For example, to test if a value is a string! use "string? val".

Decompress

decompress data

Arguments

databinary!

Return

string!/binary!

Delete

delete file

Arguments

filefile!/string!

Return

unset! or error thrown.

Difference

difference setA setB

Arguments

setAseries
setBseries

Return

New series that contains the elements of setA which are not in setB.

This function generates the set-theoretic difference, not the symmetric difference (the elements unique to both sets).

Dir?

dir? path

Arguments

pathfile!/string!

Return

logic! or none! if path does not exist.

Test if path is a directory.

Div

div a b

Arguments

aint!/decimal!/vec3!
bint!/decimal!/vec3!

Return

Quotient of a divided by b.

Do

do value

Arguments

value

Return

Result of value.

Does

does body

Arguments

bodyblock!

Return

func!

Create function which takes no arguments.

Either

either exp body-t body-f

Arguments

exp
body-tblock!
body-fblock!

Return

result of body-t if exp is true, or body-f if it is false.

Empty?

empty? series

Arguments

series

Return

logic!

Encode

encode type data /bom

Arguments

typeint!/word! 2, 16, 64, latin1, utf8, ucs2
databinary!/string!
/bomPrepend Unicode BOM for utf8 or ucs2 and return binary.

Return

String or binary with data converted to encoding type.

When data is a string! then the type must be a a word! and a new string is returned. If data is a binary! then the type must be an int! and the input value is returned with only the base indicator modified.

Encoding?

encoding? value

Arguments

value

Return

Encoding type word! or none! if val is not a string.

Equal?

equal? a b

Arguments

a
b

Return

True if two values are equivalent.

Execute

execute command /in input /out output

Arguments

commandstring!
/inProvide data via stdin.
   inputbinary!/string!
/outStore output of command.
   outputbinary!/string!

Return

return status of command

Runs an external program.

Exists?

exists? file

Arguments

filefile!/string!

Return

True if file or directory exists.

Exit

exit

Return

NA

Exit from function with result unset.

Find

find series value /last /case /part limit

Arguments

series
value
/last
/caseCase of characters in strings must match
/part
   limitseries/int!

Return

Position of value in series or none!.

First

first series

Arguments

seriesseries/coord!/vec3!

Return

First item in series or none!.

Forall

forall 'word body

Arguments

'wordword!
bodyblock!

Return

Result of body.

Foreach

foreach 'words series body

Arguments

'wordsword!/block!
series
bodyblock!

Return

Result of body.

Forever

forever body

Arguments

bodyblock!

Return

Result of body.

Repeat body until break or exception thrown.

Free

free resource

Arguments

resourceseries/port!

Return

unset!

Clear series and free its memory buffer or close port.

Func

func spec body

Arguments

specblock!
bodyblock!

Return

func!

Create function.

Get

get word

Arguments

wordword!/context!

Return

Value of word or block of values in context.

Getenv

getenv val

Arguments

valstring!

Return

string! or none!

Get operating system environment variable. :: getenv "PATH" == {/usr/local/bin:/usr/bin:/bin:/usr/games:/home/karl/bin}

Gt?

gt? a b

Arguments

a
b

Return

True if first value is greater than the second.

Halt

halt

Return

NA

Halt interpreter.

Hash

hash string

Arguments

stringword!/string!

Return

int!

Compute hash value from string (treated as lowercase).

Head?

head? series

Arguments

series

Return

logic!

If

if exp body

Arguments

exp
bodyblock!

Return

Result of body if exp is true, or none if it is false.

Ifn

ifn exp body

Arguments

exp
bodyblock!

Return

Result of body if exp is false, or none if it is true.

This is the same as "if not exp body".

In

in context word

Arguments

contextcontext!
wordword!

Return

Word bound to context or none!.

Index?

index? series

Arguments

seriesSeries or word.

Return

int!

Infuse

infuse block context

Arguments

blockblock!
contextword!/context!

Return

Modified block.

Replace words with their value in context.

Insert

insert series value /block /part limit

Arguments

series
value
/blockInsert block value as a single item.
/partInsert only a limited number of elements from value.
   limit

Return

Modified series.

Intersect

intersect setA setB

Arguments

setAseries
setBseries

Return

New series that contains only the elements common to both sets.

Last

last series

Arguments

series

Return

Last item in series or none! if empty.

Load

load file

Arguments

filefile!/string!/binary!

Return

block! or none! if file is empty.

Load file or serialized data with default bindings.

Loop

loop range body

Arguments

rangeint!/block!
bodyblock!

Return

Result of body.

Use 'break to terminate loop.

Lowercase

lowercase value

Arguments

valuechar!/string!/file!

Return

Value converted to lowercase.

Lt?

lt? a b

Arguments

a
b

Return

True if first value is less than the second.

Make

make prototype attributes

Arguments

prototypedatatype!/context!
attributes

Return

New value.

Make-dir

make-dir dir /all

Arguments

dirfile!/string!
/allMake any missing parent directories.

Return

unset!

Map

map 'word series body

Arguments

'wordword!
series
bodyblock!

Return

Modified series

Replace each element of series with result of body. Use 'break in body to terminate mapping.

Mark-sol

mark-sol value /block /clear

Arguments

value
/blockMark block rather than value at block position.
/clearClear start of line flag.

Return

Value with flag set.

Flag value so that it is printed at the start of a line.

Maximum

maximum a b

Arguments

a
b

Return

Greater of two values.

Minimum

minimum a b

Arguments

a
b

Return

Lesser of two values.

Mold

mold value /contents

Arguments

value
/contentsOmit the outer braces from block and context values.

Return

string!

Convert value to its serialized form.

Mul

mul a b

Arguments

aint!/decimal!/vec3!
bint!/decimal!/vec3!/block!

Return

Product of two numbers.

Ne?

ne? a b

Arguments

a
b

Return

True if two values are not equivalent.

Negate

negate value

Arguments

valueint!/decimal!/time!/bignum!/coord!/vec3!/bitset!

Return

Negated value.

Not

not value

Arguments

value

Return

Inverse logic! of value.

Now

now /date

Arguments

/dateReturn date! rather than time!

Return

time! or date!

Open

open device /read /write /new /nowait

Arguments

devicestring!/file!/block!
/readRead-only mode.
/writeWrite-only mode.
/newCreate empty file.
/nowaitNon-blocking reads.

Return

port!

Create port!.

Or

or a b

Arguments

alogic!/char!/int!
blogic!/char!/int!/block!

Return

Bitwise OR.

Parse

parse input rules /case

Arguments

inputstring!/block!
rulesblock!
/caseCharacter case must match when comparing strings.

Return

True if end of input reached.

Pick

pick series position

Arguments

series
positionint!

Return

Value at position.

Poke

poke series position value

Arguments

series
positionint!
value

Return

series.

Pop

pop series

Arguments

series

Return

Last item of series or none! if empty.

Removes last item from series and returns it.

Prin

prin value

Arguments

value

Return

unset!

Print reduced value without a trailing linefeed.

Print

print value

Arguments

value

Return

unset!

Print reduced value and a trailing linefeed.

Probe

probe value

Arguments

value

Return

value

Print value in its serialized form.

Quit

quit /return value

Arguments

/returnReturns value as exit status to operating system.
   valueNormally an int! between 0 and 255.

Return

NA

Exit interpreter.

Random

random data /seed

Arguments

datalogic!/int!/decimal!/coord!/vec3! or series.
/seedUse data as generator seed.

Return

Random number, series position, or seed if /seed option used.

If data is a number, then a number from 1 through data will be returned. A call to random/seed must be done before random values will be generated. If seed data is is not an int! then a clock-based seed is used.

Read

read source /text /into buffer

Arguments

sourcefile!/string!/port!
/text
/into
   bufferbinary!/string!

Return

binary!/string!/block!

Read binary! or UTF-8 string!. If /text or /into string! options are used then the file is read as UTF-8 data and carriage returns are filtered on Windows. If file is a directory, then a block containing filenames is returned.

Recycle

recycle

Return

NA

Run the garbage collector.

Reduce

reduce value

Arguments

value

Return

Reduced value.

If value is a block then a new block is created with values set to the evaluated results of the original.

Remove

remove series /slice /part number

Arguments

seriesseries or none!
/sliceRemove to end of slice.
/part
   numberint!

Return

series or none!

Remove element at series position.

Rename

rename file new-name

Arguments

filefile!/string!
new-namefile!/string!

Return

unset! or error thrown.

Reserve

reserve series size

Arguments

series
sizeNumber of elements to reserve.

Return

Series.

Return

return result

Arguments

result

Return

NA

Exit from function with result.

Reverse

reverse series /part number

Arguments

series
/part
   numberint!

Return

series

Reverse the order of elements in a series.

Same?

same? a b

Arguments

a
b

Return

True if two values are identical.

Save

save dest data

Arguments

destfile!/string!/port!
data

Return

unset!

Second

second series

Arguments

seriesseries/coord!/vec3!

Return

Second item in series or none!.

Select

select series match /last /case

Arguments

series
match
/lastSearch from end of series.
/caseCase of characters in strings must match

Return

Value after match or none! if match not found.

Serialize

serialize data

Arguments

datablock!

Return

binary!

Pack data into binary image for transport. Series positions, slices, and non-global word bindings are retained.

Series?

series? value

Arguments

value

Return

True if value is a series type.

Set

set words values

Arguments

wordsword!/lit-word!/block!
values

Return

unset!

If words and values are both a block! then each word in words is set to the corresponding value in values.

Sin

sin n

Arguments

nint!/decimal!

Return

Sine of number.

Size?

size? series

Arguments

series

Return

int!

Slice

slice series limit

Arguments

seriesseries or coord!
limitnone!/int!/coord!

Return

Adjusted slice.

Sort

sort set /case /group size

Arguments

setseries
/caseUse case-sensitive comparison with string types.
/groupCompare groups of elements by first value in group.
   sizeint!

Return

New series with sorted elements.

Sqrt

sqrt n

Arguments

nint!/decimal!

Return

Square root of number.

Sub

sub a b

Arguments

aint!/decimal!/vec3!
bint!/decimal!/vec3!/block!

Return

Difference of two numbers.

Swap

swap data /group size

Arguments

databinary!
/groupSpecify number of elements to reverse
   sizeint!

Return

Modified data.

Swap adjacent elements of a series.

Switch

switch value options

Arguments

value
optionsblock!

Return

Result of selected switch case.

If the size of the options block is odd, then the last value will be the default result.

Tail

tail series

Arguments

seriesSeries or port!

Return

End of series.

Terminate

terminate series value /dir

Arguments

seriesbinary!/string!
value
/dirCheck if end is '/' or '\'.

Return

Modified series.

Append value to series only if it does not already end with it.

Third

third series

Arguments

seriesseries/coord!/vec3!

Return

Third item in series or none!.

Throw

throw value /name

Arguments

value
/nameword

Return

NA

To-datatype

to-datatype value

Arguments

value

Return

New datatype!.

Convert value to datatype. Each datatype has its own convert function which is named the same as the type but starting with "to-". For example, to convert a value to a string! use "to-string val".

To-dec

to-dec number

Arguments

numberint!/bignum!

Return

Number shown as decimal.

To-hex

to-hex number

Arguments

numberchar!/int!/bignum!

Return

Number shown as hexidecimal.

To-text

to-text value

Arguments

value

Return

string!

Trim

trim string /indent /lines

Arguments

stringstring!
/indentRemove same amount of whitespace from start of all lines.
/linesRemove all newlines and extra whitespace.

Return

Modified string.

Try

try body

Arguments

bodyblock!

Return

Result of block evaluation or error.

Do body and catch any errors.

Type?

type? value

Arguments

value

Return

Datatype of value.

Union

union setA setB

Arguments

setAseries
setBseries

Return

New series that contains the distinct elements of both sets.

Unserialize

unserialize data

Arguments

databinary!

Return

Re-materialized block!.

Uppercase

uppercase value

Arguments

valuechar!/string!/file!

Return

Value converted to uppercase.

Value?

value? value

Arguments

value

Return

True unless value is an unset word.

Values-of

values-of context

Arguments

contextcontext!

Return

Block of values defined in context.

Wait

wait target

Arguments

targetint!/decimal!/time!/block!/port!

Return

Port ready for reading or none.

Wait for data on ports.

While

while exp body

Arguments

expblock!
bodyblock!

Return

false

Repeat body as long as exp is true.

Words-of

words-of context

Arguments

contextcontext!

Return

Block of words defined in context.

Write

write dest data /append /text

Arguments

destfile!/string!/port!
databinary!/string!/context!
/append
/textEmit new lines with carriage returns on Windows.

Return

unset!

Xor

xor a b

Arguments

alogic!/char!/int!
blogic!/char!/int!/block!

Return

Bitwise exclusive OR.

Zero?

zero? value

Arguments

value

Return

logic!

2   Helper Functions

These are the built-in func! functions and aliases.

Charset

charset spec

Arguments

specstring!

Return

New bitset!

Close

close port

Arguments

port

Return

unset!

Same as free.

Context

context spec

Arguments

specblock!

Return

New context!

Eq?

eq? a b

Arguments

a
b

Return

logic!

Same as equal?

Error

error message

Arguments

messagestring!

Return

Throws error.

Join

join a b

Arguments

a
b

Return

New series.

Concatenate a and b.

Rejoin

rejoin block

Arguments

block

Return

New series.

Reduce block and concatenate results.

Replace

replace series pat rep /all

Arguments

series
patPattern to look for.
repReplacement value.
/allReplace all occurances of the pattern, not just the first.

Return

Modified series at original position.

Split-path

split-path path

Arguments

pathfile!/string!

Return

Block with path and filename.

If no directory separator is found, then path (the first block item) will be none!.

Tail?

tail? series

Arguments

series

Return

logic!

Same as empty?

Term-dir

term-dir dir

Arguments

dirfile!/string!

Return

Modified dir

Ensure that the directory has a trailing slash.