Details of Icon Functions A through D


abs (N) : N -- compute absolute value

Produces the absolute value of N.

acos (r1) : r2 -- compute arc cosine

Produces the arc cosine of r1 in the range of 0 to pi for r1 in the range of -1 to 1.
See also: cos()

any (c,s,i1,i2) : i3 -- locate initial character

Succeeds and produces i1 + 1 if s[i1] is in c and i2 > i1, but fails otherwise.
Defaults:
s       &subject
i1      &pos if s defaulted, otherwise 1
i2      0

See also: many() and match()

args (p) : i -- get number of procedure arguments

Produces the number of arguments for procedure p. For built-in procedures with a variable number of arguments, the value produced is -1. For declared procedures with a variable number of arguments, the value returned is the negative of the number of formal parameters.
See also: proc()

asin (r1) : r2 -- compute arc sine

Produces the arc sine of r1 in the range of -pi/2 to +pi/2 for r1 in the range of -1 to 1.
See also: sin()

atan (r1,r2) : r3 -- compute arc tangent

Produces the arc tangent of r1/r2 in the range -pi/2 to pi/2 with the sign of r1.
Default:
r2      1.0

See also: tan()

bal (c1,c2,c3,s,i1,i2) : i3,i4,...,in -- locate balanced characters

Generates the sequence of integer positions in s preceding a character of c1 in s[i1:i2] that is balanced with respect to the characters of c2 and c3, but fails if there is no such position.
Defaults:
c1      &cset
c2      '('
c3      ')'
s       &subject
i1      &pos if s defaulted, otherwise 1
i2      0

See also: find() and upto()

center (s1,i,s2) : s3 -- position string at center

Produces a string of size i in which s1 is centered, with s2 used for padding at left and right as necessary.
Defaults:
i       1
s2      " " (blank)

See also: left() and right()

char (i) : s -- produce character

Produces a string of length 1 consisting of the character whose internal representation is i.
See also: ord()

chdir (s) : n -- change directory

Changes the directory to s but fails if there is no such directory or if the change cannot be made.

close (f) : f -- close file

Produces f after closing it unless f was opened with the pipe ("p") option, in which case the integer exit status of the command is returned.
See also: open()

collect (i1,i2) : n -- perform garbage collection

Causes a garbage collection in region i1, requesting i2 bytes of space in that region. It fails if the requested space is not available. The regions are identified as follows:
                1               Static region
                2               String region
                3               Block region
If i1 is 0, a collection is done, but no region is identified and i2 has no effect. The value of i2 is ignored for the static region.
Defaults:
i1      0
i2      0

copy (x1) : x2 -- copy value

Produces a copy of x1 if x1 is a structure; otherwise it produces x1.

cos (r1) : r2 -- compute cosine

Produces the cosine of r1 in radians.
See also: acos()

cset (x) -- convert to cset

Produces a cset resulting from converting x, but fails if the conversion is not possible.

delay (i) : n -- delay execution

Delays execution i milliseconds.

delete (X,x) : X -- delete element

If X is a set, deletes x from X. If X is a table, deletes the element for key x from X. Produces X.
See also: insert() and member()

detab (s1,i1,i2,...,in) : s2 -- remove tabs

Produces a string based on s1 in which each tab character is replaced by one or more blanks. Tab stops are at i1, i2, ..., in, with additional stops obtained by repeating the last interval.
Default:
i1      9

See also: entab()

display (i,f) : n -- display variables

Writes the image of the current co-expression and the values of the local variables in the current procedure call. If i > 0, the local variables in the i preceding procedure calls are displayed as well. After all local variables are displayed, the values of global variables are displayed. Output is written to f.
Defaults:
i       &level
f       &errout

dtor (r1) : r2 -- convert degrees to radians

Produces the radian equivalent of r1 given in degrees.
See also: rtod()