Details of Icon Functions S through Z


seek (f,i) : f -- seek to position in file

Seeks to position i in f, but fails if the seek cannot be performed. The first byte in the file is at position 1. seek(f,0) seeks to the end of file f.
See also: where()

seq (i1,i2) : i3,i4,... -- generate sequence of integers

Generates an endless sequence of integers starting at i1 with increments of i2.
Defaults:
i1      1
i2      1

See also: i1 to i2 by i3

serial (x) : i -- produce serial number

Produces the serial number of x if it is a type that has one but fails otherwise.

set (L) : S -- create set

Produces a set whose members are the distinct values in the list L.
Default:
L       []

sin (r1) : r2 -- compute sine

Produces the sine of r1 given in radians.
See also: asin()

sort (X,i) : L -- sort structure

Produces a list containing values from X. If X is a list, record, or set, sort(X,i) produces the values of X in sorted order. If X is a table, sort(X,i) produces a list obtained by sorting the elements of X, depending on the value of i. For i = 1 or 2, the list elements are two-element lists of key/value pairs. For i = 3 or 4, the list elements are alternating keys and values. Sorting is by keys for i odd, by value for i even.
Default:
i       1

See also: sortf()

sortf (X,i) : L -- sort list or set by field

Produces a sorted list of the values in X. Sorting is primarily by type and in most respects is the same as with sort(X,i). However, among lists and among records, two structures are ordered by comparing their ith fields. i can be negative but not zero. Two structures having the equal ith fields are ordered as they would be in regular sorting, but structures lacking an ith field appear before structures having them.
Default:
i       1

See also: sort()

sqrt (r1) : r2 -- compute square root

Produces the square root of r1.
See also: N1 ^ N2()

stop (x1,x2,...,xn) -- stop execution

Terminates program execution with an error status after writing strings x1,x2,...,xn. If xi is a file, subsequent output is to xi. Initial output is to standard error output.
Default:
xi      "" (empty string)

See also: exit() and write()

string (x) : s -- convert to string

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

system (s) : i -- call system function

Calls the C library function system() to execute s and produces the resulting integer exit status.

tab (i) : s -- set scanning position

Produces &subject[&pos:i] and assigns i to &pos, but fails if i is out of range. It reverses assignment to &pos if resumed.
See also: move()

table (x) : T -- create table

Produces a table with a default value x.
Default:
x       &null

tan (r1) : r2 -- compute tangent

Produces the tangent of r1 given in radians.
See also: atan()

trim (s1,c) : s2 -- trim string

Produces a string consisting of the characters of s1 up to the trailing characters contained in c.
Default:
c       ' ' (blank)

type (x) : s -- produce type name

Produces a string corresponding to the type of x.

upto (c,s,i1,i2) : i3,i4,...,in -- locate characters

Generates the sequence of integer positions in s preceding a character of c in s[i1:i2]. It fails if there is no such position.
Defaults:
s       &subject
i1      &pos if s defaulted, otherwise 1
i2      0

See also: bal() and find()

variable (s) : x -- produce variable

Produces the variable for the identifier or keyword named s, but fails if there is no such variable. Local identifiers override global identifiers.
See also: name()

where (f) : i -- produce position in file

Produces the current byte position in f. The first byte in the file is at position 1.
See also: seek()

write (x1,x2,...,xn) : xn -- write line

Writes strings x1,x2,...,xn with a line termination sequence added at the end. If xi is a file, subsequent output is to xi. Initial output is to standard output.
Default:
xi      "" (empty string)

See also: writes()

writes (x1,x2,...,xn) -- write string

Writes strings x1,x2,...,xn without a line termination sequence added at the end. If xi is a file, subsequent output is to xi. Initial output is to standard output.
Default:
xi      "" (empty string)

See also: write()