Name | Description |
---|---|
put | Print to standard output without a trailing newline.
put "Hello" put (* 3 4) put ["x = "(* 3 4)" y = "(+ 47 56)] |
nl | Print a newline to standard output.
nl |
say | Print to standard output with a trailing newline. |
fput | Print to a file handle without a trailing newline.
\fh=(fopen "result" "w") fput fh ["x = "(* 3 4)" y = "(+ 47 56)] |
fnl | Print a newline to a file handle.
fnl fh |
fsay | Print to a file handle with a trailing newline. |
fflush | Flush any pending output on a file handle.
fflush fh |
+ | (+ x y) is the sum of x and y. |
- | (- x y) is x minus y. |
* | (* x y) is the product of x and y. |
/ | (/ x y) is x divided by y. |
^ | (^ x y) is x raised to the power of y. |
xor | (xor x y) is the bitwise exclusive-or of x and y, where x and y are cast as long integer values. |
round | (round x) is x rounded to the nearest integer. |
trunc | (trunc x) is the integer part of x, with the fractional part dropped. |
abs | (abs x) is the absolute value of x. |
sqrt | (sqrt x) is the square root of x. |
exp | (exp x) is e raised to the power of x. |
log | (log x) is the natural logarithm of x (base e). |
sin | (sin x) is the trigonometric sine of x. |
cos | (cos x) is the cosine of x. |
pi | pi is the numeric constant π. |
lt | (lt x y) is true if x is less than y. The arguments must be both numbers or both strings. |
le | (le x y) is true if x is less than or equal to y. |
eq | (eq x y) is true if x is equal to y. |
ne | (ne x y) is true if x is not equal to y. |
ge | (ge x y) is true if x is greater than or equal to y. |
gt | (gt x y) is true if x is greater than y. |
I | The identity function. (I x) = x. |
T | The boolean value true. (T x y) = x. |
F | The boolean value false. (F x y) = y. |
@ | The fixpoint function, used for looping/recursion.
It is defined to satisfy this equivalence:
(@ f) = (f (@ f)) |
void | (void x) = void. This is the value returned by various functions when they cannot return a sensible result because their arguments are of the wrong type or otherwise erroneous. |
cons | (cons x xs) is the list consisting of the element x followed by the list xs. It is equivalent to the expression [x;xs]. |
null | null is the empty list. It is equivalent to the expression []. |
eval | (eval x f) = (f y), where y is the value of x. This is used to force the evaluation of x before proceeding. Ordinarily you can avoid the explicit use of eval by using the = syntax, because eval A (\x B) is equivalent to \x=A B . |
once | (once x) returns a value which defers the evaluation of x
until it's needed, and then it evaluates only once. Example:
seed_rand 0 \x=(once; put "(CALC)" rand) say x say xThe output is: (CALC)0.84018771715471 0.84018771715471If instead you had defined x as \x==(put "(CALC)" rand)) , then the output would be: (CALC)0.84018771715471 (CALC)0.394382926819093 |
later | (later x) returns a value which defers the evaluation of x
until it's needed. Most of the time you won't need this,
because you can use the == syntax to defer evaluation.
For example:
\talk==(say "hello") talk talkThat says "hello" twice. However, in some rare cases you may want to evaluate an expression and have it return a value whose evaluation must be deferred until later. |
is_void | (is_void x) is true if the value of x is void. |
is_good | (is_good x) is true if the value of x is not void. |
is_bool | (is_bool x) is true if the value of x is boolean, either T or F. |
is_list | (is_list x) is true if the value of x is a list, either null or (cons A B) |
. | (. x y) is the concatenation of strings x and y. |
length | (length x) is the length of string x. |
slice | (slice str pos len) is the substring of str starting at position pos and proceeding for len characters. Positions start at zero. It clips as necessary to stay within the bounds of str. Returns void if pos or len is negative. |
search | (search haystack needle offset) searches the string haystack for the first occurrence of the string needle, starting at the position offset. Returns the position of the first occurrence of needle, or void if not found. |
str_num | |
ord | |
chr | |
char_width | |
dirname | |
basename | |
is_str | |
num_str | |
is_num | |
is_tuple | |
arity | |
split_tuple | |
join_tuple | |
stdin | |
stdout | |
stderr | |
fopen | |
fclose | |
fgetc | |
fget | |
remove | |
is_newer | (is_newer file1 file2 returns true if file1 is newer than file2.
If either file is missing, it returns true, which makes the most sense for
caching operations.
It currently uses resolution only down to the whole second. I could potentially use nanosecond resolution, but that feature is not available on some older machines I use. |
flock_ex | (flock_ex fh) obtains an exclusive lock on the file handle, blocking as long as necessary. |
flock_sh | (flock_sh fh) obtains a shared lock on the file handle, blocking as long as necessary. |
flock_un | (flock_un fh) releases any locks on the file handle. |
readlink | (readlink file) calls readlink on the file name (See man 2 readlink). |
die | die exits immediately with exit code 1. |
argv | (argv n) returns the command line argument at position n, starting at 0. Returns void if n is less than 0 or greater than or equal to argc (the argument count). |
seed_rand | (seed_rand x) seeds the pseudo-random number generator with a number x between 0 and 1. It multiplies x by RAND_MAX and calls srand(3). |
rand | rand returns a pseudo-random number in the range 0 through 1. It calls rand(3) and divides by RAND_MAX. Note that these numbers are not cryptographically strong. |
use_standard | |
use_numbers | |
evaluate | |
evaluate_later | |
is_resolved | |
define | |
parse | |
parse_file | |
buf_new | |
buf_put | |
buf_get | |
readstr | |
sgetc | |
sget | |
var_new | |
var_get | |
var_put | |
limit_time | |
limit_memory | |
limit_stack | |
and | (and x y) is the logical and (conjunction) of boolean values x and y. |
not | (not x) is the logical negation of the boolean value x. |
or | (or x y) is the logical or (disjunction) of boolean values x and y. |
long_month_names | |
short_month_names | |
long_month_name | |
short_month_name | |
date_year | |
date_month | |
date_ymd | |
date_normal | |
date_quarter | |
month_ym | |
ym_month | |
ymd_date | |
month_before | |
month_after | |
ym_num_days | |
fill_day | |
day_after | |
date_end_prev_month | |
date_end_prev_quarter | |
date_end_prev_year | |
same_quarter | |
count_days | |
day_of_week | |
add_days | |
add_year | |
format_num | |
format_money | |
fexl_quote | |
uc | (uc x) is string x converted to all upper-case. |
lc | (lc x) is string x converted to all lower-case. |
fput_data | |
fput_list | |
put_data | |
put_list | |
hex_digit | |
hex_byte | |
hex_digit_to_dec | |
map_hex_to_raw_bytes | |
map_raw_bytes_to_hex | |
xor_hex | |
quote_ch | |
quote | |
colgroup | |
_tag | |
tag | |
tr | |
put_quote_data | |
put_quote_list | |
encode_percent | |
make_url | |
append | (append x y) is the list consisting of the elements of list x followed by the elements of list y. |
each | |
map | |
map_good | |
filter | |
reverse | (reverse x) is the list consisting of the elements of list x in reverse order. |
append_all | |
g_sort | |
unique | |
sort | |
fold | |
first | |
skip | |
list_sum | |
list_length | |
is_null | |
range | |
list_at | |
list_combine | |
column | |
shift | |
with | |
put_key | |
match_column | |
stream_values | |
get_list | |
to_str | |
get_str | |
list_str | |
str_bytes | |
str_chars | |
str_map | |
join | |
join_path | |
split | |
file_bytes | |
dirname | |
basename | |
path_under | |
dir_base | |
dir_local | |
TAB | |
NL | |
CR | |
LF | |
QU | |
cached | |
error | |
check | |
if | (if x y) is y if the condition x is true, otherwise I
(the identity function). It is used to evaluate y for its side-effects
if the condition is true, otherwise do nothing and proceed. It is defined
as:
\if=(\x\y x y I) |
use | |
use_standard | |
neg | (neg x) is the negative of number x. |
max | (max x y) is the maximum of numbers x and y. |
min | (min x y) is the minimum of numbers x and y. |
mod | (mod x n) is x modulo n.
It is defined as:
\mod=(\x\n - x; * n; trunc; / x n) |
tau | tau is the numeric constant 2*π. |
round2 | (round2 x) is x rounded to two decimal places. |
read_csv_chars | |
read_csv_file | |
read_ssv_chars | |
read_ssv_file |