Chapter 4:
Basic Primitives
Daisy primitives always return an existing value or a new value; they
don't return results by storing the results in data passed to them (aka
passing by reference). Unlike in languages such as C, which don't
provide built-in compound types, Daisy can return multiple values as a
list or stream.
Arithmetic and Logical Operations
Daisy provides a fairly standard set of operations on numbers. If any
argument supplied is not a number, or is a number of an inappropriate
type, the system returns a non-numeric operand erron.
Bitwise Logic Operations
not:N => bitwise NOT of N
and:[N0 N1] => bitwise AND of N0 and N1
or:[N0 N1] => bitwise OR of N0 and N1
xor:[N0 N1] => bitwise XOR of N0 and N1
Standard boolean primitives that operate bitwise (bit-by-bit) on integer
numeric operands.
Shift Operations
lsh:[N0 N1] => N0 shifted left by N1 bits
rsh:[N0 N1] => N0 shifted right by N1 bits
arsh:[N0 N1] => N0 shifted right by N1 bits, sign-extending as necessary
Bit-shifting primitives. Operands must be integers.
Arithmetic Operations
neg:N => negation of N (- N)
inv:N => inverse of N (1 / N)
inc:N => increment N (N + 1)
dcr:N => decrement N (N - 1)
add:[N0 N1] => addition of N0 and N1 (N0 + N1)
sub:[N0 N1] => subtraction N0 and N1 (N0 - N1)
mpy:[N0 N1] => multiplication of N0 and N1 (N0 * N1)
div:[N0 N1] => division of N0 by N1 (N0 / N1)
rem:[N0 N1] => remainder of N0 divided by N1 (N0 modulo N1)
Daisy provides the standard set of basic arithmetic operations you would
expect for numeric operands.
Arithmetic Tests
zero?:N => true if N = 0, false otherwise
one?:N => true if N = 1, false otherwise
neg?:N => true if N < 0, false otherwise
pos?:N => true if N >= 0, false otherwise
lt?:[N0 N1] => true if N0 < N1, false otherwise
le?:[N0 N1] => true if N0 <= N1, false otherwise
eq?:[N0 N1] => true if N0 < N1, false otherwise
ne?:[N0 N1] => true if N0 != N1, false otherwise
ge?:[N0 N1] => true if N0 >= N1, false otherwise
gt?:[N0 N1] => true if N0 > N1, false otherwise
Daisy provides the standard set of basic arithmetic predicates you would
expect for numeric operands.
Operations on Symbols
All symbols that are processed through the Daisy parser are hashed. This
means that two symbols can be compared quite efficiently for
equality. It does not mean that two identifiers with the same name refer
to the same variable-that depends on where the identifiers are defined
and used.
isLtrl?:I => true if I is a symbol, nil otherwise
Chr?:I => true if I is a single character symbol, nil otherwise
same?:[V0 V1] => true if V0 and V1 are the same symbol;
true if V0 and V1 are equal numbers;
nil otherwise
Operations on Lists
nil?:V => true if V is the empty list (nil), nil otherwise
list?:V => true if V is a list, nil otherwise
head: [V0 V1 V2 ...] => V0
tail: [V0 V1 V2 ...] => [V1 V2 ...]
head: [Vhead ! Vtail] => Vhead
tail: [Vhead ! Vtail] => Vtail