Files
calc/help/null
2017-05-21 15:38:36 -07:00

76 lines
2.1 KiB
Plaintext

NAME
null - null value
SYNOPSIS
null([v_1, v_2,...])
TYPES
v_1, v_2,... any
return null
DESCRIPTION
After evaluating in order any arguments it may have, null(...)
returns the null value. This is a particular value, different from
all other types; it is the only value v for which isnull(v) returns
TRUE. The null value tests as FALSE in conditions, and normally
delivers no output in print statements, except that when a list or
matrix is printed, null elements are printed as "NULL".
A few builtin functions may return the null value, e.g.
printf(...) returns the null value; if L = list(), then both
pop(L) and remove(L) return the null value; when successful,
file-handling functions like fclose(fs), fflush(fs), fputs(fs, ...)
return the null value when successful (when they fail they return an
error-value). User-defined functions where execution ends
without a "return" statement or with "return ;" return the null
value.
Missing expressions in argument lists are assigned the null value.
For example, after
define f(a,b,c) = ...
calling
f(1,2)
is as if c == null(). Similarly, f(1,,2) is as if b == null().
(Note that this does not occur in initialization lists; missing
expressions there indicate no change.)
The null value may be used as an argument in some operations, e.g.
if v == null(), then for any x, x + v returns x.
When calc is used interactively, a function that returns the null value
causes no printed output and does not change the "oldvalue". Thus,
null(config("mode", "frac")) may be used to change the output mode
without printing the current mode or changing the stored oldvalue.
EXAMPLE
> L = list(-1,0,1,2);
> while (!isnull(x = pop(L)) print x,; print
-1 0 1 2
> printf("%d %d %d\n", 2, , 3);
2 3
> L = list(,1,,2,)
> print L
list (5 elements, 5 nonzero):
[[0]] = NULL
[[1]] = 1
[[2]] = NULL
[[3]] = 2
[[4]] = NULL
> a = 27
> null(pi = pi(1e-1000))
> .
27
LIMITS
The number of arguments is not to exceed 100.
LIBRARY
none
SEE ALSO
isnull, test