Procedures set to read and write HP95LX appointment book (.abk) files. Notes: 1. Files created by the Appointment Book application may contain some padding following the last field of some data records. Hence, the RecordLength field must be used to determine the start of the next record. Appointment book files created by other programs need not have any padding. 2. ApptState has several bit fields. Only bit 0 is meaningful to software processing an appointment book file. Bit 0 being set or cleared corresponds to the alarm being enabled or disabled, respectively. Programs creating Appointment book files should clear all bits, except perhaps bit 0. 3. ToDoState has two one-bit bit fields. Bit 0 being set or cleared corresponds to carry forward being enabled or disabled for this todo item, respectively. Bit 1 being set or cleared corresponds to the doto being checked off or not checked off, respectively. 4. Appointment and ToDo texts are each limited to a maximum of 27 characters. 5. Note text is limited to a maximum of 11 lines of 39 characters per line (not counting the line terminator).
[ Full documentation | Source code ]
Pretty mundane stuff. Set_OS(), Basename(), Pathname(), Strip(), and a utility for creating index filenames.
[ Full documentation | Source code ]
Procedures used by programs that process address lists: nextadd() get next address writeadd(add) write address get_country(add) get country get_state(add) get state (U.S. addresses only) get_city(add) get city (U.S. addresses only) get_zipcode(add) get ZIP code (U.S. addresses only) get_lastname(add) get last name get_namepfx(add) get name prefix get_title(add) get name title format_country(s) format country name
[ Full documentation | Source code ]
allof{expr1,expr2} -- Control operation that performs iterative
conjunction.
Iterative conjunction permits a conjunction expression to be built
at run time which supports full backtracking among the created terms
of the expression. The computed expression can be of arbitrary
length, and is built via an iterative loop in which one term is
appended to the expression (as if connected with a "&" operator) per
iteration.
Expr1 works like the control expression of "every-do"; it controls
iteration by being resumed to produce all of its possible results.
The allof{} expression produces the outcome of conjunction of all of
the resulting instances of expr2.
For example:
global c
...
pattern := "ab*"
"abcdef" ? {
allof { c := !pattern ,
if c == "*" then move(0 to *&subject - &pos + 1) else =c
} & pos(0)
}
This example will perform a wild card match on "abcdef" against
pattern "ab*", where "*" in a pattern matches 0 or more characters.
Since pos(0) will fail the first time it is evaluated, the allof{}
expression will be resumed just as a conjunction expression would,
and backtracking will propagate through all of the instances of
expr2; the expression will ultimately succeed (as its conjunctive
equivalent would).
Note that, due to the scope of variables in co-expressions,
variables shared between expr1 and expr2 must have global scope,
hence c in the above example must be global.
The allof{} procedure models Icon's expression evaluation
mechanism in that it explicitly performs backtracking. The author of
this procedure knows of no way to invoke Icon's built-in goal
directed evaluation to perform conjunction of a arbitrary number of
computed expressions (suggestions welcome).
[ Full documentation | Source code ]
[ Full documentation | Source code ]
This package of procedures implements a subset of the ANSI terminal
control sequences. The names of the procedures are taken directly from
the ANSI names. If it is necessary to use these routines with non-ANSI
devices, link in iolib.icn, and (optionally) iscreen.icn as well. Use
will be made of whatever routines are made available via either of these
libraries. Be careful of naming conflicts if you link in iscreen.icn.
It contains procedures like "clear" and "boldface."
CUB(i) Moves the cursor left i columns
CUD(i) Moves the cursor down i rows
CUF(i) Moves the cursor right i columns
CUP(i,j) Moves the cursor to row i, column j
CUU(i) Moves the cursor up i rows
ED(i) Erases screen: i = 0, cursor to end; i = 1,
beginning to cursor; i = 2, all (default 2)
EL(i) Erases data in cursor row: i = 0, cursor to
end; i = 1, beginning to cursor; i = 2, all
(default 0)
SGR(i) Sets video attributes: 0 = off; 1 = bold; 4 =
underscore; 5 = blink; 7 = reverse (default
0)
Note that not all so-called ANSI terminals support every ANSI
screen control sequence - not even the limited subset included in
this file.
If you plan on using these routines with non-ANSI magic-cookie
terminals (e.g. a Wyse-50) then it is strongly recommended that you
link in iolib or itlib *and* iscreen (not just iolib or itlib by
itself). The routines WILL WORK with most magic cookie terminals;
they just don't always get all the modes displayed (because they
are basically too busy erasing the cookies).
[ Full documentation | Source code ]
This procedure applies a list of functions to an argument. An example is
apply([integer, log], 10)
which is equivalent to integer(log(10)).
[ Full documentation | Source code ]
argparse(s) parses s as if it were a command line and puts the components in in a list, which is returned. At present, it does not accept any escape conventions.
[ Full documentation | Source code ]
create_array([lbs], [ubs], value) creates a n-dimensional array with the specified lower bounds, upper bounds, and with each array element having the specified initial value. ref_array(A, i1, i2, ...) references the i1-th i2-th ... element of A.
[ Full documentation | Source code ]
asciiname(s) returns the mnemonic name of the single unprintable ASCII character s.
[ Full documentation | Source code ]
Descriptions: base64encode( s1 ) : s2 returns the base64 encoding of a string s1 base64decode( s1 ) : s2 returns the base64 decoding of a string s1 fails if s1 isn't base64 encoded references: MIME encoding Internet RFC 2045
[ Full documentation | Source code ]
This procedure is based on the UNIX basename(1) utility. It strips off any path information and removes the specified suffix, if present. If no suffix is provided, the portion of the name up to the first "." is returned. It should work under UNIX, MS-DOS, and the Macintosh.
[ Full documentation | Source code ]
This is a collection of procedures that support conversion of Icon data elements to and from binary data formats. The purpose is to facilitate dealing with binary data files. The procedures can be used individually or via the "control" procedures pack() and unpack().
[ Full documentation | Source code ]
unsigned() -- Converts binary byte string into unsigned integer. Detects overflow if number is too large. This procedure is normally used for processing of binary data read from a file. raw() -- Puts raw bits of characters of string s into an integer. If the size of s is less than the size of an integer, the bytes are put into the low order part of the integer, with the remaining high order bytes filled with zero. If the string is too large, the most significant bytes will be lost -- no overflow detection. This procedure is normally used for processing of binary data read from a file. rawstring() -- Creates a string consisting of the raw bits in the low order "size" bytes of integer i. This procedure is normally used for processing of binary data to be written to a file.
[ Full documentation | Source code ]
This procedure applies a binary operation to a list of arguments.
For example,
binop("+", 1, 2, 3)
returns 6.
[ Full documentation | Source code ]
int2bit(i) produces a string with the bit representation of i. bit2int(s) produces an integer corresponding to the bit representation i.
[ Full documentation | Source code ]
Procedures for working with strings made up of numeric values represented by strings of an arbitrary number of bits, stored without regard to character boundaries. In conjunction with the "large integers" feature of Icon, this facility can deal with bitstring segments of arbitrary size. If "large integers" are not supported, bitstring segments (i.e. the nbits parameter of BitStringGet and BitStringPut) wider that the integer size of the platform are likely to produce incorrect results.
[ Full documentation | Source code ]
Procedures for reading and writing integer values made up of an arbitrary number of bits, stored without regard to character boundaries.
[ Full documentation | Source code ]
Utility procedures for HP95LX phone book and appointment book processing.
[ Full documentation | Source code ]
These procedures produce text with interspersed characters suit-
able for printing to produce the effect of boldface (by over-
striking) and underscoring (using backspaces).
bold(s) bold version of s
uscore(s) underscored version of s
[ Full documentation | Source code ]
Limitation: Assumes square patterns.
[ Full documentation | Source code ]
Synopsis:
bufopen(s) Open a file name s for buffered read and lookahead
bufread(f) Read the next line from file f
bufnext(f, n) Return the next nth record from file f
without changing the next record to be read by
bufread
bufclose(f) Close file f
[ Full documentation | Source code ]
Procedures in this file supersede several procedures in datetime.icn.
[ Full documentation | Source code ]
calendat(j) return a record with the month, day, and year corresponding to the Julian Date Number j.
[ Full documentation | Source code ]
These procedures deal with procedure invocations that are encapsulated in records.
[ Full documentation | Source code ]
Capture is initially called by the user with one argument, the open file
to contain the echoed output. Then it places itself and several shadow
procedures between all calls to write, writes & stop. The user never
need call capture again.
Subsequently, during calls to write, writes, and stop, the appropriate
shadow procedure gains control and calls capture internally. Capture
then constructs a list of only those elements that direct output to
&output and calls the original builtin function via the saved name.
Upon return the shadow routine calls the the original builtin function
with the full list.
A series of uncaptured output functions have been added to allow output
to be directed only to &output. These are handy for placing progress
messages and other comforting information on the screen.
Example:
otherfile := open(...,"w")
capfile := capture(open(filename,"w"))
write("Hello there.",var1,var2," - this should be echoed",
otherfile,"This should appear once in the other file only")
uncaptured_writes("This will appear once only.")
every i := 1 to 10000 do
if ( i % 100 ) = 0 then
uncaptured_writes("Progress is ",i,"\r")
close(capfile)
close(otherfile)
[ Full documentation | Source code ]
These procedures project geographic coordinates. rectp(x1, y1, x2, y2, xm, ym) defines a rectangular projection. pptrans(L1, L2) defines a planar projective transformation. utm(a, f) defines a latitude/longitude to UTM projection. project(p, L) projects a list of coordinates. invp(p) returns the inverse of projection p. compose(p1, p2, ...) creates a composite projection.
[ Full documentation | Source code ]
These procedures are analogous to the standard string-analysis
functions except that uppercase letters are considered equivalent to
lowercase letters.
anycl(c, s, i1, i2) succeeds and produces i1 + 1, provided
map(s[i1]) is in cset(map(c)) and i2 is
greater than i1. It fails otherwise.
balcl(c1, c2, c3, s, i1, i2) generates the sequence of integer
positions in s preceding a
character of cset(map(c1)) in
map(s[i1:i2]) that is balanced with
respect to characters in cset(map(c2))
and cset(map(c3)), but fails if there
is no such position.
findcl(s1, s2, i1, i2) generates the sequence of integer positions in
s2 at which map(s1) occurs as a substring
in map(s2[i1:i2]), but fails if there is no
such position.
manycl(c, s, i1, i2) succeeds and produces the position in s
after the longest initial sequence of
characters in cset(map(c)) within
map(s[i1:i2]). It fails if map(s[i1]) is not
in cset(map(c)).
matchcl(s1, s2, i1, i2) produces i1 + *s1 if
map(s1) == map(s2[i1+:=*s1]) but fails
otherwise.
uptocl(c, s, i1, i2) generates the sequence of integer positions in
s preceding a character of cset(map(c)) in
map(s[i1:i2]). It fails if there is no such
position.
Defaults: s, s2 &subject
i1 &pos if s or s2 is defaulted; otherwise 1
i2 0
c1 &cset
c2 '('
c3 ')'
Errors: 101 i1 or i2 not integer
103 s or s1 or s2 not string
104 c or c1 or c2 or c3 not cset
[ Full documentation | Source code ]
These procedures provide a way of storing Icon values as strings and
retrieving them. The procedure encode(x) converts x to a string s that
can be converted back to x by decode(s). These procedures handle all
kinds of values, including structures of arbitrary complexity and even
loops. For "scalar" types -- null, integer, real, cset, and string --
decode(encode(x)) === x
For structures types -- list, set, table, and record types --
decode(encode(x)) is, for course, not identical to x, but it has the
same "shape" and its elements bear the same relation to the original
as if they were encoded and decode individually.
No much can be done with files, functions and procedures, and
co-expressions except to preserve type and identification.
The encoding of strings and csets handles all characters in a way
that it is safe to write the encoding to a file and read it back.
No particular effort was made to use an encoding of value that
minimizes the length of the resulting string. Note, however, that
as of Version 7 of Icon, there are no limits on the length of strings
that can be written out or read in.
[ Full documentation | Source code ]
colmize() -- Arrange data into columns. Procedure to arrange a number of data items into multiple columns. Items are arranged in column-wise order, that is, the sequence runs down the first column, then down the second, etc. This procedure goes to great lengths to print the items in as few vertical lines as possible.
[ Full documentation | Source code ]
complete(s,st) completes a s relative to a set or list of strings, st.
Put differently, complete() lets you supply a
partial string, s, and get back those strings in st
that s is either equal to or a substring of.
[ Full documentation | Source code ]
The following procedures perform operations on complex numbers.
complex(r,i) create complex number with real part r and
imaginary part i
cpxadd(z1, z2) add complex numbers z1 and z2
cpxdiv(z1, z2) divide complex number z1 by complex number z2
cpxmul(z1, z2) multiply complex number z1 by complex number z2
cpxsub(z1, z2) subtract complex number z2 from complex number z1
cpxstr(z) convert complex number z to string representation
strcpx(s) convert string representation s of complex
number to complex number
[ Full documentation | Source code ]
Thanks to Clint Jeffery for suggesting the Directive wrapper and making defining a specification much cleaner looking and easier!
[ Full documentation | Source code ]
This procedure produces continued-fraction convergents from a list of partial quotients.
[ Full documentation | Source code ]
exbase10(i, j) converts base-10 integer i to base j.
inbase10(s, i) convert base-i integer s to base 10.
radcon(s, i, j) convert base-i integer s to base j.
There are several other procedures related to conversion that are
not yet part of this module.
[ Full documentation | Source code ]
Links to core modules of the basic part of the library, as defined in the Icon Language book (3/e, p.179) and Graphics book (p.47).
[ Full documentation | Source code ]
This program returns the number of structures of a given type that have been created.
[ Full documentation | Source code ]
currency() -- Formats "amount" in standard American currency format. "amount" can be a real, integer, or numeric string. "width" is the output field width, in which the amount is right adjusted. The returned string will be longer than "width" if necessary to preserve significance. "minus" is the character string to be used for negative amounts (default "-"), and is placed to the right of the amount.
[ Full documentation | Source code ]
This file links procedure files that generate traces of points on various
plain curves.
The first two parameters determine the defining position of the
curve:
x x coordinate
y y coordinate
The meaning of "definition position" depends on the curve. In some
cases it is the position at which plotting starts. In others, it
is a "center" for the curve.
The next arguments vary and generally refer to parameters of the
curve. There is no practical way to describe these here. If they
are not obvious, the best reference is
A Catalog of Special Plane Curves, J. Dennis Lawrence,
Dover Publications, Inc., New York, 1972.
This book, which is in print at the time of this writing, is a
marvelous source of information about plane curves and is inexpensive
as well.
The trailing parameters give the number of steps and the end points
(generally in angles) of the curves:
steps number of points, default varies
lo beginning of plotting range, default varies
hi end of plotting range, default varies
Because of floating-point roundoff, the number of steps
may not be exactly the number specified.
Note: Some of the curves may be "upside down" when plotted on
coordinate systems in which the y axis increases in a downward direction.
Caution: Some of these procedures generate very large values
in portions of their ranges. These may cause run-time errors when
used in versions of Icon prior to 8.10. One work-around is to
turn on error conversion in such cases.
Warning: The procedures that follow have not been tested thoroughly.
Corrections and additions are most welcome.
These procedures are, in fact, probably most useful for the parametric
equations they contain.
[ Full documentation | Source code ]
datefns.icn - a collection of date functions Adaptor: Charles L Hethcoat III June 12, 1995 Taken from various sources as attributed below. All date and calendar functions use the "date_rec" structure defined below. Note: I adapted the procedures "julian" and "unjulian" sometime in 1994 from "Numerical Recipes in C." Some time later I discovered them (under slightly different names) in Version 9 of the Icon Library (Ralph Griswold, author). I am including mine for what they are worth. That'll teach me to wait!
[ Full documentation | Source code ]
Notes:
- the default value for function parameters named
"hoursFromGmt" is the value of global variable
"HoursFromGmt" if nonnull, or environment variable
"HoursFromGmt" if set, or 0.
- The base year from which the "seconds" representation
of a date is calculated is by default 1970 (the ad hoc
standard used by both Unix and MS-Windows), but can be
changed by either setting the global variable
"DateBaseYear" or environment variable "DateBaseYear".
- There are some procedures not mentioned in this summary
that are useful: DateRecToSec(), SecToDateRec(). See the
source code for details.
ClockToSec(seconds)
converts a time in the format of &clock to seconds past
midnight.
DateLineToSec(dateline,hoursFromGmt)
converts a date in &dateline format to seconds since start of
dateBaseYear.
DateToSec(date,hoursFromGmt)
converts a date string in Icon &date format (yyyy/mm/dd)
to seconds past DateBaseYear.
SecToClock(seconds)
converts seconds past midnight to a string in the format of
&clock.
SecToDate(seconds,hoursFromGmt)
converts seconds past DateBaseYear to a string in Icon
&date format (yyyy/mm/dd).
SecToDateLine(seconds,hoursFromGmt)
produces a date in the same format as Icon's &dateline.
SecToUnixDate(seconds,hoursFromGmt)
returns a date and time in typical UNIX format:
Jan 14 10:24 1991.
IsLeapYear(year)
succeeds if year is a leap year, otherwise fails.
calendat(j)
returns a record with the month, day, and year corresponding
to the Julian Date Number j.
date() natural date in English.
dayoweek(day, month, year)
produces the day of the week for the given date.
Note carefully the parameter order.
full13th(year1, year2)
generates records giving the days on which a full moon occurs
on Friday the 13th in the range from year1 though year2.
julian(m, d, y)
returns the Julian Day Number for the specified
month, day, and year.
pom(n, phase)
returns record with the Julian Day number of fractional
part of the day for which the nth such phase since
January, 1900. Phases are encoded as:
0 - new moon
1 - first quarter
2 - full moon
3 - last quarter#
GMT is assumed.
saytime()
computes the time in natural English. If an argument is
supplied it is used as a test value to check the operation
the program.
walltime()
produces the number of seconds since midnight. Beware
wrap-around when used in programs that span midnight.
[ Full documentation | Source code ]
These procedures read DDF files ("Data Descriptive Files",
ISO standard 8211) such as those specified by the US Geological
Survey's "Spatial Data Transfer Standard" for digital maps.
ISO8211 files from other sources may contain additional data
encodings not recognized by these procedures.
ddfopen(filename) opens a file and returns a handle.
ddfdda(handle) returns a list of header records.
ddfread(handle) reads the next data record.
ddfclose(handle) closes the file.
[ Full documentation | Source code ]
dif(stream, compare, eof, group)
generates a sequence of differences between an arbitrary
number of input streams. Each result is returned as a list
of diff_recs, one for each input stream, with each diff_rec
containing a list of items that differ and their position
in the input stream.
The diff_rec type is declared as:
record diff_rec(pos,diffs)
dif() fails if there are no differences, i.e. it produces an empty
result sequence.
[ Full documentation | Source code ]
This procedure counts the number of each digit in a file and returns a ten-element list with the counts.
[ Full documentation | Source code ]
The procedures do_od and if_fi implement the "do ... od" and "if ... fi"
control structures used in the book "A Discipline of Programming" by
Edsger W. Dijkstra. This book uses a programming language designed to
delay implementation details, such as the order in which tests are
performed.
Dijkstra's programming language uses two non-ASCII characters, a box and
a right arrow. In the following discussion, the box and right arrow
characters are represented as "[]" and "->" respectively.
The "if ... fi" control structure is similar to multi-branch "if" statements
found in many languages, including the Bourne shell (i.e. the
"if / elif / fi" construct). The major difference is that in Dijkstra's
notation, there is no specified order in which the "if / elif" tests are
performed. The "if ... fi" structure has the form
if
Guard1 -> List1
[] Guard2 -> List2
[] Guard3 -> List3
...
[] GuardN -> ListN
fi
where
Guard1, Guard2, Guard3 ... GuardN are boolean expressions, and
List1, List2, List3 ... ListN are lists of statements.
When this "if ... fi" statement is performed, the guard expressions are
evaluated, in some order not specified by the language, until one of the
guard expressions evaluates to true. Once a true guard is found, the list
of statements following the guard is evaluated. It is a fatal error
for none of the guards in an "if ... fi" statement to be true.
The "do ... od" control is a "while" loop structure, but with multiple
loop conditions, in style similar to "if ... fi". The form of a Dijkstra
"do" statement is
do
Guard1 -> List1
[] Guard2 -> List2
[] Guard3 -> List3
...
[] GuardN -> ListN
od
where
Guard1, Guard2, Guard3 ... GuardN are boolean expressions, and
List1, List2, List3 ... ListN are lists of statements.
To perform this "do ... od" statement, the guard expressions are
evaluated, in some order not specified by the language, until either a
guard evaluates to true, or all guards have been evaluated as false.
- If all the guards are false, we exit the loop.
- If a guard evaluates to true, then the list of statements following this
guard is performed, and then we loop back to perform this "do ... od"
statement again.
The procedures if_fi{} and do_od{} implement Dijkstra's "if ... fi" and
"do ... od" control structures respectively. In keeping with Icon
conventions, the guard expressions are arbitrary Icon expressions. A guard
is considered to be true precisely when it succeeds. Similarly, a statement
list can be represented by a single Icon expression. The Icon call
if_fi{
Guard1, List1,
Guard2, List2,
...
GuardN, ListN
}
suspends with each result produced by the expression following the true
guard. If none of the guards succeed, runerr() is called with an appropriate
message.
Similarly, the Icon call
do_od{
Guard1, List1,
Guard2, List2,
...
GuardN, ListN
}
parallels the "do ... od" statement. As long as at least one guard
succeeds, another iteration is performed. When all guards fail, we exit
the loop and do_od fails.
The test section of this file includes a guarded command implementation of
Euclid's algorithm for calculating the greatest common denominator. Unlike
most implementations of Euclid's algorithm, this version handles its
parameters in a completely symmetrical fashion.
[ Full documentation | Source code ]
Doesn't get the decimal point. Not sure what the padding does; to study.
[ Full documentation | Source code ]
These procedures assist in use of the ASCII and EBCDIC character sets,
regardless of the native character set of the host:
Ascii128() Returns a 128-byte string of ASCII characters in
numerical order. Ascii128() should be used in
preference to &ascii for applications which might
run on an EBCDIC host.
Ascii256() Returns a 256-byte string representing the 256-
character ASCII character set. On an EBCDIC host,
the order of the second 128 characters is essentially
arbitrary.
Ebcdic() Returns a 256-byte string of EBCDIC characters in
numerical order.
AsciiChar(i) Returns the character whose ASCII representation is i.
AsciiOrd(c) Returns the position of the character c in the ASCII
collating sequence.
EbcdicChar(i) Returns the character whose EBCDIC representation is i.
EbcdicOrd(c) Returns the position of the character c in the EBCDIC
collating sequence.
MapEtoA(s) Maps a string of EBCDIC characters to the equivalent
ASCII string, according to a plausible mapping.
MapAtoE(s) Maps a string of ASCII characters to the equivalent
EBCDIC string, according to a plausible mapping.
Control(c) Returns the "control character" associated with the
character c. On an EBCDIC host, with $ representing
an EBCDIC character with no 7-bit ASCII equivalent,
Control("$") may not be identical to "\^$", as
translated by ICONT (and neither result is particularly
meaningful).
[ Full documentation | Source code ]
This procedure is called by timing programs produced by empg. It a "delta" timing value used to adjust timings.
[ Full documentation | Source code ]
This program is designed to be linked with the output of the meta- translator. As given here, they produce an identity translation. Modifications can be made to effect different translations. The procedures here are just wrappers. This file is a skeleton that can be used as a basis for code-generation procedures.
[ Full documentation | Source code ]
equiv(s,y) compare arbitrary structures x and y
[ Full documentation | Source code ]
The procedure escape(s) produces a string in which Icon quoted
literal escape conventions in s are replaced by the corresponding
characters. For example, escape("\\143\\141\\164") produces the
string "cat".
[ Full documentation | Source code ]
Procedure kit for dealing with escape sequences in Icon character
string representations. Note that Icon escape sequences are
very similar to C escapes, so this works for C strings, too.
escapeseq() -- a matching procedure for Icon string escape sequences
escchar() -- produces the character value of an Icon string escape sequence
escape() -- converts a string with escape sequences (as in Icon string
representation) to the string it represents with escape
quotedstring() -- matching routine for a quoted string.
[ Full documentation | Source code ]
This procedure analyzes a string representing an Icon function or procedure call and evaluates the result. Operators can be used in functional form, as in "*(2,3)". This procedure cannot handle nested expressions or control structures. It assumes the string is well-formed. The arguments can only be Icon literals. Escapes, commas, and parentheses in strings literals are not handled. In the case of operators that are both unary and binary, the binary form is used.
[ Full documentation | Source code ]
This procedure takes an expression, produces a program encapsulating it, and puts the results written by the program in a list. It is called as evallist(expr, n, ucode, ...) where expr is an expression (normally a generator), n is the maximum size of the list, and the trailing arguments are ucode files to link with the expression.
[ Full documentation | Source code ]
This program is designed to be linked with the output of the meta-variant translator. It is designed to insert event-reporting code in Icon programs.
[ Full documentation | Source code ]
everycat(x1, x2, ...) generates the concatenation of every string
from !x1, !x2, ... .
For example, if
first := ["Mary", "Joe", "Sandra"]
last := ["Smith", "Roberts"]
then
every write(everycat(first, " ", last))
writes
Mary Smith
Mary Roberts
Joe Smith
Joe Roberts
Sandra Smith
Sandra Roberts
Note that x1, x2, ... can be any values for which !x1, !x2, ... produce
strings or values convertible to strings. In particular, in the example
above, the second argument is a one-character string " ", so that !" "
generates a single blank.
[ Full documentation | Source code ]
pfl2str(pattern) expands pattern-form expressions, which have the form
[<expr><op><expr>]
to the corresponding string.
The value of <op> determines the operation to be performed.
pfl2gxp(pattern) expands pattern-form expressions into generators
that, when compiled and evaluated, produce the corresponding
string.
pfl2pwl(pattern) converts pattern-form expressions to Painter's
weaving language.
[ Full documentation | Source code ]
exprfile(exp, link, ...)
produces a pipe to a program that writes all the
results generated by exp. The trailing arguments
name link files needed for the expression.
exprfile() closes any previous pipe it opened
and deletes its temporary file. Therefore,
exprfile() cannot be used for multiple expression
pipes.
If the expression fails to compile, the global
expr_error is set to 1; otherwise 0.
exec_expr(expr_list, links[])
generates the results of executing the expression
contained in the lists expr_list with the specified
links.
plst2pstr(L) converts the list of Icon programs lines in L to a
string with separating newlines.
pstr2plst(s) converts the string of Icon program lines (separated
by newlines) to a list of lines.
ucode(file) produces a ucode file from the Icon program in file.
[ Full documentation | Source code ]
This file contains procedures related to factorization and prime
numbers.
divisors(n) generates the divisors of n.
divisorl(n) returns a list of the divisors of n.
factorial(n) returns n!. It fails if n is less than 0.
factors(i, j) returns a list containing the prime factors of i
limited to maximum value j; default, no limit.
genfactors(i, j)
like factors(), except factors are generated as
they are found.
gfactorial(n, i)
generalized factorial; n x (n - i) x (n - 2i) x ...
ispower(i, j) succeeds and returns root if i is k^j
isprime(n) succeeds if n is a prime.
nxtprime(n) returns the next prime number beyond n.
pfactors(i) returns a list containing the primes that divide i.
prdecomp(i) returns a list of exponents for the prime
decomposition of i.
prime() generates the primes.
primel() generates the primes from a precompiled list.
primorial(i,j) product of primes j <= i; j defaults to 1.
sfactors(i, j) as factors(i, j), except output is in string form
with exponents for repeated factors
squarefree(i) succeeds if the factors of i are distinct
[ Full documentation | Source code ]
These procedures implement integer-valued using the fastest
method known to the author. "Fastest" does not mean "fast".
acker(i, j) Ackermann's function
fib(i) Fibonacci sequence
g(k, i) Generalized Hofstader nested recurrence
q(i) "Chaotic" sequence
robbins(i) Robbins numbers
[ Full documentation | Source code ]
This procedure analyzes a string representing an Icon function or procedure call and evaluates the result. It assumes the string is well-formed. The arguments can only be Icon literals. Escapes, commas, and parentheses in strings literals are not handled.
[ Full documentation | Source code ]
filedim(s, p) computes the number of rows and maximum column width
of the file named s. The procedure p, which defaults to detab, i
applied to each line. For example, to have lines left as is, use
filedim(s, 1)
[ Full documentation | Source code ]
This procedure is useful when you need to create the next file in a series of files (such as successive log files). Usage: fn := nextseqfilename( ".", "$", "log") returns the (non-existent) filename next in the sequence .\$*.log (where the * represents 1, 2, 3, ...) or fails
[ Full documentation | Source code ]
filesize(s) returns the number of characters in the file named s; it
fails if s cannot be opened.
[ Full documentation | Source code ]
DESCRIPTION: findre() is like the Icon builtin function find(), except that it takes, as its first argument, a regular expression pretty much like the ones the Unix egrep command uses (the few minor differences are listed below). Its syntax is the same as find's (i.e. findre(s1,s2,i,j)), with the exception that a no- argument invocation wipes out all static structures utilized by findre, and then forces a garbage collection.
[ Full documentation | Source code ]
This procedure returns the file identification produced by file(1).
[ Full documentation | Source code ]
fullimage() -- enhanced image()-type procedure that outputs all data contained in structured types. The "level" argument tells it how far to descend into nested structures (defaults to unlimited).
[ Full documentation | Source code ]
gauss_random(x, f) produces a Gaussian distribution about the value x. The value of f can be used to alter the shape of the Gaussian distribution (larger values flatten the curve...)
[ Full documentation | Source code ]
Gdl returns a list containing everything in a directory (whose name must be passed as an argument to gdl). Nothing fancy. I use this file as a template, modifying the procedures according to the needs of the program in which they are used.
[ Full documentation | Source code ]
Gdl returns a list containing everything in a directory (whose name must be passed as an argument to gdl). Nothing fancy. I use this file as a template, modifying the procedures according to the needs of the program in which they are used. NOTE: MSDOS results are all in lower case Modifications: 1) Fixed MSDOS routines. 2) Added gdlrec which does same thing as gdl except it recursively descends through subdirectories. May choose which Unix utility to use by passing in method parameter. See below.
[ Full documentation | Source code ]
These procedures read and interpret GEDCOM files, a standard format for genealogy databases.
[ Full documentation | Source code ]
These procedures are for use with code produced by a meta-variant translator. As given here, they produce an identity translation. Modifications can be made to effect variant translations.
[ Full documentation | Source code ]
These procedures generate sequences of results.
days() days of the week.
hex() sequence of hexadecimal codes for numbers
from 0 to 255
label(s,i) sequence of labels with prefix s starting at i
multii(i, j) sequence of i * j i's
months() months of the year
octal() sequence of octal codes for numbers from 0 to 255
star(s) sequence consisting of the closure of s
starting with the empty string and continuing
in lexical order as given in s
[ Full documentation | Source code ]
These procedures generate sequences of results.
arandseq(i, j) arithmetic sequence starting at i with randomly
chosen increment between 1 and j
arithseq(i, j) arithmetic sequence starting at i with increment j
beatty1seq() Beatty's first sequence i * &phi
beatty2seq() Beatty's second sequence i * &phi ^ 2
catlnseq(i) sequence of generalized Catalan numbers
cfseq(i, j) continued-fraction sequence for i / j
chaosseq() chaotic sequence
chexmorphseq() sequence of centered hexamorphic numbers
connellseq(p) generalized Connell sequence
dietzseq(s) Dietz sequence for polynomial
dressseq(i) dress sequence with increment i, default 1 (Schroeder)
eisseq(i) EIS A sequence for i
factseq() factorial sequence
fareyseq(i, k) Farey fraction sequence; k = 0, the default, produces
numerator sequence; k = 1 produces denominator
sequence
fibseq(i, j, k, m) generalized Fibonacci sequence (Lucas sequence)
with initial values i and j and additive constant
k. If m is supplied, the results are produced
mod m.
figurseq(i) series of ith figurate number
fileseq(s, i) generate from file s; if i is null, lines are generated.
Otherwise characters, except line terminators.
friendseq(k) generate random friendly sequence from k values, 1 to k
(in a friendly sequence, successive terms differ by 1).
geomseq(i, j) geometric sequence starting at i with multiplier j
hailseq(i) hailstone sequence starting at i
irepl(i, j) j instances of i
lindseq(f, i) generate symbols from L-system in file f; i if
present overrides the number of generations specified
in the L-system.
logmapseq(k, x) logistic map
lrrcseq(L1, L2)
generalized linear recurrence with constant
coefficients; L1 is a list of initial terms,
L2 is a list of coefficients for n previous values,
where n = *L2
meanderseq(s, n) sequences of all characters that contain all n-tuples
of characters from s
mthueseq() Morse-Thue sequence
mthuegseq(i) Morse-Thue sequence for base i
multiseq(i, j, k) sequence of (i * j + k) i's
ngonalseq(i) sequence of the ith polygonal number
nibonacciseq(values[])
generalized Fibonacci sequence that sums the
previous n terms, where n = *values.
partitseq(i, j, k) sequence of integer partitions of i with minimum j
and maximum k
pellseq(i, j, k) generalized Pell's sequence starting with i, j and
using multiplier k
perrinseq() Perrin sequence
polyseq(coeff[]) polynomial in x evaluated for x := seq()
primeseq() the sequence of prime numbers
powerseq(i) sequence n ^ i, n = 1, 2, 3, 4, ...
powersofseq(i) sequence i ^ n, n = 1, 2, 3, 4, ...n
rabbitseq() rabbit sequence
ratsseq(i) versumseq() with sort
signaseq(r) signature sequence of r
spectseq(r) spectral sequence integer(i * r), i - 1, 2, 3, ...
srpseq(n, m) palindromic part of the continued-fraction sequence
for sqrt(n^2+m)
versumseq(i, j) generalized sequence of added reversed integers with
seed i (default 196) and increment j (default 0)
versumopseq(i, p) procedure p (default 1) applied to versumseq(i)
vishwanathseq() random variation on Fibonacci sequence
zebra(values[]) zebra colors, alternating 2 and 1, for number of
times given by successive values
[ Full documentation | Source code ]
These procedures provide "projections" that convert among geodetic datums, which relate locations on the earth's surface to longitude and latitude coordinates. As measurement techniques improve, newer datums typically give slightly different values from older ones. The values returned here are used with the project() procedure of cartog.icn. geodat(s1, s2) defines a geodetic datum conversion. molodensky() performs an algorithmic datum conversion. nadcon(s1, s2) uses data files for more precise conversion. ellipsoid(s) return the parameters of the named ellipsoid.
[ Full documentation | Source code ]
Implementing getch() is a much, much more complex affair under UNIX
than it is under, say, MS-DOS. This library represents one,
solution to the problem - one which can be run as a library, and
need not be compiled into the run-time system. Note that it will
not work on all systems. In particular, certain Suns (with a
screwy stty command) and the NeXT 1.0 OS (lacking the -g option for
stty) do not run getchlib properly. See the bugs section below for
workarounds.
Four basic utilities are included here:
getch() - waits until a keystroke is available &
returns it without displaying it on the screen
getche() - same as getch() only with echo
getse(s) - like getche() only for strings. The optional
argument s gives getse() something to start with. Use this
if, say, you want to read single characters in cbreak mode,
but get more input if the character read is the first part
of a longer command. If the user backspaces over everything
that has been input, getse() fails. Returns on \r or \n.
reset_tty() - absolutely vital routine for putting the cur-
rent tty line back into cooked mode; call it before exiting
or you will find yourself with a locked-up terminal; use it
also if you must temporarily restore the terminal to cooked
mode
Note that getse() *must* be used in place of read(&input) if you
are planning on using getch() or getche(), since read(&input)
assumes a tty with "sane" settings.
Warning: The routines below do not do any sophisticated output
processing. As noted above, they also put your tty line in raw
mode. I know, I know: "Raw is overkill - use cbreak." But in
a world that includes SysV, one must pick a lowest common denomi-
nator. And no, icanon != cbreak.
BUGS: These routines will not work on systems that do not imple-
ment the -g option for the stty command. The NeXT workstation is
an example of such a system. Tisk, tisk. If you are on a BSD
system where the network configuration makes stty | more impossible,
then substitute /usr/5bin/stty (or whatever your system calls the
System V stty command) for /bin/stty in this file. If you have no
SysV stty command online, then you can try replacing every instance
of "stty -g 2>&1" below with "stty -g 2>&1 1> /dev/tty" or
something similar.
[ Full documentation | Source code ]
Getkeys(FNAME) generates all keys in FNAME in order of occurrence. See gettext.icn for a description of the requisite file structure for FNAME.
[ Full documentation | Source code ]
The getmail procedure reads a Unix/Internet type mail folder
and generates a sequence of records, one per mail message.
It fails when end-of-file is reached. Each record contains the
message header and message text components parsed into separate
record fields. The entire uninterpreted message (header and text)
are also stored in the record. See the description
of message_record below.
The argument to getmail is either the name of a mail folder or
the file handle for a mail folder which has already been opened
for reading. If getmail is resumed after the last message is
generated, it closes the mail folder and returns failure.
If getmail generates an incomplete sequence (does not close the
folder and return failure) and is then restarted (not resumed)
on the same or a different mail folder, the previous folder file
handle remains open and inaccessible. This may be a problem if
done repeatedly since there is usually an OS-imposed limit
on number of open file handles. Safest way to use getmail
is using one of the below forms:
message := message_record()
every message := !getmail("folder_name") do {
process message ...
}
message := message_record()
coex := create getmail("folder_name")
while message := @coex do {
process message ...
}
Note that if message_record's are stored in a list, the records
may be sorted by individual components (like sender, _date, _subject)
using sortf function in Icon Version 9.0.
[ Full documentation | Source code ]
Suspends, in turn, the paths supplied as args to getpaths(),
then all paths in the PATH environment variable. A typical
invocation might look like:
open(getpaths("/usr/local/lib/icon/procs") || filename)
Note that getpaths() will be resumed in the above context until
open succeeds in finding an existing, readable file. Getpaths()
can take any number of arguments.
[ Full documentation | Source code ]
Gettext() and associated routines allow the user to maintain a file
of KEY/value combinations such that a call to gettext(KEY, FNAME)
will produce value. Gettext() fails if no such KEY exists.
Returns an empty string if the key exists, but has no associated
value in the file, FNAME.
The file format is simple. Keys belong on separate lines, marked
as such by an initial colon+colon (::). Values begin on the line
following their respective keys, and extend up to the next
colon+colon-initial line or EOF. E.g.
::sample.1
or:
::sample.1 ::sample.2
Notice how the key above, sample.1, has :: prepended to mark it
out as a key. The text you are now reading represents that key's
value. To retrieve this text, you would call gettext() with the
name of the key passed as its first argument, and the name of the
file in which this text is stored as its second argument (as in
gettext("sample.1","tmp.idx")).
::next.key
etc...
For faster access, an indexing utility is included, idxtext. Idxtext
creates a separate index for a given text-base file. If an index file
exists in the same directory as FNAME, gettext() will make use of it.
The index becomes worthwhile (at least on my system) after the text-
base file becomes longer than 5 kilobytes.
Donts:
1) Don't nest gettext text-base files.
2) In searches, surround phrases with spaces or tabs in
key names with quotation marks: "an example"
3) Don't modify indexed files in any way other than to append
additional keys/values (unless you want to re-index).
This program is intended for situations where keys tend to have
very large values, and use of an Icon table structure would be
unwieldy.
BUGS: Gettext() relies on the Icon runtime system and the OS to
make sure the last text/index file it opens gets closed.
[ Full documentation | Source code ]
These declarations are provided for representing geometrical objects as records.
[ Full documentation | Source code ]
The procedures here use sets to represent directed graphs. See
The Icon Programming Language, second edition, pp. 195-198.
A value of type "graph" has two components: a list of nodes and
a two-way lookup table. The nodes in turn contain pointers to
other nodes. The two-way table maps a node to its name and
vice-versa.
Graph specifications are give in files in which the first line
is a white-space separated list of node names and subsequent lines
give the arcs, as in
Tucson Phoenix Bisbee Douglas Flagstaff
Tucson->Phoenix
Tucson->Bisbee
Bisbee->Bisbee
Bisbee->Douglas
Douglas->Phoenix
Douglas->Tucson
[ Full documentation | Source code ]
[ Full documentation | Source code ]
hex(s) -- Converts string of hex digits into an integer. hexstring(i,n,lc) -- Returns a string that is the hexadecimal representation of the argument. If n is supplied, a minimum of n digits appear in the result; otherwise there is no minimum, and negative values are indicated by a minus sign. If lc is non-null, lowercase characters are used instead of uppercase.
[ Full documentation | Source code ]
This procedure determines the name of the current host. It takes no arguments. Aborts with an error message if the necessary commands are not found. Geared specifically for UNIX machines.
[ Full documentation | Source code ]
These procedures parse HTML files:
htchunks(f) generates the basic chunks -- tags and text --
that compose an HTML file.
htrefs(f) generates the tagname/keyword/value combinations
that reference other files.
These procedures process strings from HTML files:
httag(s) extracts the name of a tag.
htvals(s) generates the keyword/value pairs from a tag.
urlmerge(base,new) interprets a new URL in the context of a base.
canpath(s) puts a path in canonical form
[ Full documentation | Source code ]
Procedures to support benchmarking of Icon programs: Init__(prog) initialize for benchmarking Term__() terminate benchmarking Allocated__() get amounts allocated Collections__() get collections Regions__() get regions Signature__() show program/environment information Storage__() get storage Time__() show elapsed time Display__(data,name) show information
[ Full documentation | Source code ]
General:
Ichartp implements a simple chart parser - a slow but
easy-to-implement strategy for parsing context free grammars (it
has a cubic worst-case time factor). Chart parsers are flexible
enough to handle a lot of natural language constructs. They also
lack many of the troubles associated with empty and left-recursive
derivations. To obtain a parse, just create a BNF file, obtain a
line of input, and then invoke parse_sentence(sentence,
bnf_filename, start-symbol). Parse_sentence suspends successive
edge structures corresponding to possible parses of the input
sentence. There is a routine called edge_2_tree() that converts
these edges to a more standard form. See the stub main() procedure
for an example of how to make use of all these facilities.
[ Full documentation | Source code ]
This program is designed to be linked with the output of the meta- translator. As given here, they produce an identity translation. Modifications can be made to effect different translations.
[ Full documentation | Source code ]
This procedure produces an "identity" value for types that have one.
[ Full documentation | Source code ]
These are procedure wrappers for use in Icon function tracing. Don't let the apparent recursion fool you.
[ Full documentation | Source code ]
These procedures provide tracing for Icon functions by using procedure wrappers to call the functions. iftrace(fncs[]) sets tracing for a list of function names.
[ Full documentation | Source code ]
The procedure Image(x,style) produces a string image of the value x.
The value produced is a generalization of the value produced by
the Icon function image(x), providing detailed information about
structures. The value of style determines the formatting and
order of processing:
1 indented, with ] and ) at end of last item (default)
2 indented, with ] and ) on new line
3 puts the whole image on one line
4 as 3, but with structures expanded breadth-first instead of
depth-first as for other styles.
[ Full documentation | Source code ]
This procedure, inbits(), re-imports data converted into writable form by outbits(). See the file outbits.icn for all the whys and hows.
[ Full documentation | Source code ]
indices(spec, last)
produces a list of the integers given by the
specification spec, which is a common separated list
of either positive integers or integer spans, as in
"1,3-10, ..."
If last is specified, it it used for a span of
the form "10-".
In an integer span, the low and high values need not
be in order. For example, "1-10" and "10-1"
are equivalent. Similarly, indices need not be
in order, as in "3-10, 1, ..."
And empty value, as in "10,,12" is ignored.
indices() fails if the specification is syntactically
erroneous or if it contains a value less than 1.
[ Full documentation | Source code ]
inserts() -- Inserts values into a table in which the same key can have more than one value (i.e., duplicate keys). The value of each element is a list of inserted values. The table must be created with default value &null.
[ Full documentation | Source code ]
intstr() -- Creates a string consisting of the raw bits in the low order "size" bytes of integer i. This procedure is normally used for processing of binary data to be written to a file. Note that if large integers are supported, this procedure still will not work for integers larger than the implementation defined word size due to the shifting in of zero-bits from the left in the right shift operation.
[ Full documentation | Source code ]
They provide facilities for handling input, output, and files. There are other modules in the Icon program library that deal with input and output. They are not included here because they conflict with procedures here or each other.
[ Full documentation | Source code ]
The following library represents a series of rough functional equivalents to the standard UNIX low-level termcap routines. It is not meant as an exact termlib clone. Nor is it enhanced to take care of magic cookie terminals, terminals that use \D in their termcap entries, or archaic terminals that require padding. This library is geared mainly for use with ANSI and VT-100 devices. Note that this file may, in most instances, be used in place of the older UNIX-only itlib.icn file. It essentially replaces the DOS- only itlibdos routines. For DOS users not familiar with the whole notion of generalized screen I/O, I've included extra documentation below. Please read it. The sole disadvantage of this over the old itlib routines is that iolib.icn cannot deal with archaic or arcane UNIX terminals and/or odd system file arrangements. Note that because these routines ignore padding, they can (unlike itlib.icn) be run on the NeXT and other systems which fail to implement the -g option of the stty command. Iolib.icn is also simpler and faster than itlib.icn. I want to thank Norman Azadian for suggesting the whole idea of combining itlib.icn and itlibdos.icn into one distribution, for suggesting things like letting drive specifications appear in DOS TERMCAP environment variables, and for finding several bugs (e.g. the lack of support for %2 and %3 in cm). Although he is loathe to accept this credit, I think he deserves it.
[ Full documentation | Source code ]
This file contains some rudimentary screen functions for use with
itlib.icn (termlib-like routines for Icon).
clear() - clears the screen (tries several methods)
emphasize() - initiates emphasized (usu. = reverse) mode
boldface() - initiates bold mode
blink() - initiates blinking mode
normal() - resets to normal mode
message(s) - displays message s on 2nd-to-last line
underline() - initiates underline mode
status_line(s,s2,p) - draws status line s on the 3rd-to-last
screen line; if s is too short for the terminal, s2 is used;
if p is nonnull then it either centers, left-, or right-justi-
fies, depending on the value, "c," "l," or "r."
clear_emphasize() - horrible way of clearing the screen to all-
emphasize mode; necessary for many terminals
[ Full documentation | Source code ]
These procedures implement commonly referenced ``text-book''
recursively defined functions, but using iteration.
acker(i, j) Ackermann's function
fib(i, j) Generalized Fibonacci (Lucas) sequence
[ Full documentation | Source code ]
The following library represents a series of rough functional equivalents to the standard UNIX low-level termcap routines. They are not meant as exact termlib clones. Nor are they enhanced to take care of magic cookie terminals, terminals that use \D in their termcap entries, or, in short, anything I felt would not affect my normal, day-to-day work with ANSI and vt100 terminals. There are some machines with incomplete or skewed implementations of stty for which itlib will not work. See the BUGS section below for work- arounds.
[ Full documentation | Source code ]
The following library represents a series of rough functional equivalents to the standard UNIX low-level termcap routines. They are not meant as exact termlib clones. Nor are they enhanced to take care of magic cookie terminals, terminals that use \D in their termcap entries, or, in short, anything I felt would not affect my normal, day-to-day work with ANSI and vt100 terminals. At this point I'd recommend trying iolib.icn instead of itlibdos.icn. Iolib is largely DOS-UNIX interchangeable, and it does pretty much every- thing itlibdos.icn does.
[ Full documentation | Source code ]
This file contains itokens() - a utility for breaking Icon source
files up into individual tokens. This is the sort of routine one
needs to have around when implementing things like pretty printers,
preprocessors, code obfuscators, etc. It would also be useful for
implementing cut-down implementations of Icon written in Icon - the
sort of thing one might use in an interactive tutorial.
Itokens(f, x) takes, as its first argument, f, an open file, and
suspends successive TOK records. TOK records contain two fields.
The first field, sym, contains a string that represents the name of
the next token (e.g. "CSET", "STRING", etc.). The second field,
str, gives that token's literal value. E.g. the TOK for a literal
semicolon is TOK("SEMICOL", ";"). For a mandatory newline, itokens
would suspend TOK("SEMICOL", "\n").
Unlike Icon's own tokenizer, itokens() does not return an EOFX
token on end-of-file, but rather simply fails. It also can be
instructed to return syntactically meaningless newlines by passing
it a nonnull second argument (e.g. itokens(infile, 1)). These
meaningless newlines are returned as TOK records with a null sym
field (i.e. TOK(&null, "\n")).
NOTE WELL: If new reserved words or operators are added to a given
implementation, the tables below will have to be altered. Note
also that &keywords should be implemented on the syntactic level -
not on the lexical one. As a result, a keyword like &features will
be suspended as TOK("CONJUNC", "&") and TOK("IDENT", "features").
[ Full documentation | Source code ]
itrcline(f) generates lines from the file f that are Icon
trace messages. It can, of course, be fooled.
[ Full documentation | Source code ]
This procedure turns a string from image() into the corresponding Icon value. It can handle integers, real numbers, strings, csets, keywords, structures, and procedures. For the image of a structure, it produces a result of the correct type and size, but any values in the structure are not likely to be correct, since they are not encoded in the image. For procedures, the procedure must be present in the environment in which ivalue() is evaluated. This generally is true for built-in procedures (functions). All keywords are supported even if image() does not produce a string of the form "&name" for them. The values produced for non-constant keywords are, of course, the values they have in the environment in which ivalue() is evaluated. ivalue() also can handle non-local variables (image() does not produce these), but they must be present in the environment in which ivalue() is evaluated.
[ Full documentation | Source code ]
jumpque(queue, y) moves y to the head of the queue if it is in queue but just adds y to the head of the queue if it is not already in the queue. A copy of queue is returned; the argument is not modified.
[ Full documentation | Source code ]
This procedure maps uppercase letters and the control modifier key in combination with letters into the corresponding lowercase letters. It is intended for use with graphic applications in which the modifier keys for shift and control are encoded in keyboard events.
[ Full documentation | Source code ]
This procedure produces a new label in sequence each time it's called. The labels consist of all possible combinations of the characters given in the argument the first time it is called. See star(s) in gener.icn for a generator that does the same thing (and much more concisely).
[ Full documentation | Source code ]
Descriptions:
lastc( c, s, i1, i2 ) : i3
succeeds and produces i1, provided either
- i1 is 1, or
- s[i1 - 1] is in c and i2 is greater than i1
defaults: same as for any
errors: same as for any
findp( c, s1, s2, i1, i2 ) : i3, i4, ..., in
generates the sequence of positions in s2 at which s1 occurs
provided that:
- s2 is preceded by a character in c,
or is found at the beginning of the string
i1 & i2 limit the search as in find
defaults: same as for find
errors: same as for find & lastc
findw( c1, s1, c2, s2, i1, i2 ) : i3, i4, ..., in
generates the sequence of positions in s2 at which s1 occurs
provided that:
- s2 is preceded by a character in c1,
or is found at the beginning of the string;
and
- s2 is succeeded by a character in c2,
or the end of the string
i1 & i2 limit the search as in find
defaults: same as for find
errors: same as for find & lastc
[ Full documentation | Source code ]
Produces the last name of a name in conventional form. Obviously, it doesn't work for every possibility.
[ Full documentation | Source code ]
rcseval(a, c, m) evaluates the constants used in a linear congruence recurrence for generating a sequence of pseudo-random numbers. a is the multiplicative constant, c is the additive constant, and m is the modulus. Any line of output starting with asterisks indicates a problem. See Donald E. Knuth, "Random Numbers" in The Art of Computer Programming, Vol. 2, Seminumerical Algorithms, Addison-Wesley, Reading, Massachusetts, 1969, pp. 1-160.
[ Full documentation | Source code ]
lindgen() assumes a "full" mapping table; lindgenx() does not.
Note that the first argument is a single character. At the top level
it might be called as
lindgen(!axiom, rewrite, gener)
[ Full documentation | Source code ]
Lindenmayer systems are usually are interpreted as specifications
for drawing plant-like objects, fractals, or other geometric designs.
This procedure illustrates that L-systems can be interpreted in other
ways -- as striped patterns, for example.
The procedure is called as lindstrp(prod, band_tbl) where prod is a
"production" that is interpreted as being a sequence of one-character
symbols, and band_tbl is a table with these symbols as keys whose
corresponding values are specifications for bands of the form
"color:width". An example of a table for the symbols A, B, and C is:
band_tbl := table()
band_tbl["A"] := "blue:3"
band_tbl["B"] := "red:10"
band_tbl["C"] := "black:5"
With a table default of null, as above, symbols in prod that are not
table keys are effectively ignored. Other table defaults
can be used to produce different behaviors for such symbols.
An example of a production is:
"ABCBABC"
The result is a string of band specifications for the striped pattern
represented by prod. It can be converted to an image by using
strplang.icn, but graphics are not necessary for the use of this
procedure itself.
One thing this procedure is useful for is developing an understanding
of how to construct L-systems for specific purpose: L-systems for
plant-like objects and fractals are require specialized knowledge and
are difficu