A Joy Library for Online Help Generation

Nick Forde [nickf@system-7.freeserve.co.uk]
Creation Date: Thu Feb 27 2003
Last Updated: Thu Feb 27 2003

Contents


1 Introduction

A recent update to the Joy interpreter was inclusion of the __manual_list primitive which gives direct access to the online help table. One advantage of this is that it makes possible the definition of help functions written in Joy. It also means that help generation support, which is not performance critical, could effectively be removed from the interpreter and supplied as a standard library.

To experiment with __manual_list I created the hlplib.joy library below. This largely, although not exactly, replicates the primitive functions help, _help, manual, __html_manual, __latex_manual and helpdetail. I've improved the help format somewhat by sorting and splitting into multiple columns. As an example the HTML primitive list also now includes a little colour!

The Latex output hasn't been tested and it would be nice to have some functions for rabbit, texi, or even postscript. Please send me any updates or suggestions you may have to the above address.


2 Library Implementation

     1	(* FILE: hlplib.joy *)
     2	
     3	"seqlib" libload.
     4	
     5	LIBRA
     6	
     7	##### Public Definitions #############################################
     8	
     9	  help == (* Print a textual sorted, 4 column, list of definitions *)
    10	    help-names [help-print-line] help-print-entries pop;
    11	
    12	  _help == (* Print a textual sorted, 4 column, list of hidden defs. *)
    13	    help-hidden-names [help-print-line] help-print-entries pop;
    14	
    15	  manual == (* Print a list of primitive, hidden & type definitions *)
    16	    help-list help-hidden-list concat help-type-list concat
    17	    [help-print-tentry] help-print-entries pop;
    18	
    19	  _manual == (* Print a list of hidden definitions *)
    20	    help-hidden-list [help-print-tentry] help-print-entries pop;
    21	
    22	  __html_manual == (* Print the manual in HTML format *)
    23	    help-print-hhead
    24	    help-list [help-print-hentry] help-print-entries pop
    25	    "</TABLE><H2>Hidden Primitives</H2><TABLE>\n" putchars
    26	    help-hidden-list [help-print-hentry] help-print-entries pop
    27	    "</TABLE><H2>Types</H2><TABLE>\n" putchars
    28	    help-type-list [help-print-hentry] help-print-entries pop
    29	    help-print-hfoot;
    30	
    31	  __latex_manual == (* Print the manual in Latex format *)
    32	    help-list [help-print-lentry] help-print-entries pop;
    33	
    34	  helpdetail == (* A -> Print help for  *)
    35	    [help-list [first =] filter [help-print-tentry] map] map pop;
    36	
    37	##### Private Definitions ############################################
    38	
    39	  _hlplib == true;
    40	
    41	  help-sort == (* A:unsorted -> A:sorted *)
    42	    [small] [] [uncons [first [first] dip >] split] 
    43	    [swapd cons concat] binrec;
    44	
    45	  help-list == (* -> A *)
    46	    __manual_list help-sort [first first '  !=] filter
    47	    [first first '_ !=] filter;
    48	
    49	  help-hidden-list == (* -> A *)
    50	    __manual_list help-sort [first first ' !=] filter
    51	    [first first '_ =] filter;
    52	
    53	  help-type-list == (* -> A *)
    54	    __manual_list help-sort [ first first ' =] filter;
    55	
    56	  help-names == (* -> A *)
    57	    help-list [first] map 4 help-slice;
    58	
    59	  help-hidden-names == (* -> A *)
    60	    help-hidden-list [first] map 4 help-slice;
    61	
    62	  help-slice == (* A -> A:A *)
    63	    [] rolldown [null] [pop popd reverse]
    64	    [[dupd swap] dip swap dup2 take rollup drop swonsd] tailrec;
    65	
    66	  help-print-entries == (* A P -> *)
    67	    swap [null] [pop] [unswons rolldown dup [i] dip swap] tailrec;
    68	
    69	  help-print-line == (* A -> *)
    70	    [null] [] [unswons 16 help-pad] tailrec "\n" putchars pop;
    71	
    72	  help-print-tentry == (* A -> *)
    73	    dup first 20 help-pad " : " putchars 
    74	    dup second 30 help-pad "\n" putchars
    75	    third putchars "\n\n" putchars;
    76	
    77	  help-print-hhead == (* -> *)
    78	    "<HTML><BODY>\n" putchars
    79	    "<H2>Atoms of Joy</H2\n" putchars
    80	    "<TABLE><TR><TD><B>Last Updated:</B> " putchars show-todaynow
    81	    "</TD></TR></TABLE></P><H2>Basic Primitives</H2><P>\n<TABLE>" putchars;
    82	
    83	  help-print-hfoot == (* -> *)
    84	    "</TABLE>\n</BODY>\n</HTML>\n" putchars;
    85	
    86	  help-print-hentry == (* A -> *)
    87	    "<TR><TD><B>" putchars dup first 20 help-pad "</B></TD>" putchars 
    88	    "<TD><FONT COLOR=darkblue>" putchars dup second 30 help-pad 
    89	    "</FONT></TD></TR>\n" putchars
    90	    "<TR><TD></TD><TD><FONT COLOR=darkred>" putchars third putchars 
    91	    "<BR><BR></FONT></TD></TR>\n\n" putchars;
    92	
    93	  help-print-lentry == (* A -> *)
    94	    "\\item[\\JX{" putchars dup first putchars
    95	    "}]  \\verb#      : " putchars dup second putchars
    96	    "# \\\\\n{\\small\\verb#" putchars third putchars
    97	    "#}\n\n" putchars;
    98	
    99	  help-pad == (* S I -> S *)
   100	    [dup putchars size] dip swap - [" " putchars] times;
   101	
   102	######################################################################
   103	  
   104	HLPLIB == "hlplib.joy - help generation library".
   105	
   106	(* end LIBRA *)
   107	
   108	"hlplib  is loaded\n" putchars.
   109	
   110	(* END hlplib.joy *)


3 Help Text

help.

!=              *               +               -               
/               <               <=              =               
>               >=              abort           abs             
acos            all             and             app1            
app11           app12           app2            app3            
app4            argc            argv            asin            
at              atan            atan2           autoput         
binary          binrec          body            branch          
case            ceil            char            choice          
chr             cleave          clock           compare         
concat          cond            condlinrec      cons            
construct       conts           cos             cosh            
dip             div             drop            dup             
dupd            echo            enconcat        equal           
exp             false           fclose          feof            
ferror          fflush          fgetch          fgets           
file            filter          first           float           
floor           fold            fopen           format          
formatf         fput            fputch          fputchars       
fputstring      fread           fremove         frename         
frexp           fseek           ftell           fwrite          
gc              genrec          get             getenv          
gmtime          has             help            helpdetail      
i               id              ifchar          iffile          
iffloat         ifinteger       iflist          iflogical       
ifset           ifstring        ifte            in              
include         infra           integer         intern          
ldexp           leaf            linrec          list            
localtime       log             log10           logical         
manual          map             max             maxint          
min             mktime          modf            name            
neg             not             null            nullary         
of              opcase          or              ord             
pop             popd            pow             pred            
primrec         put             putch           putchars        
quit            rand            rem             rest            
rolldown        rolldownd       rollup          rollupd         
rotate          rotated         set             setautoput      
setecho         setsize         setundeferror   sign            
sin             sinh            size            small           
some            split           sqrt            srand           
stack           stderr          stdin           stdout          
step            strftime        string          strtod          
strtol          succ            swap            swapd           
swons           system          tailrec         take            
tan             tanh            ternary         time            
times           treegenrec      treerec         treestep        
true            trunc           unary           unary2          
unary3          unary4          uncons          undeferror      
undefs          unstack         unswons         user            
while           x               xor             


4 Hidden Primitives

_help.

__ANON_FUNCT    __COPIED        __USR           __dump          
__html_manual   __latex_manual  __manual_list   __memoryindex   
__memorymax     __settracegc    __symtabindex   __symtabmax     
_help           


5 The helpdetail Function

[dip dup pop] helpdetail.

dip                  : X [P]  ->  ... X              
Saves X, executes P, pushes X back.

dup                  :  X  ->   X X                  
Pushes an extra copy of X onto stack.

pop                  :  X  ->                        
Removes X from top of the stack.


6 HTML Manual

Atoms of Joy

Last Updated: Thursday 27-FEB-03 18:51:48

Basic Primitives

!= X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X not equal to Y. Also supports float.

* I J -> K
Integer K is the product of integers I and J. Also supports float.

+ M I -> N
Numeric N is the result of adding integer I to numeric M. Also supports float.

- M I -> N
Numeric N is the result of subtracting integer I from numeric M. Also supports float.

/ I J -> K
Integer K is the (rounded) ratio of integers I and J. Also supports float.

< X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X less than Y. Also supports float.

<= X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X less than or equal to Y. Also supports float.

= X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X equal to Y. Also supports float.

> X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X greater than Y. Also supports float.

>= X Y -> B
Either both X and Y are numeric or both are strings or symbols. Tests whether X greater than or equal to Y. Also supports float.

abort ->
Aborts execution of current Joy program, returns to Joy main cycle.

abs N1 -> N2
Integer N2 is the absolute value (0,1,2..) of integer N1, or float N2 is the absolute value (0.0 ..) of float N1

acos F -> G
G is the arc cosine of F.

all A [B] -> X
Applies test B to members of aggregate A, X = true if all pass.

and X Y -> Z
Z is the intersection of sets X and Y, logical conjunction for truth values.

app1 X [P] -> R
Executes P, pushes result R on stack without X.

app11 X Y [P] -> R
Executes P, pushes result R on stack.

app12 X Y1 Y2 [P] -> R1 R2
Executes P twice, with Y1 and Y2, returns R1 and R2.

app2 X1 X2 [P] -> R1 R2
Obsolescent. == unary2

app3 X1 X2 X3 [P] -> R1 R2 R3
Obsolescent. == unary3

app4 X1 X2 X3 X4 [P] -> R1 R2 R3 R4
Obsolescent. == unary4

argc -> I
Pushes the number of command line arguments. This is quivalent to 'argv size'.

argv -> A
Creates an aggregate A containing the interpreter's command line arguments.

asin F -> G
G is the arc sine of F.

at A I -> X
X (= A[I]) is the member of A at position I.

atan F -> G
G is the arc tangent of F.

atan2 F G -> H
H is the arc tangent of F / G.

autoput -> I
Pushes current value of flag for automatic output, I = 0..2.

binary X Y [P] -> R
Executes P, which leaves R on top of the stack. No matter how many parameters this consumes, exactly two are removed from the stack.

binrec [B] [T] [R1] [R2] -> ...
Executes P. If that yields true, executes T. Else uses R1 to produce two intermediates, recurses on both, then executes R2 to combines their results.

body U -> [P]
Quotation [P] is the body of user-defined symbol U.

branch B [T] [F] -> ...
If B is true, then executes T else executes F.

case X [..[X Y]..] -> Y i
Indexing on the value of X, execute the matching Y.

ceil F -> G
G is the float ceiling of F.

char X -> B
Tests whether X is a character.

choice B T F -> X
If B is true, then X = T else X = F.

chr I -> C
C is the character whose Ascii value is integer I (or logical or character).

cleave X [P1] [P2] -> R1 R2
Executes P1 and P2, each with X on top, producing two results.

clock -> I
Pushes the integer value of current CPU usage in hundreds of a second.

compare A B -> I
I (=-1,0,+1) is the comparison of aggregates A and B. The values correspond to the predicates <=, =, >=.

concat S T -> U
Sequence U is the concatenation of sequences S and T.

cond [..[[Bi] Ti]..[D]] -> ...
Tries each Bi. If that yields true, then executes Ti and exits. If no Bi yields true, executes default D.

condlinrec [ [C1] [C2] .. [D] ] -> ...
Each [Ci] is of the forms [[B] [T]] or [[B] [R1] [R2]]. Tries each B. If that yields true and there is just a [T], executes T and exit. If there are [R1] and [R2], executes R1, recurses, executes R2. Subsequent case are ignored. If no B yields true, then [D] is used. It is then of the forms [[T]] or [[R1] [R2]]. For the former, executes T. For the latter executes R1, recurses, executes R2.

cons X A -> B
Aggregate B is A with a new member X (first member for sequences).

construct [P] [[P1] [P2] ..] -> R1 R2 ..
Saves state of stack and then executes [P]. Then executes each [Pi] to give Ri pushed onto saved stack.

conts -> [[P] [Q] ..]
Pushes current continuations. Buggy, do not use.

cos F -> G
G is the cosine of F.

cosh F -> G
G is the hyperbolic cosine of F.

dip X [P] -> ... X
Saves X, executes P, pushes X back.

div I J -> K L
Integers K and L are the quotient and remainder of dividing I by J.

drop A N -> B
Aggregate B is the result of deleting the first N elements of A.

dup X -> X X
Pushes an extra copy of X onto stack.

dupd Y Z -> Y Y Z
As if defined by: dupd == [dup] dip

echo -> I
Pushes value of echo flag, I = 0..3.

enconcat X S T -> U
Sequence U is the concatenation of sequences S and T with X inserted between S and T (== swapd cons concat)

equal T U -> B
(Recursively) tests whether trees T and U are identical.

exp F -> G
G is e (2.718281828...) raised to the Fth power.

false -> false
Pushes the value false.

fclose S ->
Stream S is closed and removed from the stack.

feof S -> S B
B is the end-of-file status of stream S.

ferror S -> S B
B is the error status of stream S.

fflush S -> S
Flush stream S, forcing all buffered output to be written.

fgetch S -> S C
C is the next available character from stream S.

fgets S -> S L
L is the next available line (as a string) from stream S.

file F -> B
Tests whether F is a file.

filter A [B] -> A1
Uses test B to filter aggregate A producing sametype aggregate A1.

first A -> F
F is the first member of the non-empty aggregate A.

float R -> B
Tests whether R is a float.

floor F -> G
G is the floor of F.

fold A V0 [P] -> V
Starting with value V0, sequentially pushes members of aggregate A and combines with binary operator P to produce value V.

fopen P M -> S
The file system object with pathname P is opened with mode M (r, w, a, etc.) and stream object S is pushed; if the open fails, file:NULL is pushed.

format N C I J -> S
S is the formatted version of N in mode C ('d or 'i = decimal, 'o = octal, 'x or 'X = hex with lower or upper case letters) with maximum width I and minimum width J.

formatf F C I J -> S
S is the formatted version of F in mode C ('e or 'E = exponential, 'f = fractional, 'g or G = general with lower or upper case letters) with maximum width I and precision J.

fput S X -> S
Writes X to stream S, pops X off stack.

fputch S C -> S
The character C is written to the current position of stream S.

fputchars S "abc.." -> S
The string abc.. (no quotes) is written to the current position of stream S.

fputstring S "abc.." -> S
== fputchars, as a temporary alternative.

fread S I -> S L
I bytes are read from the current position of stream S and returned as a list of I integers.

fremove P -> B
The file system object with pathname P is removed from the file system. is a boolean indicating success or failure.

frename P1 P2 -> B
The file system object with pathname P1 is renamed to P2. B is a boolean indicating success or failure.

frexp F -> G I
G is the mantissa and I is the exponent of F. Unless F = 0, 0.5 <= abs(G) < 1.0.

fseek S P W -> S
Stream S is repositioned to position P relative to whence-point W, where W = 0, 1, 2 for beginning, current position, end respectively.

ftell S -> S I
I is the current position of stream S.

fwrite S L -> S
A list of integers are written as bytes to the current position of stream S.

gc ->
Initiates garbage collection.

genrec [B] [T] [R1] [R2] -> ...
Executes B, if that yields true executes T. Else executes R1 and then [[B] [T] [R1] [R2] genrec] R2.

get -> F
Reads a factor from input and pushes it onto stack.

getenv "variable" -> "value"
Retrieves the value of the environment variable "variable".

gmtime I -> T
Converts a time I into a list T representing universal time: [year month day hour minute second isdst yearday weekday]. Month is 1 = January ... 12 = December; isdst is false; weekday is 0 = Monday ... 7 = Sunday.

has A X -> B
Tests whether aggregate A has X as a member.

help ->
Lists all defined symbols, including those from library files. Then lists all primitives of raw Joy (There is a variant: "_help" which lists hidden symbols).

helpdetail [ S1 S2 .. ]
Gives brief help on each symbol S in the list.

i [P] -> ...
Executes P. So, [P] i == P.

id ->
Identity function, does nothing. Any program of the form P id Q is equivalent to just P Q.

ifchar X [T] [E] -> ...
If X is a character, executes T else executes E.

iffile X [T] [E] -> ...
If X is a file, executes T else executes E.

iffloat X [T] [E] -> ...
If X is a float, executes T else executes E.

ifinteger X [T] [E] -> ...
If X is an integer, executes T else executes E.

iflist X [T] [E] -> ...
If X is a list, executes T else executes E.

iflogical X [T] [E] -> ...
If X is a logical or truth value, executes T else executes E.

ifset X [T] [E] -> ...
If X is a set, executes T else executes E.

ifstring X [T] [E] -> ...
If X is a string, executes T else executes E.

ifte [B] [T] [F] -> ...
Executes B. If that yields true, then executes T else executes F.

in X A -> B
Tests whether X is a member of aggregate A.

include "filnam.ext" ->
Transfers input to file whose name is "filnam.ext". On end-of-file returns to previous input file.

infra L1 [P] -> L2
Using list L1 as stack, executes P and returns a new list L2. The first element of L1 is used as the top of stack, and after execution of P the top of stack becomes the first element of L2.

integer X -> B
Tests whether X is an integer.

intern "sym" -> sym
Pushes the item whose name is "sym".

ldexp F I -> G
G is F times 2 to the Ith power.

leaf X -> B
Tests whether X is not a list.

linrec [P] [T] [R1] [R2] -> ...
Executes P. If that yields true, executes T. Else executes R1, recurses, executes R2.

list X -> B
Tests whether X is a list.

localtime I -> T
Converts a time I into a list T representing local time: [year month day hour minute second isdst yearday weekday]. Month is 1 = January ... 12 = December; isdst is a Boolean flagging daylight savings/summer time; weekday is 0 = Monday ... 7 = Sunday.

log F -> G
G is the natural logarithm of F.

log10 F -> G
G is the common logarithm of F.

logical X -> B
Tests whether X is a logical.

manual ->
Writes this manual of all Joy primitives to output file.

map A [P] -> B
Executes P on each member of aggregate A, collects results in sametype aggregate B.

max N1 N2 -> N
N is the maximum of numeric values N1 and N2. Also supports float.

maxint -> maxint
Pushes largest integer (platform dependent). Typically it is 32 bits.

min N1 N2 -> N
N is the minimum of numeric values N1 and N2. Also supports float.

mktime T -> I
Converts a list T representing local time into a time I. T is in the format generated by localtime.

modf F -> G H
G is the fractional part and H is the integer part (but expressed as a float) of F.

name sym -> "sym"
For operators and combinators, the string "sym" is the name of item sym, for literals sym the result string is its type.

neg I -> J
Integer J is the negative of integer I. Also supports float.

not X -> Y
Y is the complement of set X, logical negation for truth values.

null X -> B
Tests for empty aggregate X or zero numeric.

nullary [P] -> R
Executes P, which leaves R on top of the stack. No matter how many parameters this consumes, none are removed from the stack.

of I A -> X
X (= A[I]) is the I-th member of aggregate A.

opcase X [..[X Xs]..] -> [Xs]
Indexing on type of X, returns the list [Xs].

or X Y -> Z
Z is the union of sets X and Y, logical disjunction for truth values.

ord C -> I
Integer I is the Ascii value of character C (or logical or integer).

pop X ->
Removes X from top of the stack.

popd Y Z -> Z
As if defined by: popd == [pop] dip

pow F G -> H
H is F raised to the Gth power.

pred M -> N
Numeric N is the predecessor of numeric M.

primrec X [I] [C] -> R
Executes I to obtain an initial value R0. For integer X uses increasing positive integers to X, combines by C for new R. For aggregate X uses successive members and combines by C for new R.

put X ->
Writes X to output, pops X off stack.

putch N ->
N : numeric, writes character whose ASCII is N.

putchars "abc.." ->
Writes abc.. (without quotes)

quit ->
Exit from Joy.

rand -> I
I is a random integer.

rem I J -> K
Integer K is the remainder of dividing I by J. Also supports float.

rest A -> R
R is the non-empty aggregate A with its first member removed.

rolldown X Y Z -> Y Z X
Moves Y and Z down, moves X up

rolldownd X Y Z W -> Y Z X W
As if defined by: rolldownd == [rolldown] dip

rollup X Y Z -> Z X Y
Moves X and Y up, moves Z down

rollupd X Y Z W -> Z X Y W
As if defined by: rollupd == [rollup] dip

rotate X Y Z -> Z Y X
Interchanges X and Z

rotated X Y Z W -> Z Y X W
As if defined by: rotated == [rotate] dip

set X -> B
Tests whether X is a set.

setautoput I ->
Sets value of flag for automatic put to I (if I = 0, none; if I = 1, put; if I = 2, stack.

setecho I ->
Sets value of echo flag for listing. I = 0: no echo, 1: echo, 2: with tab, 3: and linenumber.

setsize -> setsize
Pushes the maximum number of elements in a set (platform dependent). Typically it is 32, and set members are in the range 0..31.

setundeferror I ->
Sets flag that controls behavior of undefined functions (0 = no error, 1 = error).

sign N1 -> N2
Integer N2 is the sign (-1 or 0 or +1) of integer N1, or float N2 is the sign (-1.0 or 0.0 or 1.0) of float N1.

sin F -> G
G is the sine of F.

sinh F -> G
G is the hyperbolic sine of F.

size A -> I
Integer I is the number of elements of aggregate A.

small X -> B
Tests whether aggregate X has 0 or 1 members, or numeric 0 or 1.

some A [B] -> X
Applies test B to members of aggregate A, X = true if some pass.

split A [B] -> A1 A2
Uses test B to split aggregate A into sametype aggregates A1 and A2 .

sqrt F -> G
G is the square root of F.

srand I ->
Sets the random integer seed to integer I.

stack .. X Y Z -> .. X Y Z [Z Y X ..]
Pushes the stack as a list.

stderr -> S
Pushes the standard error stream.

stdin -> S
Pushes the standard input stream.

stdout -> S
Pushes the standard output stream.

step A [P] -> ...
Sequentially putting members of aggregate A onto stack, executes P for each member of A.

strftime T S1 -> S2
Formats a list T in the format of localtime or gmtime using string S1 and pushes the result S2.

string X -> B
Tests whether X is a string.

strtod S -> R
String S is converted to the float R.

strtol S I -> J
String S is converted to the integer J using base I. If I = 0, assumes base 10, but leading "0" means base 8 and leading "0x" means base 16.

succ M -> N
Numeric N is the successor of numeric M.

swap X Y -> Y X
Interchanges X and Y on top of the stack.

swapd X Y Z -> Y X Z
As if defined by: swapd == [swap] dip

swons A X -> B
Aggregate B is A with a new member X (first member for sequences).

system "command" ->
Escapes to shell, executes string "command". The string may cause execution of another program. When that has finished, the process returns to Joy.

tailrec [P] [T] [R1] -> ...
Executes P. If that yields true, executes T. Else executes R1, recurses.

take A N -> B
Aggregate B is the result of retaining just the first N elements of A.

tan F -> G
G is the tangent of F.

tanh F -> G
G is the hyperbolic tangent of F.

ternary X Y Z [P] -> R
Executes P, which leaves R on top of the stack. No matter how many parameters this consumes, exactly three are removed from the stack.

time -> I
Pushes the current time (in seconds since the Epoch).

times N [P] -> ...
N times executes P.

treegenrec T [O1] [O2] [C] -> ...
T is a tree. If T is a leaf, executes O1. Else executes O2 and then [[O1] [O2] [C] treegenrec] C.

treerec T [O] [C] -> ...
T is a tree. If T is a leaf, executes O. Else executes [[O] [C] treerec] C.

treestep T [P] -> ...
Recursively traverses leaves of tree T, executes P for each leaf.

true -> true
Pushes the value true.

trunc F -> I
I is an integer equal to the float F truncated toward zero.

unary X [P] -> R
Executes P, which leaves R on top of the stack. No matter how many parameters this consumes, exactly one is removed from the stack.

unary2 X1 X2 [P] -> R1 R2
Executes P twice, with X1 and X2 on top of the stack. Returns the two values R1 and R2.

unary3 X1 X2 X3 [P] -> R1 R2 R3
Executes P three times, with Xi, returns Ri (i = 1..3).

unary4 X1 X2 X3 X4 [P] -> R1 R2 R3 R4
Executes P four times, with Xi, returns Ri (i = 1..4).

uncons A -> F R
F and R are the first and the rest of non-empty aggregate A.

undeferror -> I
Pushes current value of undefined-is-error flag.

undefs ->
Push a list of all undefined symbols in the current symbol table.

unstack [X Y ..] -> ..Y X
The list [X Y ..] becomes the new stack.

unswons A -> R F
R and F are the rest and the first of non-empty aggregate A.

user X -> B
Tests whether X is a user-defined symbol.

while [B] [D] -> ...
While executing B yields true executes D.

x [P]i -> ...
Executes P without popping [P]. So, [P] x == [P] P.

xor X Y -> Z
Z is the symmetric difference of sets X and Y, logical exclusive disjunction for truth values.

Hidden Primitives

__ANON_FUNCT ->
op for anonymous function call.

__COPIED ->
no message ever, used for gc.

__USR usg
user node.

__dump ->
debugging only: pushes the dump as a list.

__html_manual ->
Writes this manual of all Joy primitives to output file in HTML style.

__latex_manual ->
Writes this manual of all Joy primitives to output file in Latex style but without the head and tail.

__manual_list -> L
Pushes a list L of lists (one per operator) of three documentation strings

__memoryindex ->
Pushes current value of memory.

__memorymax ->
Pushes value of total size of memory.

__settracegc I ->
Sets value of flag for tracing garbage collection to I (= 0..5).

__symtabindex ->
Pushes current size of the symbol table.

__symtabmax ->
Pushes value of maximum size of the symbol table.

_help ->
Lists all hidden symbols in library and then all hidden inbuilt symbols.

Types

character type -> C
The type of characters. Literals are written with a single quote. Examples: 'A '7 '; and so on. Unix style escapes are allowed.

file type -> FILE:
The type of references to open I/O streams, typically but not necessarily files. The only literals of this type are stdin, stdout, and stderr.

float type -> F
The type of floating-point numbers. Literals of this type are written with embedded decimal points (like 1.2) and optional exponent specifiers (like 1.5E2)

integer type -> I
The type of negative, zero or positive integers. Literals are written in decimal notation. Examples: -123 0 42.

list type -> [...]
The type of lists of values of any type (including lists), or the type of quoted programs which may contain operators or combinators. Literals of this type are written inside square brackets. Examples: [] [3 512 -7] [john mary] ['A 'C ['B]] [dup *].

set type -> {...}
The type of sets of small non-negative integers. The maximum is platform dependent, typically the range is 0..31. Literals are written inside curly braces. Examples: {} {0} {1 3 5} {19 18 17}.

string type -> "..."
The type of strings of characters. Literals are written inside double quotes. Examples: "" "A" "hello world" "123". Unix style escapes are accepted.

truth value type -> B
The logical type, or the type of truth values. It has just two literals: true and false.


7 References


$Id: hlplib.m4,v 1.1 2003/02/27 19:07:17 nickf Exp nickf $: