Version: | 0.2.2 |
---|---|
Date: | Nov 20 2011 |
Contents
Function Groups
These are the built-in functions implemented in C.
++ 'word
Arguments
'word | word! |
Return
Value before increment.
Increments series or number bound to word.
-- 'word
Arguments
'word | word! |
Return
Value before decrement.
Decrements series or number bound to word.
append series value /block
Arguments
series | Series or context! |
value | |
/block | If series and value are blocks, push value as a single item. |
Return
Modified series or bound word!.
catch body /name word
Arguments
body | block! |
/name | |
word | word!/block! |
Return
Result of block evaluation or thrown value.
change series replacement /slice /part limit
Arguments
series | |
replacement | |
/slice | Remove slice and insert replacement. |
/part | Remove to limit and insert replacement. |
limit |
Return
Series at end of change.
checksum data /sha1 /crc16 /crc32
Arguments
data | binary!/string!/file! |
/sha1 | |
/crc16 | IBM Bisync, USB |
/crc32 | IEEE 802.3, MPEG-2 |
Return
int!/binary!
Computes sha1 checksum by default.
clear series
Arguments
series | series or none! |
Return
Empty series or none!.
Erase to end of series.
complement value
Arguments
value | logic!/char!/int!/binary!/bitset! |
Return
Complemented value.
construct object plan
Arguments
object | datatype!/binary! |
plan | block! |
Return
New value.
Make or append values with a detailed specification.
copy value /deep
Arguments
value | |
/deep | If value is a block, copy all sub-blocks. |
Return
New value.
cpu-cycles loop block
Arguments
loop | int! Number of times to evaluate block. |
block | block! |
Return
int!/bignum!
Get the number of CPU cycles used to evaluate a block.
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".
difference setA setB
Arguments
setA | series |
setB | series |
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? path
Arguments
path | file!/string! |
Return
logic! or none! if path does not exist.
Test if path is a directory.
either exp body-t body-f
Arguments
exp | |
body-t | block! |
body-f | block! |
Return
result of body-t if exp is true, or body-f if it is false.
encode type data /bom
Arguments
type | int!/word! 2, 16, 64, latin1, utf8, ucs2 |
data | binary!/string! |
/bom | Prepend 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? value
Arguments
value |
Return
Encoding type word! or none! if val is not a string.
execute command /in input /out output
Arguments
command | string! |
/in | Provide data via stdin. |
input | binary!/string! |
/out | Store output of command. |
output | binary!/string! |
Return
return status of command
Runs an external program.
find series value /last /case /part limit
Arguments
series | |
value | |
/last | |
/case | Case of characters in strings must match |
/part | |
limit | series/int! |
Return
Position of value in series or none!.
foreach 'words series body
Arguments
'words | word!/block! |
series | |
body | block! |
Return
Result of body.
forever body
Arguments
body | block! |
Return
Result of body.
Repeat body until break or exception thrown.
free resource
Arguments
resource | series/port! |
Return
unset!
Clear series and free its memory buffer or close port.
getenv val
Arguments
val | string! |
Return
string! or none!
Get operating system environment variable. :: getenv "PATH" == {/usr/local/bin:/usr/bin:/bin:/usr/games:/home/karl/bin}
hash string
Arguments
string | word!/string! |
Return
int!
Compute hash value from string (treated as lowercase).
if exp body
Arguments
exp | |
body | block! |
Return
Result of body if exp is true, or none if it is false.
ifn exp body
Arguments
exp | |
body | block! |
Return
Result of body if exp is false, or none if it is true.
This is the same as "if not exp body".
infuse block context
Arguments
block | block! |
context | word!/context! |
Return
Modified block.
Replace words with their value in context.
insert series value /block /part limit
Arguments
series | |
value | |
/block | Insert block value as a single item. |
/part | Insert only a limited number of elements from value. |
limit |
Return
Modified series.
intersect setA setB
Arguments
setA | series |
setB | series |
Return
New series that contains only the elements common to both sets.
load file
Arguments
file | file!/string!/binary! |
Return
block! or none! if file is empty.
Load file or serialized data with default bindings.
loop range body
Arguments
range | int!/block! |
body | block! |
Return
Result of body.
Use 'break to terminate loop.
make-dir dir /all
Arguments
dir | file!/string! |
/all | Make any missing parent directories. |
Return
unset!
map 'word series body
Arguments
'word | word! |
series | |
body | block! |
Return
Modified series
Replace each element of series with result of body. Use 'break in body to terminate mapping.
mark-sol value /block /clear
Arguments
value | |
/block | Mark block rather than value at block position. |
/clear | Clear start of line flag. |
Return
Value with flag set.
Flag value so that it is printed at the start of a line.
mold value /contents
Arguments
value | |
/contents | Omit the outer braces from block and context values. |
Return
string!
Convert value to its serialized form.
mul a b
Arguments
a | int!/decimal!/vec3! |
b | int!/decimal!/vec3!/block! |
Return
Product of two numbers.
negate value
Arguments
value | int!/decimal!/time!/bignum!/coord!/vec3!/bitset! |
Return
Negated value.
open device /read /write /new /nowait
Arguments
device | string!/file!/block! |
/read | Read-only mode. |
/write | Write-only mode. |
/new | Create empty file. |
/nowait | Non-blocking reads. |
Return
port!
Create port!.
parse input rules /case
Arguments
input | string!/block! |
rules | block! |
/case | Character case must match when comparing strings. |
Return
True if end of input reached.
pop series
Arguments
series |
Return
Last item of series or none! if empty.
Removes last item from series and returns it.
quit /return value
Arguments
/return | Returns value as exit status to operating system. |
value | Normally an int! between 0 and 255. |
Return
NA
Exit interpreter.
random data /seed
Arguments
data | logic!/int!/decimal!/coord!/vec3! or series. |
/seed | Use 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 source /text /into buffer
Arguments
source | file!/string!/port! |
/text | |
/into | |
buffer | binary!/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.
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 series /slice /part number
Arguments
series | series or none! |
/slice | Remove to end of slice. |
/part | |
number | int! |
Return
series or none!
Remove element at series position.
rename file new-name
Arguments
file | file!/string! |
new-name | file!/string! |
Return
unset! or error thrown.
reverse series /part number
Arguments
series | |
/part | |
number | int! |
Return
series
Reverse the order of elements in a series.
select series match /last /case
Arguments
series | |
match | |
/last | Search from end of series. |
/case | Case of characters in strings must match |
Return
Value after match or none! if match not found.
serialize data
Arguments
data | block! |
Return
binary!
Pack data into binary image for transport. Series positions, slices, and non-global word bindings are retained.
set words values
Arguments
words | word!/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.
skip series offset /wrap
Arguments
series | Series or port! |
offset | logic!/int! |
/wrap | Cycle around to other end when new position is out of range. |
Return
Offset series.
If offset is a logic! type then the series will move to the next element if its value is true.
slice series limit
Arguments
series | series or coord! |
limit | none!/int!/coord! |
Return
Adjusted slice.
sort set /case /group size
Arguments
set | series |
/case | Use case-sensitive comparison with string types. |
/group | Compare groups of elements by first value in group. |
size | int! |
Return
New series with sorted elements.
sub a b
Arguments
a | int!/decimal!/vec3! |
b | int!/decimal!/vec3!/block! |
Return
Difference of two numbers.
swap data /group size
Arguments
data | binary! |
/group | Specify number of elements to reverse |
size | int! |
Return
Modified data.
Swap adjacent elements of a series.
switch value options
Arguments
value | |
options | block! |
Return
Result of selected switch case.
If the size of the options block is odd, then the last value will be the default result.
terminate series value /dir
Arguments
series | binary!/string! |
value | |
/dir | Check if end is '/' or '\'. |
Return
Modified series.
Append value to series only if it does not already end with it.
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".
trim string /indent /lines
Arguments
string | string! |
/indent | Remove same amount of whitespace from start of all lines. |
/lines | Remove all newlines and extra whitespace. |
Return
Modified string.
try body
Arguments
body | block! |
Return
Result of block evaluation or error.
Do body and catch any errors.
union setA setB
Arguments
setA | series |
setB | series |
Return
New series that contains the distinct elements of both sets.
wait target
Arguments
target | int!/decimal!/time!/block!/port! |
Return
Port ready for reading or none.
Wait for data on ports.
while exp body
Arguments
exp | block! |
body | block! |
Return
false
Repeat body as long as exp is true.
write dest data /append /text
Arguments
dest | file!/string!/port! |
data | binary!/string!/context! |
/append | |
/text | Emit new lines with carriage returns on Windows. |
Return
unset!
These are the built-in func! functions and aliases.
replace series pat rep /all
Arguments
series | |
pat | Pattern to look for. |
rep | Replacement value. |
/all | Replace all occurances of the pattern, not just the first. |
Return
Modified series at original position.
split-path path
Arguments
path | file!/string! |
Return
Block with path and filename.
If no directory separator is found, then path (the first block item) will be none!.
term-dir dir
Arguments
dir | file!/string! |
Return
Modified dir
Ensure that the directory has a trailing slash.