~trn/reduce-algebra

e8acca6ba9ed88191a58463dad2db392c0bffb3b — Jeffrey H. Johnson 16 days ago 5bdfc41 + 8b06977
Merge branch 'svn/trunk'
M Makefile.new => Makefile.new +95 -140
@@ 8,12 8,14 @@
###########################################################################
###########################################################################

# There are two things that this Makefile is trying to do. Firstly there
# will be multiple versions of some code in a number of directories. Here I
# these are the multiple build directories within cslbuild and pslbuild.
# When I go "make target" I want that target re-built in each relevant
# directory. I will be able to put explicit targets here
# for artefacts that I do not want delegated that way.
# There are two things that this Makefile is trying to do.
#
# Firstly there are multiple variant build directories (within cslbuild
# and pslbuild). When I go "make target" I generally want that target
# re-built in each relevant directory.
# However there need to be some targets which only get run in one of
# the variants.
#
# Secondly I want the builds all to run in parallel, even across the
# multiple directories. By default if you invoke "make" it will use as
# much parallelism as you have available "cpus". If you explicitly indicate


@@ 21,24 23,15 @@
# to the setting you specified, so "make -j 1" reverts to sequential builds
# everywhere.
#
# This Makefile takes a while to start up because it is tabululating for
# itself all possible combinations of targets and build directories.

.PHONY:	csl psl all

all:

# "targets" needs to be a list of all the targets that I will delegate...
# ... and "dirs" is a list of the directories within which they live.

# A sort of nasty issue is that I can not make just "csl" a target here
# because I want that to map to building the default target in all CSL
# variants. But in Windows I can make csl.exe and csl.com available.
# A messy issue is that of the phrase "relevent directory" above. Here I am
# supporting both a CSL and a PSL Lisp and for instance "bootstrapreduce.exe"
# and "c-code" are only relevant in the CSL world, while "all" applies
# everywhere.

csltargets := \
	csl.exe csl.com csl.img \
	bootstrapreduce bootstrapreduce.exe \
		bootstrapreduce.com bootstrapreduce.img \
	bootstrapreduce.com bootstrapreduce.img \
	reduce reduce.exe reduce.com reduce.img \
	flatcsl flatcsl.exe flatcsl.com flatcsl.img \
	fwindemo fwindemo.exe fwindemo.com \


@@ 67,41 60,7 @@ csltargets1 := \

csldirs := $(wildcard cslbuild/*-*-*/csl)

csldirs1 := $(shell d1="$(csldirs)" && echo $${d1%% *})

# I will have a small number of special targets for use while testing
# and developing. These just abbreviate fuller targets, so for instance on
# Windows "make cygwin::reduce.img" should build the straightforward
# version of Reduce under cygwin, while on all systems "make main::reduce.img"
# builds the version for the "first" configured directory.

.PHONY:	cygwin\:\:csl cygwin\:\:csl.img cygwin\:\:bootstrapreduce \
		cygwin\:\:bootstrapreduce.img cygwin\:\:reduce \
		cygwin\:\:reduce.img windows\:\:csl windows\:\:csl.img \
		windows\:\:bootstrapreduce windows\:\:bootstrapreduce.img \
		windows\:\:reduce windows\:\:reduce.img main\:\:csl \
		main\:\:csl.img main\:\:bootstrapreduce \
		main\:\:bootstrapreduce.img main\:\:reduce main\:\:reduce.img

cygwin\:\:csl:			cslbuild/x86_64-pc-cygwin/csl\:\:csl
cygwin\:\:csl.img:		cslbuild/x86_64-pc-cygwin/csl\:\:csl.img
cygwin\:\:bootstrapreduce:	cslbuild/x86_64-pc-cygwin/csl\:\:bootstrapreduce
cygwin\:\:bootstrapreduce.img:	cslbuild/x86_64-pc-cygwin/csl\:\:bootstrapreduce.img
cygwin\:\:reduce:		cslbuild/x86_64-pc-cygwin/csl\:\:reduce
cygwin\:\:preduce.img:		cslbuild/x86_64-pc-cygwin/csl\:\:reduce.img
windows\:\:csl:			cslbuild/x86_64-pc-windows/csl\:\:csl
windows\:\:csl.img:		cslbuild/x86_64-pc-windows/csl\:\:csl.img
windows\:\:bootstrapreduce:	cslbuild/x86_64-pc-windows/csl\:\:bootstrapreduce
windows\:\:bootstrapreduce.img:	cslbuild/x86_64-pc-windows/csl\:\:bootstrapreduce.img
windows\:\:reduce:		cslbuild/x86_64-pc-windows/csl\:\:reduce
windows\:\:reduce.img:		cslbuild/x86_64-pc-windows/csl\:\:reduce.img
main\:\:csl:			$(csldirs1)\:\:csl
main\:\:csl.img:		$(csldirs1)\:\:csl.img
main\:\:bootstrapreduce:	$(csldirs1)\:\:bootstrapreduce
main\:\:bootstrapreduce.img:	$(csldirs1)\:\:bootstrapreduce.img
main\:\:reduce:			$(csldirs1)\:\:reduce
main\:\:reduce.img:		$(csldirs1)\:\:reduce.img

csldirs1 := $(firstword $(csldirs))

# The list of psltargets is extracted from psl/Makefile.am, and if new
# targets are introduced there then this list will need updating


@@ 112,9 71,12 @@ psltargets := \
	deps/core-packages.psl-make deps/core-packages.psl-depend \
	deps/noncore-packages.psl-make deps/noncore-packages.psl-depend \
	red/reduce.img install-exex-local uninstall-local

psldirs := $(wildcard pslbuild/*-*-*)

bothtargets = all clean
bothtargets = __all install uninstall

bothdirs := $(csldirs) $(psldirs)

# Find the number of available cpus and insert "-j N" if you are a top-level
# invocation of "make". If the user specified "-j N" or "--jobs=N" then


@@ 125,89 87,82 @@ ifeq "0" "$(MAKELEVEL)"
MAKEFLAGS := -j$(shell nproc || sysctl -n hw.ncpu || printf "1") $(MAKEFLAGS)
endif

# fulltargets ends up as a list showing each directory paired with every
# target that will be within it. The two components are separated with a
# double colon - which is a character sequence not expected to arise in any
# real directory or target name, if only because casual use of it could
# confuse "make".


fullcsltargets := \
	$(foreach d,$(csldirs), \
		$(foreach t,$(csltargets),$d\:\:$t))

fullcsltargets1 := \
	$(foreach d,$(csldirs1), \
		$(foreach t,$(csltargets1),$d\:\:$t))

fullpsltargets := \
	$(foreach d,$(psldirs), \
		$(foreach t,$(psltargets),$d\:\:$t))

fullbothtargets := \
	$(foreach d,$(csldirs) $(psldirs), \
		$(foreach t,$(bothtargets),$d\:\:$t))

.PHONY:	show \
	$(csltargets) $(fullcsltargets) $(csltargets1) $(bothtargets) \
	$(fullcsltargets1) $(psltargets) $(fullpsltargets) \
	$(fullbothtargets)

# The next line makes (eg) an attempt to build p1 in fact lead to
# a build request for each of d1::p1, d2::p1 etc. by setting up dependencies.

# Here are three alternatives to use of $(shell) that I had tried without
# success:
#$(Xtargets):	$(foreach d,$(Xdirs), $d\:\:$@)
#$(Xtargets):	$(patsubst %,%\:\:$@, $(Xdirs))
#$(Xtargets):	$(Xdirs:%=%\:\:$@)

.SECONDEXPANSION:

cslcmd = for i in $(csldirs)\; do echo $$$$i\:\:$$@\; done
cslcmd1 = for i in $(csldirs1)\; do echo $$$$i\:\:$$@\; done
pslcmd = for i in $(psldirs)\; do echo $$$$i\:\:$$@\; done
bothcmd = for i in $(csldirs) $(psldirs)\; do echo $$$$i\:\:$$@\; done

$(csltargets) csl:	$$(shell $(cslcmd))
	@printf "+++ make [CSL] $@: $^\n"

$(csltargets1):	$$(shell $(cslcmd1))
	@printf "+++ make [CSL1] $@: $^\n"

$(psltargets) psl:	$$(shell $(pslcmd))
	@printf "+++ make [PSL] $@: $^\n"

$(bothtargets) all:	$$(shell $(bothcmd))
	@printf "+++ make [both] $@: $^\n"

# Now I arrange that "make d1::p1" triggers "make -C d1 p1" so that p1
# gets built within the directory d1.

# $(patsubst %,%\:\:%, $(csldirs) $(psldirs)):
#	@a="$@" && printf "Build in $${a%%::*} for $${a##*::}\n" && \
#		   $(MAKE) -C "$${a%%::*}" "$${a##*::}"

$(fullcsltargets) $(fullcsltargets1) $(fullpsltargets) $(fullbothtargets):
	@a="$@" && printf "Build in $${a%%::*} for $${a##*::}\n" && \
		   $(MAKE) -C "$${a%%::*}" "$${a##*::}"

# While debugging (at least) I wanted a target that displays some
# of the information I have collected... "make show" does that.

show:
	@printf "MAKELEVEL = %s\n" "$(MAKELEVEL)"
	@printf "MAKEFLAGS = %s\n" "$(MAKEFLAGS)"
	@printf "csltargets = %s\n" "$(csltargets)"
	@printf "csltargets1 = %s\n" "$(csltargets1)"
	@printf "psltargets = %s\n" "$(psltargets)"
	@printf "bothtargets = %s\n" "$(bothtargets)"
	@printf "csldirs = %s\n" "$(csldirs)"
	@printf "csldirs1 = %s\n" "$(csldirs1)"
	@printf "psldirs = %s\n" "$(psldirs)"
	@printf "fullcsltargets = %s\n" "$(fullcsltargets)"
	@printf "fullcsltargets1 = %s\n" "$(fullcsltargets1)"
	@printf "fullpsltargets = %s\n" "$(fullpsltargets)"
	@printf "fullbothtargets = %s\n" "$(fullbothtargets)"
.PHONY:	all $(bothtargets) clean $(csltargets) $(csltargets1) $(psltargets)

all $(bothtargets):
	@c="$(bothdirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
	i=1 && \
	printf ".PHONY:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	printf "all:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	for d in $$c; \
	do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
	   i=$$(($$i+1)); \
	done ) | $(MAKE) -f -

clean:
	for d in `find cslbuild -name Makefile` `find pslbuild -name Makefile`; \
	do $(MAKE) -C `dirname $$d` clean; \
	   $(MAKE) -C `dirname $d` uninstall; \
	done
	rm -rf cslbuild/generated-c/*.img cslbuild/generated-c/u*

$(csltargets):
	@c="$(csldirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
	i=1 && \
	printf ".PHONY:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	printf "all:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	for d in $$c; \
	do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
	   i=$$(($$i+1)); \
	done ) | $(MAKE) -f -

$(csltargets1):
	$(MAKE) -C $(csldirs1) $@; \

$(psltargets):
	@c="$(psldirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
	i=1 && \
	printf ".PHONY:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	printf "all:\t" && \
	for d in $$c; \
	do printf " __$$i"; \
	   i=$$(($$i+1)); \
	done && \
	printf "\n\n" && \
	i=1 && \
	for d in $$c; \
	do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
	   i=$$(($$i+1)); \
	done ) | $(MAKE) -f -

# end of Makefile

M autogen.sh => autogen.sh +6 -6
@@ 116,7 116,7 @@ L="./scripts ./libraries/crlibm ./libraries/$LIBEDIT_VERSION \
case $a in
*--without-psl* | *with-psl=no*)
  ;;
*--with-psl*)
*--with-psl* | *--with-both*)
  L="$L ./psl"
  ;;
*)


@@ 137,9 137,9 @@ case $a in
esac

case $a in
*--without-csl* | *with-csl=no*)
*--without-csl* | *--with-csl=no*)
  ;;
*--with-csl*)
*--with-csl* | *--with-both*)
  L="$L ./csl ./csl/cslbase ./csl/cslbase-nothrow ./libraries/SoftFloat-3a/source"
# On Apple m1 (ie arm64) I will want to build a universal version of the
# libffi library and that is done in a way that differs from standrad builds.


@@ 179,14 179,14 @@ do
      ( printf "$d: $LIBTOOLIZE/aclocal/autoreconf -i -v\n" && \
        $LIBTOOLIZE --copy && \
        aclocal && \
        autoreconf -i ) &
        autoreconf -f -i -v ) &
      procids="$procids $!"
    else
      printf "$d: $LIBTOOLIZE --force --copy; aclocal --force\n"
      $LIBTOOLIZE --force --copy
      printf "$d: aclocal/autoreconf -f -i\n"
      printf "$d: aclocal/autoreconf -f -i -v\n"
      aclocal --force
      autoreconf -f -i
      autoreconf -f -i -v
    fi
    cd $here
  fi

M csl/cslbase/configure.ac => csl/cslbase/configure.ac +20 -3
@@ 1819,10 1819,27 @@ CYG_FLATCSL = $(with_cygbuild64)/csl/flatcsl.exe
CYG_BOOTSTRAPREDUCE = $(with_cygbuild64)/csl/bootstrapreduce.exe
CYG_REDUCE = $(with_cygbuild64)/csl/reduce.exe
CYG_FWINDEMO = $(with_cygbuild64)/csl/fwindemo.exe
.PHONY:	$(CYG_CSL) $(CYG_FLATCSL) $(CYG_BOOTSTRAPREDUCE) \
		$(CYG_REDUCE) $(CYG_FWINDEMO)
$(CYG_CSL) $(CYG_FLATCSL) $(CYG_BOOTSTRAPREDUCE) $(CYG_REDUCE) $(CYG_FWINDEMO):

$(CYG_CSL):
	@printf "About to make %s in directory %s from %s\n" "$(notdir $@)" "$(with_cygbuild64)" "`pwd`"
	$(MAKE) -C $(with_cygbuild64)/csl $(notdir $@)

$(CYG_FLATCSL):
	@printf "About to make %s in directory %s from %s\n" "$(notdir $@)" "$(with_cygbuild64)" "`pwd`"
	$(MAKE) -C $(with_cygbuild64)/csl $(notdir $@)

$(CYG_BOOTSTRAPREDUCE):
	@printf "About to make %s in directory %s from %s\n" "$(notdir $@)" "$(with_cygbuild64)" "`pwd`"
	$(MAKE) -C $(with_cygbuild64)/csl $(notdir $@)

$(CYG_REDUCE):
	@printf "About to make %s in directory %s from %s\n" "$(notdir $@)" "$(with_cygbuild64)" "`pwd`"
	$(MAKE) -C $(with_cygbuild64)/csl $(notdir $@)

$(CYG_FWINDEMO):
	@printf "About to make %s in directory %s from %s\n" "$(notdir $@)" "$(with_cygbuild64)" "`pwd`"
	$(MAKE) -C $(with_cygbuild64)/csl $(notdir $@)

endif
'
AC_SUBST([CYGWIN_DIR])

M csl/cslbase/eval2.cpp => csl/cslbase/eval2.cpp +1 -0
@@ 1,5 1,6 @@
// eval2.cpp                               Copyright (C) 1989-2021 Codemist


//
// Interpreter (part 2).  apply & some special forms
//

M csl/cslbase/externs.h => csl/cslbase/externs.h +1 -0
@@ 1099,6 1099,7 @@ typedef struct setup_type
    two_args *two;
    three_args *three;
    fourup_args *fourup;
    int nargs;
} setup_type;

// In many cases a function will take a fixed number of arguments,

M csl/cslbase/fns2.cpp => csl/cslbase/fns2.cpp +22 -3
@@ 275,7 275,7 @@ LispObject Lobject_header(LispObject env, LispObject a)
}

LispObject Lsymbol_argcount(LispObject env, LispObject a)
// For debugging use. Only valid if the function involved
// For debugging use. Mostly only valid if the function involved
// is byte-coded. For simple functions taking a fixed number of args the
// result is an integer. Otherwise it is a list of 3 items
//   (fewest-legal-args most-args-before-&rest flags)


@@ 298,9 298,9 @@ LispObject Lsymbol_argcount(LispObject env, LispObject a)
    f2 = qfn2(a);
    f3 = qfn3(a);
    f4up = qfn4up(a);
// If a function in the kernel takea a fixed number of args then all its
// If a function in the kernel takes a fixed number of args then all its
// function cells other than the operative one will contain entrypoints
// of code to report the error.
// of code to report the error. Actually the code 
    if (f1==G1W0 && f2==G2W0 && f3==G3W0 && f4up==G4W0)
        return onevalue(fixnum_of_int(0));
    if (f0==G0W1 && f2==G2W1 && f3==G3W1 && f4up==G4W1)


@@ 312,6 312,25 @@ LispObject Lsymbol_argcount(LispObject env, LispObject a)
// If a function takes 4 or more arguments all I can see is that
// its definition is in qfn4up() and I have no obvious way to tell whether
// it wants 4, 5, 6 or whatever args.
//
// If s sunction is interpreted all the function calls refer back to the
// interpreter, and the env cell is the lambda expression.
    if (f0 == interpreted_0)
    {   r = car(qenv(a));  // argument list
        int n = 0;
// If any of the Common Lisp "magic words" appear I will give up.
        while (consp(r))
        {   if (!symbolp(car(r)) ||
                car(r) == opt_key ||
                car(r) == rest_key ||
                car(r) == key_key ||
                car(r) == aux_key ||
                car(r) == allow_other_keys) return onevalue(nil);
            n++;
            r = cdr(r);
        }
        return onevalue(fixnum_of_int(n));      
    }
    r = qenv(a);
    if (!consp(r)) return onevalue(nil);
    r = car(r);

M csl/cslbase/version.h => csl/cslbase/version.h +1 -1
@@ 39,7 39,7 @@
// (scripts/commit.sh) that is used to update the subversion repository to
// update the revision number here.

#define REVISION 5847
#define REVISION 5854

#endif // header_version_h


A csl/m4/.gitignore => csl/m4/.gitignore +0 -0
M generic/newfront/configure.ac => generic/newfront/configure.ac +3 -0
@@ 135,6 135,9 @@ AC_ARG_WITH(win32bit,
AC_ARG_WITH(c32,
  AS_HELP_STRING([--with-c32], [not relevent here]))

AC_ARG_WITH(both,
  AS_HELP_STRING([--with-both], [not relevent here]))


AM_CONDITIONAL(DEBUG,   test "x$debug" = "xyes")
AM_CONDITIONAL(WINDOWS, test "x$on_windows" = "xyes")

D packages/alg/genmod.red => packages/alg/genmod.red +0 -250
@@ 1,250 0,0 @@
module genmod; % Modular arithmetic where the modulus may be any size.

% Authors: A. C. Norman and P. M. A. Moore, 1981.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%


% Modifications by: John Abbott.

% Note: when balanced_mod is on, the results here are not always in
% range. *modular2f is used to correct this. However, these routines
% should be updated to give balanced results.

fluid '(!*balanced_mod current!-modulus modulus!/2);

global '(largest!-small!-modulus);

symbolic procedure set!-general!-modulus p;
  if not numberp p or p=0 then current!-modulus
   else begin
     scalar previous!-modulus;
     previous!-modulus:=current!-modulus;
     current!-modulus:=p;
     modulus!/2 := p/2;
% Allow for use of small moduli where appropriate. What this bit is about is
% that CSL supports "set-small-modulus" setting a general potentially bignum
% modulus, and modular-plus and related functions then handle the big cases
% gracefully, meaning that the functions here like general-modular-plus are
% basically redundant. I am now making Jlisp do the same. But rather than
% checking the identity of the Lisp system I now see if set!-small!-modulus
% will accept an argument that is rather large. I test at 2^64 because I
% expect that to be above any reasonable "small" range.
% The re-binding of !*protfg is to prevent rederr from displaying a message
% if things fail.
#if (errorp (errorset
      '((lambda (!*protfg) (set!-small!-modulus (expt 2 64))) t)
      nil nil))
     if p <= largest!-small!-modulus then
#endif
        set!-small!-modulus p;
     return previous!-modulus
  end;

symbolic procedure general!-modular!-plus(a,b);
  begin scalar result;
     result:=a+b;
     if result >= current!-modulus then result:=result-current!-modulus;
     return result
  end;

symbolic procedure general!-modular!-difference(a,b);
  begin scalar result;
     result := a - b;
     if result < 0 then result:=result+current!-modulus;
     return result
  end;

symbolic procedure general!-modular!-number a;
  begin
     a:=remainder(a,current!-modulus);
     if a < 0 then a:=a+current!-modulus;
     return a
  end;

symbolic procedure general!-modular!-times(a,b);
  begin scalar result;
     result:=remainder(a*b,current!-modulus);
     if result<0
       then result := result+current!-modulus;  %can this happen?
     return result
  end;

symbolic procedure general!-modular!-reciprocal a;
   % Note this returns a positive result.
   if !*balanced_mod and a<0
     then general!-reciprocal!-by!-gcd(current!-modulus,
                                       a + current!-modulus,0,1)
    else general!-reciprocal!-by!-gcd(current!-modulus,a,0,1);

symbolic procedure general!-modular!-quotient(a,b);
    general!-modular!-times(a,general!-modular!-reciprocal b);

symbolic procedure general!-modular!-minus a;
    if a=0 then a else current!-modulus - a;

%symbolic procedure general!-reciprocal!-by!-gcd(a,b,x,y);
%%On input A and B should be coprime. This routine then
%%finds X and Y such that A*X+B*Y=1, and returns the value Y
%%on input A > B;
%   if b=0 then rerror(alg,8,"Invalid modular division")
%   else if b=1 then if y < 0 then y+current!-modulus else y
%   else begin scalar w;
%%N.B. Invalid modular division is either:
%% a)  attempt to divide by zero directly
%% b)  modulus is not prime, and input is not
%%     coprime with it;
%     w:=quotient(a,b); %Truncated integer division;
%     return general!-reciprocal!-by!-gcd(b,a-b*w,y,x-y*w)
%   end;

% Now a version that does not rely on tail-recursion elimination.
% For reasons I do not quite understand CSL leaves the above using
% tail calls in the bytecodes but it may still use too much stack.

symbolic procedure general!-reciprocal!-by!-gcd(a,b,x,y);
%On input A and B should be coprime. This routine then
%finds X and Y such that A*X+B*Y=1, and returns the value Y
%on input A > B;
  begin
   scalar w, tmp;
top:
   if b=0 then return rerror(alg,8,"Invalid modular division")
   else if b=1 then return (if y < 0 then y+current!-modulus else y);
%N.B. Invalid modular division is either:
% a)  attempt to divide by zero directly
% b)  modulus is not prime, and input is not
%     coprime with it;
    w := quotient(a,b); %Truncated integer division;
    tmp := a;
    a := b;
    b := tmp - b*w;
    tmp := x;
    x := y;
    y := tmp - y*w;
    go to top
  end;

% The next two functions compute the "reverse" of a binary number.
% This is the number obtained when writing down the binary expansion
% in reverse order.  If 2^r divides n (but 2^(r+1) does not) then
% reverse-num(reverse-num(n)) = abs(n)/2^r. r can be computed using
% height2.

symbolic procedure reverse!-num(n);
   if n = 0 then n
    else if n<0 then -reverse!-num1(-n,ilog2(-n)+1)
    else reverse!-num1(n,ilog2(n)+1);

global '(reverse!-num!-table!*);

reverse!-num!-table!* := mkvect 16;
putv(reverse!-num!-table!*,1,8);
putv(reverse!-num!-table!*,2,4);
putv(reverse!-num!-table!*,3,12);
putv(reverse!-num!-table!*,4,2);
putv(reverse!-num!-table!*,5,10);
putv(reverse!-num!-table!*,6,6);
putv(reverse!-num!-table!*,7,14);
putv(reverse!-num!-table!*,8,1);
putv(reverse!-num!-table!*,9,9);
putv(reverse!-num!-table!*,10,5);
putv(reverse!-num!-table!*,11,13);
putv(reverse!-num!-table!*,12,3);
putv(reverse!-num!-table!*,13,11);
putv(reverse!-num!-table!*,14,7);
putv(reverse!-num!-table!*,15,15);

symbolic procedure reverse!-num1(n,bits);
   if n = 0 then 0
    else if bits = 1 then n
    else if bits = 2 then getv(reverse!-num!-table!*,4*n)
    else if bits = 3 then getv(reverse!-num!-table!*,2*n)
    else if bits = 4 then getv(reverse!-num!-table!*,n)
    else begin scalar shift,qr;
       shift := 2**(bits/2);
       qr := divide(n,shift);
       if not evenp bits then shift := shift*2;
       return reverse!-num1(cdr qr,bits/2)*shift +
           reverse!-num1(car qr,(bits+1)/2)
   end;

% Interface to algebraic mode.

flag('(reverse!-num),'integer);

deflist('((reverse!-num rnreverse!-num!*)),'!:rn!:);

%put('fibonacci,'!:rn!:,'rnfibonacci!*);

put('reverse!-num,'number!-of!-args,1);

put('reverse!-num,'simpfn,'simpiden);

symbolic procedure rnreverse!-num!*(x);
   (if fixp y then reverse!-num(y)
    else !*p2f mksp(list('reverse!-num,y),1))
    where y=rnfixchk x;

% Interface to algebraic mode.

put('reverse!-num, 'simpfn, 'simpreverse!-num);

symbolic procedure simpreverse!-num(u);
   begin scalar arg;
      if length(u) neq 1 then typerr(u,"integer");
      arg := simpcar u;
      if denr(arg) neq 1 or not fixp(numr(arg))
        then rederr("reverse!-num: argument should be an integer");
      return reverse!-num(numr(arg)) ./ 1
   end;

% This is an iterative version of general!-modular!-expt.
% Its principal advantage over the (simpler) recursive implementation
% is that it avoids excessive memory consumption when both n and the
% modulus are quite large -- try primep(2^10007-1) if you don't believe
% it!

symbolic procedure general!-modular!-expt(a,n);
   % Computes a**n modulo current-modulus.  Uses Fermat's Little
   % Theorem where appropriate for a prime modulus.
    if a=0 then if n=0 then rerror(alg,101,"0^0 formed") else 0
    else if n=0 then 1
    else if n=1 then a
    else if n>=current!-modulus-1 and primep current!-modulus
     then general!-modular!-expt(a,remainder(n,current!-modulus-1))
    else begin scalar x, revn;
      while evenp n do <<n := n/2; a := general!-modular!-times(a,a)>>;
      revn := reverse!-num n;
      x := 1;
      while revn>0 do
      <<x := general!-modular!-times(x,x);
        if not evenp(revn) then x := general!-modular!-times(x,a);
        revn := revn/2>>;
      return x
    end;

endmodule;

end;

D packages/alg/random.red => packages/alg/random.red +0 -140
@@ 1,140 0,0 @@
module random;  % Random Number Generator.

% Author: C.J. Neerdaels, with adjustments by A.C. Norman.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%


% Entrypoints:
%     random_new_seed n Re-seed the random number generator
%     random n          return next value (range 0 <= r < n)
%     next!-random!-number()
%                       return next value in range 0<=r<randommodulus!*

% Note that random_new_seed is automatically called with argument 1 if
% the user does not explicitly call it with some other argument, and
% that resetting the seed in the generator is a fairly expensive
% business. % The argument to random() may be integer or floating, large
% or small, but should be strictly positive.


global '(unidev_vec!* randommodulus!*);
global '(unidev_fac!* unidev_next!* unidev_nextp!* unidev_mj!*);
global '(randomseed!*);

unidev_vec!* := mkvect(54)$
randommodulus!* := 100000000; % This is a fixnum in PSL and CSL (10^8).
unidev_fac!* :=  1.0/randommodulus!*;

% The following two lines are for speed fanatics - they should be OK
% with both PSL and CSL (as of June 1993).  They can be removed with no
% serious effect to code that is not random-number intensive.

% compiletime on fastfor;
% compiletime flag('(randommodulus!* unidev_fac!*), 'constant!?);

flag('(random random_new_seed),'opfn); % Make symbolic operators.

symbolic procedure random_new_seed offset;
% Sets the unidev seed to offset
  begin scalar mj, mk, ml, ii;
    if not fixp offset or offset <= 0
      then typerr(offset,"positive integer");
    mj := remainder(offset, randommodulus!*);
    putv(unidev_vec!*, 54, mj);
    mk := mj + 1;          % This arranges that one entry in the vector
                           % will end up with '1' in it, and that is
                           % enough to ensure we get a long cycle.
    for i:= 1:54 do <<
      ml := mk #- mj;
      if iminusp ml then ml := ml #+ randommodulus!*;
      ii := remainder(21*i,55);
      putv(unidev_vec!*, ii #- 1, ml);
      mk := mj;
      mj := ml >>;
    for k:=1:4 do <<      % Cycle generator a few times to pre-scramble.
      for i:=0:54 do <<
        ml := getv(unidev_vec!*, i) #-
              getv(unidev_vec!*, remainder(i #+ 31,55));
        if iminusp ml then ml := ml #+ randommodulus!*;
        putv(unidev_vec!*, i, ml) >> >>;
    unidev_next!* := 0;
    unidev_nextp!* := 31;
    return nil
  end;

%*************************UNIDEV****************************************

symbolic procedure next!-random!-number;
% Returns a uniform random deviate between 0 and randommodulus!*-1.
  begin scalar mj;
    if unidev_next!* = 54 then unidev!_next!* := 0
     else unidev!_next!* := unidev!_next!* #+ 1;
    if unidev!_nextp!* = 54 then unidev!_nextp!* := 0
     else unidev!_nextp!* := unidev!_nextp!* #+ 1;
    mj := getv(unidev_vec!*, unidev_next!*) #-
          getv(unidev_vec!*, unidev_nextp!*);
    if iminusp mj then mj := mj #+ randommodulus!*;
    putv(unidev_vec!*, unidev_next!*, mj);
    return mj
  end;

symbolic procedure random size;
% Returns a random value in the range 0 <= r < size.
  begin scalar m, r;
    if not numberp size or size <= 0
      then typerr(size,"positive number");
    if floatp size then <<
% next!-random!-number() returns just under 27 bits of randomness, and
% for a properly random double precision (IEEE) value I need 52 or 53
% bits.  So I just call next!-random!-number() twice and glue the bits
% together.
      r := float next!-random!-number() * unidev_fac!*;
      return (float next!-random!-number() + r) * unidev_fac!* * size >>
    else <<
% I first generate a random variate over a range that is some power of
% randommodulus!*.  Then I select from this to restrict my range to be
% an exact multiple of size.  The worst case for this selection is when
% the power of randommodulus!* is just less than twice size, in which
% case on average two trials are needed.  In the vast majority of cases
% the cost of making the selection will be much less.  With a value
% uniform over some multiple of my range I can use simple remaindering
% to get the result.
      repeat <<
        r := next!-random!-number();
        m := randommodulus!*;
        while m < size do <<
          m := m * randommodulus!*;
          r := randommodulus!* * r + next!-random!-number() >>;
        >> until r < m - remainder(m, size);
      return remainder(r, size) >>
  end;

random_new_seed 1;    % Ensure that code is set up ready for use.

endmodule;

end;



D packages/alg/smallmod.red => packages/alg/smallmod.red +0 -145
@@ 1,145 0,0 @@
module smallmod; % Small integer modular arithmetic used in factorizer.

% Author: Arthur C. Norman.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%


% Note: when balanced_mod is on, the results here are not always in
% range. *modular2f is used to correct this.

fluid '(!*balanced_mod current!-modulus modulus!/2);

global '(largest!-small!-modulus);

symbolic procedure set!-modulus p; set!-general!-modulus p;

symbolic procedure set!-small!-modulus p;
  begin
    scalar previous!-modulus;
    if p>largest!-small!-modulus
      then rerror(alg,9,list("Overlarge modulus",p,"being used"));
    previous!-modulus:=current!-modulus;
    current!-modulus:=p;
    modulus!/2 := p/2;
    return previous!-modulus
  end;


inline procedure modular!-plus(a,b);
  begin scalar result;
     result:=a #+ b;
     if not(result #< current!-modulus) then
            result:=result #- current!-modulus;
     return result
  end;

inline procedure modular!-difference(a,b);
  begin scalar result;
     result:=a #- b;
     if iminusp result then result:=result #+ current!-modulus;
     return result
  end;

symbolic procedure modular!-number a;
  begin
     if not atom a then typerr(a,"integer in modular-number");
     a:=remainder(a,current!-modulus);
     if iminusp a then a:=a #+ current!-modulus;
     return a
  end;

inline procedure modular!-times(a,b);
    remainder(a*b,current!-modulus);

symbolic procedure modular!-reciprocal a;
   if !*balanced_mod and a<0
     then reciprocal!-by!-gcd(current!-modulus,
                              a #+ current!-modulus,0,1)
    else reciprocal!-by!-gcd(current!-modulus,a,0,1);

symbolic procedure reciprocal!-by!-gcd(a,b,x,y);
%On input A and B should be coprime. This routine then
%finds X and Y such that A*X+B*Y=1, and returns the value Y
%on input A > B;
   if b=0 then rerror(alg,10,"Invalid modular division")
   else if b=1 then if iminusp y then y #+ current!-modulus else y
   else begin scalar w;
%N.B. Invalid modular division is either:
% a)  attempt to divide by zero directly
% b)  modulus is not prime, and input is not
%     coprime with it;
     w:= a #/ b; %Truncated integer division;
     return reciprocal!-by!-gcd(b,a #- b #* w,
                                y,x #- y #* w)
   end;

symbolic procedure safe!-modular!-reciprocal a;
   if !*balanced_mod and a<0
     then safe!-reciprocal!-by!-gcd(current!-modulus,
                              a #+ current!-modulus,0,1)
    else safe!-reciprocal!-by!-gcd(current!-modulus,a,0,1);

symbolic procedure safe!-reciprocal!-by!-gcd(a,b,x,y);
%On input A and B should be coprime. This routine then
%finds X and Y such that A*X+B*Y=1, and returns the value Y
%on input A > B. If a and b are not coprime return NIL not an error; 
   if b=0 then nil
   else if b=1 then if iminusp y then y #+ current!-modulus else y
   else begin scalar w;
%N.B. Invalid modular division is either:
% a)  attempt to divide by zero directly
% b)  modulus is not prime, and input is not
%     coprime with it;
     w:= a #/ b; %Truncated integer division;
     return safe!-reciprocal!-by!-gcd(b,a #- b #* w,
                                      y,x #- y #* w)
   end;

inline procedure modular!-quotient(a,b);
    modular!-times(a,modular!-reciprocal b);


inline procedure modular!-minus a;
    if a=0 then a else current!-modulus #- a;

symbolic procedure modular!-expt(a,n);
   % Computes a**n modulo current-modulus.  Uses Fermat's Little
   % Theorem where appropriate for a prime modulus.
    if n=0 then 1
    else if n=1 then a
    else if n>=current!-modulus-1 and primep current!-modulus
     then modular!-expt(a,remainder(n,current!-modulus-1))
    else begin scalar x;
     x:=modular!-expt(a,n/2);
     x:=modular!-times(x,x);
     if not(remainder(n,2)=0) then x:=modular!-times(x,a);
     return x
    end;

symbolic set!-modulus(1) ; % forces everything into a standard state.

endmodule;

end;

D packages/alg/sort.red => packages/alg/sort.red +0 -157
@@ 1,157 0,0 @@
module sort;  % A simple sorting routine.

% Author: Arthur C. Norman.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%


symbolic procedure sort(l,pred);
   % Sort the list l according to the given predicate.  If l is a list
   % of numbers then the predicate "lessp" will sort the list into
   % ascending order.  The predicate should be a strict inequality,
   % i.e. it should return NIL if the two items compared are equal.  As
   % implemented here SORT just calls STABLE-SORT, but as a matter of
   % style any use where the ordering of incomparable items in the
   % output matters ought to use STABLE!-SORT directly, thereby
   % allowing the replacement of this code with a faster non-stable
   % method. (Note: the previous REDUCE sort function also happened to
   % be stable, so this code should give exactly the same results for
   % all calls where the predicate is self-consistent and never has
   % both pred(a,b) and pred(b,a) true).
   stable!-sortip(append(l, nil), pred);

symbolic procedure stable!-sort(l,pred);
   % Sorts a list, as SORT, but if two items x and y in the input list
   % satisfy neither pred(x,y) nor pred(y,x) [i.e. they are equal so far
   % as the given ordering predicate is concerned] this function
   % guarantees that they will appear in the output list in the same
   % order that they were in the input.
   stable!-sortip(append(l, nil), pred);

symbolic procedure stable!-sortip(l, pred);
   % As stable!-sort, but over-writes the input list to make the output.
   % It is not intended that people should call this function directly:
   % it is present just as the implementation of the main sort
   % procedures defined above.
   begin scalar l1,l2,w;
      if null l then return l;    % Input list of length 0
      l1 := l;
      l2 := cdr l;
      if null l2 then return l;   % Input list of length 1
      % Now I have dealt with the essential special cases of lists of
      % length 0 and 1 (which do not need sorting at all).  Since it
      % possibly speeds things up just a little I will now have some
      % fairly ugly code that makes special cases of lists of length 2.
      % I could easily have special code for length 3 lists here (and
      % include it, but commented out), but at present my measurements
      % suggest that the speed improvement that it gives is minimal and
      % the increase in code bulk is large enough to give some pain.
      l := cdr l2;
      if null l then <<           % Input list of length 2
         if apply2(pred, car l2, car l1) then <<
            l := car l1;
            rplaca(l1, car l2);
            rplaca(l2, l) >>;
       return l1 >>;
      % Now I will check to see if the list is in fact in order already
      % Doing so will have a cost - but sometimes that cost will be
      % repaid when I am able to exit especially early.  The result of
      % all this is that I will have a best case behaviour with linear
      % cost growth for inputs that are initially in the correct order,
      % while my average and worst-case costs will increase by a
      % constant factor.
      l := l1;
      % In the input list is NOT already in order then I expect that
      % this loop will exit fairly early, and so will not contribute
      % much to the total cost.  If it exits very late then probably in
      % the next recursion down the first half of the list will be
      % found to be already sorted, and again I have a chance to win.
      while l2 and not apply2(pred, car l2, car l) do
         <<l := l2; l2 := cdr l2 >>;
      if null l2 then return l1;
      l2 := l1;
      l := cddr l2;
      while l and cdr l do << l2 := cdr l2; l := cddr l >>;
      l := l2;
      l2 := cdr l2;
      rplacd(l, nil);
      % The two sub-lists are then sorted.
      l1 := stable!-sortip(l1, pred);
      l2 := stable!-sortip(l2, pred);
      % Now I merge the sorted fragments, giving priority to item from
      % the earlier part of the original list.
      l := w := list nil;
      while l1 and l2 do <<
         if apply2(pred, car l2, car l1) then <<
            rplacd(w, l2); w := l2; l2 := cdr l2 >>
         else <<rplacd(w, l1); w := l1; l1 := cdr l1>>>>;
      if l1 then l2 := l1;
      rplacd(w,l2);
      return cdr l
  end;

symbolic procedure idsort u;
   % lexicographically sort list of ids.
   sort(u,function idcompare);

symbolic procedure idcompare(u,v);
   % compare lexicographical ordering of two ids.
   idcomp1(explode2 u,explode2 v);

symbolic procedure idcomp1(u,v);
   if null u then t
    else if null v then nil
    else if car u eq car v then idcomp1(cdr u,cdr v)
    else orderp(car u,car v);

% Comparison functions and special cases for sorting.

% The next two are now provided in alg/general.red

%symbolic procedure lesspcar(u,v); car u < car v;
%symbolic procedure lesspcdr(u,v); cdr u < cdr v;

symbolic procedure lessppair(a,b);
    if car a = car b then cdr a<cdr b else car a<car b;

symbolic procedure greaterpcdr(a,b); cdr a > cdr b;

symbolic procedure lesspcdadr(a,b); cdadr a < cdadr b;

symbolic procedure lesspdeg(a,b);
   if domainp b then nil else if domainp a then t else ldeg a<ldeg b;

symbolic procedure ordopcar(a,b); ordop(car a,car b);

symbolic procedure orderfactors(a,b);
   if cdr a = cdr b then ordp(car a,car b) else cdr a < cdr b;

symbolic procedure sort!-factors l;
   % Sort factors as found into some sort of standard order.  The order
   % used here is more or less random, but will be self-consistent.
   sort(l,function orderfactors);

endmodule;

end;

D packages/rlisp/charname.red => packages/rlisp/charname.red +0 -2186
@@ 1,2186 0,0 @@
module charname; % Set up names for extended characters

% Author: Arthur Norman.

% Copyright (c) 2014 Arthur Norman.  All rights reserved.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%

% The data here is derived from the HTML Living Standard at
% http://whatwg.org which notes on its contents page
% "Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation,
%  and Opera Software ASA. You are granted a license to use, reproduce
%  and create derivative works of this document."
% It was extracted from their information in March 2014 and the "official"
% list may change at any stage after that.

% Some of the character names are shown as mapping onto pairs of Unicode
% symbols (&acE; is the first such: I might try to render it here as
% "~=", an &ac; sign (alternating current?) followed by a lowered equals
% sign). I have commented out all such cases in that it seems bad enough
% feel like worrying about things like &Afr; (Capital letter A rendered
% in a Fractur font at codepoint U+1d504) but support for Unicode
% combining marks and composites is a step too far for me at present!

% I have added a special extra &hash; to stand for "#" just for the
% convenience of Reduce. 

% Just so you know, there are somewhat over 2000 names here. Please be
% VERY aware that just because there is a name for an entity here that
% will not guarantee that it can be displayed, in that display will
% depend on at least the font you are using.

for each x in '( 
    ("Aacute"                          193)
    ("aacute"                          225)
    ("Abreve"                          258)
    ("abreve"                          259)
    ("ac"                              8766)
    ("acd"                             8767)
 %  ("acE"                             8766, 819)
    ("Acirc"                           194)
    ("acirc"                           226)
    ("acute"                           180)
    ("Acy"                             1040)
    ("acy"                             1072)
    ("AElig"                           198)
    ("aelig"                           230)
    ("af"                              8289)
    ("Afr"                             120068)
    ("afr"                             120094)
    ("Agrave"                          192)
    ("agrave"                          224)
    ("alefsym"                         8501)
    ("aleph"                           8501)
    ("Alpha"                           913)
    ("alpha"                           945)
    ("Amacr"                           256)
    ("amacr"                           257)
    ("amalg"                           10815)
    ("amp"                             38)
    ("AMP"                             38)
    ("andand"                          10837)
    ("And"                             10835)
    ("and"                             8743)
    ("andd"                            10844)
    ("andslope"                        10840)
    ("andv"                            10842)
    ("ang"                             8736)
    ("ange"                            10660)
    ("angle"                           8736)
    ("angmsdaa"                        10664)
    ("angmsdab"                        10665)
    ("angmsdac"                        10666)
    ("angmsdad"                        10667)
    ("angmsdae"                        10668)
    ("angmsdaf"                        10669)
    ("angmsdag"                        10670)
    ("angmsdah"                        10671)
    ("angmsd"                          8737)
    ("angrt"                           8735)
    ("angrtvb"                         8894)
    ("angrtvbd"                        10653)
    ("angsph"                          8738)
    ("angst"                           197)
    ("angzarr"                         9084)
    ("Aogon"                           260)
    ("aogon"                           261)
    ("Aopf"                            120120)
    ("aopf"                            120146)
    ("apacir"                          10863)
    ("ap"                              8776)
    ("apE"                             10864)
    ("ape"                             8778)
    ("apid"                            8779)
    ("apos"                            39)
    ("ApplyFunction"                   8289)
    ("approx"                          8776)
    ("approxeq"                        8778)
    ("Aring"                           197)
    ("aring"                           229)
    ("Ascr"                            119964)
    ("ascr"                            119990)
    ("Assign"                          8788)
    ("ast"                             42)
    ("asymp"                           8776)
    ("asympeq"                         8781)
    ("Atilde"                          195)
    ("atilde"                          227)
    ("Auml"                            196)
    ("auml"                            228)
    ("awconint"                        8755)
    ("awint"                           10769)
    ("backcong"                        8780)
    ("backepsilon"                     1014)
    ("backprime"                       8245)
    ("backsim"                         8765)
    ("backsimeq"                       8909)
    ("Backslash"                       8726)
    ("Barv"                            10983)
    ("barvee"                          8893)
    ("barwed"                          8965)
    ("Barwed"                          8966)
    ("barwedge"                        8965)
    ("bbrk"                            9141)
    ("bbrktbrk"                        9142)
    ("bcong"                           8780)
    ("Bcy"                             1041)
    ("bcy"                             1073)
    ("bdquo"                           8222)
    ("becaus"                          8757)
    ("because"                         8757)
    ("Because"                         8757)
    ("bemptyv"                         10672)
    ("bepsi"                           1014)
    ("bernou"                          8492)
    ("Bernoullis"                      8492)
    ("Beta"                            914)
    ("beta"                            946)
    ("beth"                            8502)
    ("between"                         8812)
    ("Bfr"                             120069)
    ("bfr"                             120095)
    ("bigcap"                          8898)
    ("bigcirc"                         9711)
    ("bigcup"                          8899)
    ("bigodot"                         10752)
    ("bigoplus"                        10753)
    ("bigotimes"                       10754)
    ("bigsqcup"                        10758)
    ("bigstar"                         9733)
    ("bigtriangledown"                 9661)
    ("bigtriangleup"                   9651)
    ("biguplus"                        10756)
    ("bigvee"                          8897)
    ("bigwedge"                        8896)
    ("bkarow"                          10509)
    ("blacklozenge"                    10731)
    ("blacksquare"                     9642)
    ("blacktriangle"                   9652)
    ("blacktriangledown"               9662)
    ("blacktriangleleft"               9666)
    ("blacktriangleright"              9656)
    ("blank"                           9251)
    ("blk12"                           9618)
    ("blk14"                           9617)
    ("blk34"                           9619)
    ("block"                           9608)
 %  ("bne"                             61, 8421)
 %  ("bnequiv"                         8801, 8421)
    ("bNot"                            10989)
    ("bnot"                            8976)
    ("Bopf"                            120121)
    ("bopf"                            120147)
    ("bot"                             8869)
    ("bottom"                          8869)
    ("bowtie"                          8904)
    ("boxbox"                          10697)
    ("boxdl"                           9488)
    ("boxdL"                           9557)
    ("boxDl"                           9558)
    ("boxDL"                           9559)
    ("boxdr"                           9484)
    ("boxdR"                           9554)
    ("boxDr"                           9555)
    ("boxDR"                           9556)
    ("boxh"                            9472)
    ("boxH"                            9552)
    ("boxhd"                           9516)
    ("boxHd"                           9572)
    ("boxhD"                           9573)
    ("boxHD"                           9574)
    ("boxhu"                           9524)
    ("boxHu"                           9575)
    ("boxhU"                           9576)
    ("boxHU"                           9577)
    ("boxminus"                        8863)
    ("boxplus"                         8862)
    ("boxtimes"                        8864)
    ("boxul"                           9496)
    ("boxuL"                           9563)
    ("boxUl"                           9564)
    ("boxUL"                           9565)
    ("boxur"                           9492)
    ("boxuR"                           9560)
    ("boxUr"                           9561)
    ("boxUR"                           9562)
    ("boxv"                            9474)
    ("boxV"                            9553)
    ("boxvh"                           9532)
    ("boxvH"                           9578)
    ("boxVh"                           9579)
    ("boxVH"                           9580)
    ("boxvl"                           9508)
    ("boxvL"                           9569)
    ("boxVl"                           9570)
    ("boxVL"                           9571)
    ("boxvr"                           9500)
    ("boxvR"                           9566)
    ("boxVr"                           9567)
    ("boxVR"                           9568)
    ("bprime"                          8245)
    ("breve"                           728)
    ("Breve"                           728)
    ("brvbar"                          166)
    ("bscr"                            119991)
    ("Bscr"                            8492)
    ("bsemi"                           8271)
    ("bsim"                            8765)
    ("bsime"                           8909)
    ("bsolb"                           10693)
    ("bsol"                            92)
    ("bsolhsub"                        10184)
    ("bull"                            8226)
    ("bullet"                          8226)
    ("bump"                            8782)
    ("bumpE"                           10926)
    ("bumpe"                           8783)
    ("Bumpeq"                          8782)
    ("bumpeq"                          8783)
    ("Cacute"                          262)
    ("cacute"                          263)
    ("capand"                          10820)
    ("capbrcup"                        10825)
    ("capcap"                          10827)
    ("cap"                             8745)
    ("Cap"                             8914)
    ("capcup"                          10823)
    ("capdot"                          10816)
    ("CapitalDifferentialD"            8517)
 %  ("caps"                            8745, 65024)
    ("caret"                           8257)
    ("caron"                           711)
    ("Cayleys"                         8493)
    ("ccaps"                           10829)
    ("Ccaron"                          268)
    ("ccaron"                          269)
    ("Ccedil"                          199)
    ("ccedil"                          231)
    ("Ccirc"                           264)
    ("ccirc"                           265)
    ("Cconint"                         8752)
    ("ccups"                           10828)
    ("ccupssm"                         10832)
    ("Cdot"                            266)
    ("cdot"                            267)
    ("cedil"                           184)
    ("Cedilla"                         184)
    ("cemptyv"                         10674)
    ("cent"                            162)
    ("centerdot"                       183)
    ("CenterDot"                       183)
    ("cfr"                             120096)
    ("Cfr"                             8493)
    ("CHcy"                            1063)
    ("chcy"                            1095)
    ("check"                           10003)
    ("checkmark"                       10003)
    ("Chi"                             935)
    ("chi"                             967)
    ("circ"                            710)
    ("circeq"                          8791)
    ("circlearrowleft"                 8634)
    ("circlearrowright"                8635)
    ("circledast"                      8859)
    ("circledcirc"                     8858)
    ("circleddash"                     8861)
    ("CircleDot"                       8857)
    ("circledR"                        174)
    ("circledS"                        9416)
    ("CircleMinus"                     8854)
    ("CirclePlus"                      8853)
    ("CircleTimes"                     8855)
    ("cir"                             9675)
    ("cirE"                            10691)
    ("cire"                            8791)
    ("cirfnint"                        10768)
    ("cirmid"                          10991)
    ("cirscir"                         10690)
    ("ClockwiseContourIntegral"        8754)
    ("CloseCurlyDoubleQuote"           8221)
    ("CloseCurlyQuote"                 8217)
    ("clubs"                           9827)
    ("clubsuit"                        9827)
    ("colon"                           58)
    ("Colon"                           8759)
    ("Colone"                          10868)
    ("colone"                          8788)
    ("coloneq"                         8788)
    ("comma"                           44)
    ("commat"                          64)
    ("comp"                            8705)
    ("compfn"                          8728)
    ("complement"                      8705)
    ("complexes"                       8450)
    ("cong"                            8773)
    ("congdot"                         10861)
    ("Congruent"                       8801)
    ("conint"                          8750)
    ("Conint"                          8751)
    ("ContourIntegral"                 8750)
    ("copf"                            120148)
    ("Copf"                            8450)
    ("coprod"                          8720)
    ("Coproduct"                       8720)
    ("copy"                            169)
    ("COPY"                            169)
    ("copysr"                          8471)
    ("CounterClockwiseContourIntegral" 8755)
    ("crarr"                           8629)
    ("cross"                           10007)
    ("Cross"                           10799)
    ("Cscr"                            119966)
    ("cscr"                            119992)
    ("csub"                            10959)
    ("csube"                           10961)
    ("csup"                            10960)
    ("csupe"                           10962)
    ("ctdot"                           8943)
    ("cudarrl"                         10552)
    ("cudarrr"                         10549)
    ("cuepr"                           8926)
    ("cuesc"                           8927)
    ("cularr"                          8630)
    ("cularrp"                         10557)
    ("cupbrcap"                        10824)
    ("cupcap"                          10822)
    ("CupCap"                          8781)
    ("cup"                             8746)
    ("Cup"                             8915)
    ("cupcup"                          10826)
    ("cupdot"                          8845)
    ("cupor"                           10821)
 %  ("cups"                            8746, 65024)
    ("curarr"                          8631)
    ("curarrm"                         10556)
    ("curlyeqprec"                     8926)
    ("curlyeqsucc"                     8927)
    ("curlyvee"                        8910)
    ("curlywedge"                      8911)
    ("curren"                          164)
    ("curvearrowleft"                  8630)
    ("curvearrowright"                 8631)
    ("cuvee"                           8910)
    ("cuwed"                           8911)
    ("cwconint"                        8754)
    ("cwint"                           8753)
    ("cylcty"                          9005)
    ("dagger"                          8224)
    ("Dagger"                          8225)
    ("daleth"                          8504)
    ("darr"                            8595)
    ("Darr"                            8609)
    ("dArr"                            8659)
    ("dash"                            8208)
    ("Dashv"                           10980)
    ("dashv"                           8867)
    ("dbkarow"                         10511)
    ("dblac"                           733)
    ("Dcaron"                          270)
    ("dcaron"                          271)
    ("Dcy"                             1044)
    ("dcy"                             1076)
    ("ddagger"                         8225)
    ("ddarr"                           8650)
    ("DD"                              8517)
    ("dd"                              8518)
    ("DDotrahd"                        10513)
    ("ddotseq"                         10871)
    ("deg"                             176)
    ("Del"                             8711)
    ("Delta"                           916)
    ("delta"                           948)
    ("demptyv"                         10673)
    ("dfisht"                          10623)
    ("Dfr"                             120071)
    ("dfr"                             120097)
    ("dHar"                            10597)
    ("dharl"                           8643)
    ("dharr"                           8642)
    ("DiacriticalAcute"                180)
    ("DiacriticalDot"                  729)
    ("DiacriticalDoubleAcute"          733)
    ("DiacriticalGrave"                96)
    ("DiacriticalTilde"                732)
    ("diam"                            8900)
    ("diamond"                         8900)
    ("Diamond"                         8900)
    ("diamondsuit"                     9830)
    ("diams"                           9830)
    ("die"                             168)
    ("DifferentialD"                   8518)
    ("digamma"                         989)
    ("disin"                           8946)
    ("div"                             247)
    ("divide"                          247)
    ("divideontimes"                   8903)
    ("divonx"                          8903)
    ("DJcy"                            1026)
    ("djcy"                            1106)
    ("dlcorn"                          8990)
    ("dlcrop"                          8973)
    ("dollar"                          36)
    ("Dopf"                            120123)
    ("dopf"                            120149)
    ("Dot"                             168)
    ("dot"                             729)
    ("DotDot"                          8412)
    ("doteq"                           8784)
    ("doteqdot"                        8785)
    ("DotEqual"                        8784)
    ("dotminus"                        8760)
    ("dotplus"                         8724)
    ("dotsquare"                       8865)
    ("doublebarwedge"                  8966)
    ("DoubleContourIntegral"           8751)
    ("DoubleDot"                       168)
    ("DoubleDownArrow"                 8659)
    ("DoubleLeftArrow"                 8656)
    ("DoubleLeftRightArrow"            8660)
    ("DoubleLeftTee"                   10980)
    ("DoubleLongLeftArrow"             10232)
    ("DoubleLongLeftRightArrow"        10234)
    ("DoubleLongRightArrow"            10233)
    ("DoubleRightArrow"                8658)
    ("DoubleRightTee"                  8872)
    ("DoubleUpArrow"                   8657)
    ("DoubleUpDownArrow"               8661)
    ("DoubleVerticalBar"               8741)
    ("DownArrowBar"                    10515)
    ("downarrow"                       8595)
    ("DownArrow"                       8595)
    ("Downarrow"                       8659)
    ("DownArrowUpArrow"                8693)
    ("DownBreve"                       785)
    ("downdownarrows"                  8650)
    ("downharpoonleft"                 8643)
    ("downharpoonright"                8642)
    ("DownLeftRightVector"             10576)
    ("DownLeftTeeVector"               10590)
    ("DownLeftVectorBar"               10582)
    ("DownLeftVector"                  8637)
    ("DownRightTeeVector"              10591)
    ("DownRightVectorBar"              10583)
    ("DownRightVector"                 8641)
    ("DownTeeArrow"                    8615)
    ("DownTee"                         8868)
    ("drbkarow"                        10512)
    ("drcorn"                          8991)
    ("drcrop"                          8972)
    ("Dscr"                            119967)
    ("dscr"                            119993)
    ("DScy"                            1029)
    ("dscy"                            1109)
    ("dsol"                            10742)
    ("Dstrok"                          272)
    ("dstrok"                          273)
    ("dtdot"                           8945)
    ("dtri"                            9663)
    ("dtrif"                           9662)
    ("duarr"                           8693)
    ("duhar"                           10607)
    ("dwangle"                         10662)
    ("DZcy"                            1039)
    ("dzcy"                            1119)
    ("dzigrarr"                        10239)
    ("Eacute"                          201)
    ("eacute"                          233)
    ("easter"                          10862)
    ("Ecaron"                          282)
    ("ecaron"                          283)
    ("Ecirc"                           202)
    ("ecirc"                           234)
    ("ecir"                            8790)
    ("ecolon"                          8789)
    ("Ecy"                             1069)
    ("ecy"                             1101)
    ("eDDot"                           10871)
    ("Edot"                            278)
    ("edot"                            279)
    ("eDot"                            8785)
    ("ee"                              8519)
    ("efDot"                           8786)
    ("Efr"                             120072)
    ("efr"                             120098)
    ("eg"                              10906)
    ("Egrave"                          200)
    ("egrave"                          232)
    ("egs"                             10902)
    ("egsdot"                          10904)
    ("el"                              10905)
    ("Element"                         8712)
    ("elinters"                        9191)
    ("ell"                             8467)
    ("els"                             10901)
    ("elsdot"                          10903)
    ("Emacr"                           274)
    ("emacr"                           275)
    ("empty"                           8709)
    ("emptyset"                        8709)
    ("EmptySmallSquare"                9723)
    ("emptyv"                          8709)
    ("EmptyVerySmallSquare"            9643)
    ("emsp13"                          8196)
    ("emsp14"                          8197)
    ("emsp"                            8195)
    ("ENG"                             330)
    ("eng"                             331)
    ("ensp"                            8194)
    ("Eogon"                           280)
    ("eogon"                           281)
    ("Eopf"                            120124)
    ("eopf"                            120150)
    ("epar"                            8917)
    ("eparsl"                          10723)
    ("eplus"                           10865)
    ("epsi"                            949)
    ("Epsilon"                         917)
    ("epsilon"                         949)
    ("epsiv"                           1013)
    ("eqcirc"                          8790)
    ("eqcolon"                         8789)
    ("eqsim"                           8770)
    ("eqslantgtr"                      10902)
    ("eqslantless"                     10901)
    ("Equal"                           10869)
    ("equals"                          61)
    ("EqualTilde"                      8770)
    ("equest"                          8799)
    ("Equilibrium"                     8652)
    ("equiv"                           8801)
    ("equivDD"                         10872)
    ("eqvparsl"                        10725)
    ("erarr"                           10609)
    ("erDot"                           8787)
    ("escr"                            8495)
    ("Escr"                            8496)
    ("esdot"                           8784)
    ("Esim"                            10867)
    ("esim"                            8770)
    ("Eta"                             919)
    ("eta"                             951)
    ("ETH"                             208)
    ("eth"                             240)
    ("Euml"                            203)
    ("euml"                            235)
    ("euro"                            8364)
    ("excl"                            33)
    ("exist"                           8707)
    ("Exists"                          8707)
    ("expectation"                     8496)
    ("exponentiale"                    8519)
    ("ExponentialE"                    8519)
    ("fallingdotseq"                   8786)
    ("Fcy"                             1060)
    ("fcy"                             1092)
    ("female"                          9792)
    ("ffilig"                          64259)
    ("fflig"                           64256)
    ("ffllig"                          64260)
    ("Ffr"                             120073)
    ("ffr"                             120099)
    ("filig"                           64257)
    ("FilledSmallSquare"               9724)
    ("FilledVerySmallSquare"           9642)
 %  ("fjlig"                           102, 106)
    ("flat"                            9837)
    ("fllig"                           64258)
    ("fltns"                           9649)
    ("fnof"                            402)
    ("Fopf"                            120125)
    ("fopf"                            120151)
    ("forall"                          8704)
    ("ForAll"                          8704)
    ("fork"                            8916)
    ("forkv"                           10969)
    ("Fouriertrf"                      8497)
    ("fpartint"                        10765)
    ("frac12"                          189)
    ("frac13"                          8531)
    ("frac14"                          188)
    ("frac15"                          8533)
    ("frac16"                          8537)
    ("frac18"                          8539)
    ("frac23"                          8532)
    ("frac25"                          8534)
    ("frac34"                          190)
    ("frac35"                          8535)
    ("frac38"                          8540)
    ("frac45"                          8536)
    ("frac56"                          8538)
    ("frac58"                          8541)
    ("frac78"                          8542)
    ("frasl"                           8260)
    ("frown"                           8994)
    ("fscr"                            119995)
    ("Fscr"                            8497)
    ("gacute"                          501)
    ("Gamma"                           915)
    ("gamma"                           947)
    ("Gammad"                          988)
    ("gammad"                          989)
    ("gap"                             10886)
    ("Gbreve"                          286)
    ("gbreve"                          287)
    ("Gcedil"                          290)
    ("Gcirc"                           284)
    ("gcirc"                           285)
    ("Gcy"                             1043)
    ("gcy"                             1075)
    ("Gdot"                            288)
    ("gdot"                            289)
    ("ge"                              8805)
    ("gE"                              8807)
    ("gEl"                             10892)
    ("gel"                             8923)
    ("geq"                             8805)
    ("geqq"                            8807)
    ("geqslant"                        10878)
    ("gescc"                           10921)
    ("ges"                             10878)
    ("gesdot"                          10880)
    ("gesdoto"                         10882)
    ("gesdotol"                        10884)
 %  ("gesl"                            8923, 65024)
    ("gesles"                          10900)
    ("Gfr"                             120074)
    ("gfr"                             120100)
    ("gg"                              8811)
    ("Gg"                              8921)
    ("ggg"                             8921)
    ("gimel"                           8503)
    ("GJcy"                            1027)
    ("gjcy"                            1107)
    ("gla"                             10917)
    ("gl"                              8823)
    ("glE"                             10898)
    ("glj"                             10916)
    ("gnap"                            10890)
    ("gnapprox"                        10890)
    ("gne"                             10888)
    ("gnE"                             8809)
    ("gneq"                            10888)
    ("gneqq"                           8809)
    ("gnsim"                           8935)
    ("Gopf"                            120126)
    ("gopf"                            120152)
    ("grave"                           96)
    ("GreaterEqual"                    8805)
    ("GreaterEqualLess"                8923)
    ("GreaterFullEqual"                8807)
    ("GreaterGreater"                  10914)
    ("GreaterLess"                     8823)
    ("GreaterSlantEqual"               10878)
    ("GreaterTilde"                    8819)
    ("Gscr"                            119970)
    ("gscr"                            8458)
    ("gsim"                            8819)
    ("gsime"                           10894)
    ("gsiml"                           10896)
    ("gtcc"                            10919)
    ("gtcir"                           10874)
    ("gt"                              62)
    ("GT"                              62)
    ("Gt"                              8811)
    ("gtdot"                           8919)
    ("gtlPar"                          10645)
    ("gtquest"                         10876)
    ("gtrapprox"                       10886)
    ("gtrarr"                          10616)
    ("gtrdot"                          8919)
    ("gtreqless"                       8923)
    ("gtreqqless"                      10892)
    ("gtrless"                         8823)
    ("gtrsim"                          8819)
 %  ("gvertneqq"                       8809, 65024)
 %  ("gvnE"                            8809, 65024)
    ("Hacek"                           711)
    ("hairsp"                          8202)
    ("half"                            189)
    ("hamilt"                          8459)
    ("HARDcy"                          1066)
    ("hardcy"                          1098)
    ("harrcir"                         10568)
    ("harr"                            8596)
    ("hArr"                            8660)
    ("harrw"                           8621)
    ("hash"                            35)    % Added by ACN
    ("Hat"                             94)
    ("hbar"                            8463)
    ("Hcirc"                           292)
    ("hcirc"                           293)
    ("hearts"                          9829)
    ("heartsuit"                       9829)
    ("hellip"                          8230)
    ("hercon"                          8889)
    ("hfr"                             120101)
    ("Hfr"                             8460)
    ("HilbertSpace"                    8459)
    ("hksearow"                        10533)
    ("hkswarow"                        10534)
    ("hoarr"                           8703)
    ("homtht"                          8763)
    ("hookleftarrow"                   8617)
    ("hookrightarrow"                  8618)
    ("hopf"                            120153)
    ("Hopf"                            8461)
    ("horbar"                          8213)
    ("HorizontalLine"                  9472)
    ("hscr"                            119997)
    ("Hscr"                            8459)
    ("hslash"                          8463)
    ("Hstrok"                          294)
    ("hstrok"                          295)
    ("HumpDownHump"                    8782)
    ("HumpEqual"                       8783)
    ("hybull"                          8259)
    ("hyphen"                          8208)
    ("Iacute"                          205)
    ("iacute"                          237)
    ("ic"                              8291)
    ("Icirc"                           206)
    ("icirc"                           238)
    ("Icy"                             1048)
    ("icy"                             1080)
    ("Idot"                            304)
    ("IEcy"                            1045)
    ("iecy"                            1077)
    ("iexcl"                           161)
    ("iff"                             8660)
    ("ifr"                             120102)
    ("Ifr"                             8465)
    ("Igrave"                          204)
    ("igrave"                          236)
    ("ii"                              8520)
    ("iiiint"                          10764)
    ("iiint"                           8749)
    ("iinfin"                          10716)
    ("iiota"                           8489)
    ("IJlig"                           306)
    ("ijlig"                           307)
    ("Imacr"                           298)
    ("imacr"                           299)
    ("image"                           8465)
    ("ImaginaryI"                      8520)
    ("imagline"                        8464)
    ("imagpart"                        8465)
    ("imath"                           305)
    ("Im"                              8465)
    ("imof"                            8887)
    ("imped"                           437)
    ("Implies"                         8658)
    ("incare"                          8453)
    ("in"                              8712)
    ("infin"                           8734)
    ("infintie"                        10717)
    ("inodot"                          305)
    ("intcal"                          8890)
    ("int"                             8747)
    ("Int"                             8748)
    ("integers"                        8484)
    ("Integral"                        8747)
    ("intercal"                        8890)
    ("Intersection"                    8898)
    ("intlarhk"                        10775)
    ("intprod"                         10812)
    ("InvisibleComma"                  8291)
    ("InvisibleTimes"                  8290)
    ("IOcy"                            1025)
    ("iocy"                            1105)
    ("Iogon"                           302)
    ("iogon"                           303)
    ("Iopf"                            120128)
    ("iopf"                            120154)
    ("Iota"                            921)
    ("iota"                            953)
    ("iprod"                           10812)
    ("iquest"                          191)
    ("iscr"                            119998)
    ("Iscr"                            8464)
    ("isin"                            8712)
    ("isindot"                         8949)
    ("isinE"                           8953)
    ("isins"                           8948)
    ("isinsv"                          8947)
    ("isinv"                           8712)
    ("it"                              8290)
    ("Itilde"                          296)
    ("itilde"                          297)
    ("Iukcy"                           1030)
    ("iukcy"                           1110)
    ("Iuml"                            207)
    ("iuml"                            239)
    ("Jcirc"                           308)
    ("jcirc"                           309)
    ("Jcy"                             1049)
    ("jcy"                             1081)
    ("Jfr"                             120077)
    ("jfr"                             120103)
    ("jmath"                           567)
    ("Jopf"                            120129)
    ("jopf"                            120155)
    ("Jscr"                            119973)
    ("jscr"                            119999)
    ("Jsercy"                          1032)
    ("jsercy"                          1112)
    ("Jukcy"                           1028)
    ("jukcy"                           1108)
    ("Kappa"                           922)
    ("kappa"                           954)
    ("kappav"                          1008)
    ("Kcedil"                          310)
    ("kcedil"                          311)
    ("Kcy"                             1050)
    ("kcy"                             1082)
    ("Kfr"                             120078)
    ("kfr"                             120104)
    ("kgreen"                          312)
    ("KHcy"                            1061)
    ("khcy"                            1093)
    ("KJcy"                            1036)
    ("kjcy"                            1116)
    ("Kopf"                            120130)
    ("kopf"                            120156)
    ("Kscr"                            119974)
    ("kscr"                            120000)
    ("lAarr"                           8666)
    ("Lacute"                          313)
    ("lacute"                          314)
    ("laemptyv"                        10676)
    ("lagran"                          8466)
    ("Lambda"                          923)
    ("lambda"                          955)
    ("lang"                            10216)
    ("Lang"                            10218)
    ("langd"                           10641)
    ("langle"                          10216)
    ("lap"                             10885)
    ("Laplacetrf"                      8466)
    ("laquo"                           171)
    ("larrb"                           8676)
    ("larrbfs"                         10527)
    ("larr"                            8592)
    ("Larr"                            8606)
    ("lArr"                            8656)
    ("larrfs"                          10525)
    ("larrhk"                          8617)
    ("larrlp"                          8619)
    ("larrpl"                          10553)
    ("larrsim"                         10611)
    ("larrtl"                          8610)
    ("latail"                          10521)
    ("lAtail"                          10523)
    ("lat"                             10923)
    ("late"                            10925)
 %  ("lates"                           10925, 65024)
    ("lbarr"                           10508)
    ("lBarr"                           10510)
    ("lbbrk"                           10098)
    ("lbrace"                          123)
    ("lbrack"                          91)
    ("lbrke"                           10635)
    ("lbrksld"                         10639)
    ("lbrkslu"                         10637)
    ("Lcaron"                          317)
    ("lcaron"                          318)
    ("Lcedil"                          315)
    ("lcedil"                          316)
    ("lceil"                           8968)
    ("lcub"                            123)
    ("Lcy"                             1051)
    ("lcy"                             1083)
    ("ldca"                            10550)
    ("ldquo"                           8220)
    ("ldquor"                          8222)
    ("ldrdhar"                         10599)
    ("ldrushar"                        10571)
    ("ldsh"                            8626)
    ("le"                              8804)
    ("lE"                              8806)
    ("LeftAngleBracket"                10216)
    ("LeftArrowBar"                    8676)
    ("leftarrow"                       8592)
    ("LeftArrow"                       8592)
    ("Leftarrow"                       8656)
    ("LeftArrowRightArrow"             8646)
    ("leftarrowtail"                   8610)
    ("LeftCeiling"                     8968)
    ("LeftDoubleBracket"               10214)
    ("LeftDownTeeVector"               10593)
    ("LeftDownVectorBar"               10585)
    ("LeftDownVector"                  8643)
    ("LeftFloor"                       8970)
    ("leftharpoondown"                 8637)
    ("leftharpoonup"                   8636)
    ("leftleftarrows"                  8647)
    ("leftrightarrow"                  8596)
    ("LeftRightArrow"                  8596)
    ("Leftrightarrow"                  8660)
    ("leftrightarrows"                 8646)
    ("leftrightharpoons"               8651)
    ("leftrightsquigarrow"             8621)
    ("LeftRightVector"                 10574)
    ("LeftTeeArrow"                    8612)
    ("LeftTee"                         8867)
    ("LeftTeeVector"                   10586)
    ("leftthreetimes"                  8907)
    ("LeftTriangleBar"                 10703)
    ("LeftTriangle"                    8882)
    ("LeftTriangleEqual"               8884)
    ("LeftUpDownVector"                10577)
    ("LeftUpTeeVector"                 10592)
    ("LeftUpVectorBar"                 10584)
    ("LeftUpVector"                    8639)
    ("LeftVectorBar"                   10578)
    ("LeftVector"                      8636)
    ("lEg"                             10891)
    ("leg"                             8922)
    ("leq"                             8804)
    ("leqq"                            8806)
    ("leqslant"                        10877)
    ("lescc"                           10920)
    ("les"                             10877)
    ("lesdot"                          10879)
    ("lesdoto"                         10881)
    ("lesdotor"                        10883)
 %  ("lesg"                            8922, 65024)
    ("lesges"                          10899)
    ("lessapprox"                      10885)
    ("lessdot"                         8918)
    ("lesseqgtr"                       8922)
    ("lesseqqgtr"                      10891)
    ("LessEqualGreater"                8922)
    ("LessFullEqual"                   8806)
    ("LessGreater"                     8822)
    ("lessgtr"                         8822)
    ("LessLess"                        10913)
    ("lesssim"                         8818)
    ("LessSlantEqual"                  10877)
    ("LessTilde"                       8818)
    ("lfisht"                          10620)
    ("lfloor"                          8970)
    ("Lfr"                             120079)
    ("lfr"                             120105)
    ("lg"                              8822)
    ("lgE"                             10897)
    ("lHar"                            10594)
    ("lhard"                           8637)
    ("lharu"                           8636)
    ("lharul"                          10602)
    ("lhblk"                           9604)
    ("LJcy"                            1033)
    ("ljcy"                            1113)
    ("llarr"                           8647)
    ("ll"                              8810)
    ("Ll"                              8920)
    ("llcorner"                        8990)
    ("Lleftarrow"                      8666)
    ("llhard"                          10603)
    ("lltri"                           9722)
    ("Lmidot"                          319)
    ("lmidot"                          320)
    ("lmoustache"                      9136)
    ("lmoust"                          9136)
    ("lnap"                            10889)
    ("lnapprox"                        10889)
    ("lne"                             10887)
    ("lnE"                             8808)
    ("lneq"                            10887)
    ("lneqq"                           8808)
    ("lnsim"                           8934)
    ("loang"                           10220)
    ("loarr"                           8701)
    ("lobrk"                           10214)
    ("longleftarrow"                   10229)
    ("LongLeftArrow"                   10229)
    ("Longleftarrow"                   10232)
    ("longleftrightarrow"              10231)
    ("LongLeftRightArrow"              10231)
    ("Longleftrightarrow"              10234)
    ("longmapsto"                      10236)
    ("longrightarrow"                  10230)
    ("LongRightArrow"                  10230)
    ("Longrightarrow"                  10233)
    ("looparrowleft"                   8619)
    ("looparrowright"                  8620)
    ("lopar"                           10629)
    ("Lopf"                            120131)
    ("lopf"                            120157)
    ("loplus"                          10797)
    ("lotimes"                         10804)
    ("lowast"                          8727)
    ("lowbar"                          95)
    ("LowerLeftArrow"                  8601)
    ("LowerRightArrow"                 8600)
    ("loz"                             9674)
    ("lozenge"                         9674)
    ("lozf"                            10731)
    ("lpar"                            40)
    ("lparlt"                          10643)
    ("lrarr"                           8646)
    ("lrcorner"                        8991)
    ("lrhar"                           8651)
    ("lrhard"                          10605)
    ("lrm"                             8206)
    ("lrtri"                           8895)
    ("lsaquo"                          8249)
    ("lscr"                            120001)
    ("Lscr"                            8466)
    ("lsh"                             8624)
    ("Lsh"                             8624)
    ("lsim"                            8818)
    ("lsime"                           10893)
    ("lsimg"                           10895)
    ("lsqb"                            91)
    ("lsquo"                           8216)
    ("lsquor"                          8218)
    ("Lstrok"                          321)
    ("lstrok"                          322)
    ("ltcc"                            10918)
    ("ltcir"                           10873)
    ("lt"                              60)
    ("LT"                              60)
    ("Lt"                              8810)
    ("ltdot"                           8918)
    ("lthree"                          8907)
    ("ltimes"                          8905)
    ("ltlarr"                          10614)
    ("ltquest"                         10875)
    ("ltri"                            9667)
    ("ltrie"                           8884)
    ("ltrif"                           9666)
    ("ltrPar"                          10646)
    ("lurdshar"                        10570)
    ("luruhar"                         10598)
 %  ("lvertneqq"                       8808, 65024)
 %  ("lvnE"                            8808, 65024)
    ("macr"                            175)
    ("male"                            9794)
    ("malt"                            10016)
    ("maltese"                         10016)
    ("Map"                             10501)
    ("map"                             8614)
    ("mapsto"                          8614)
    ("mapstodown"                      8615)
    ("mapstoleft"                      8612)
    ("mapstoup"                        8613)
    ("marker"                          9646)
    ("mcomma"                          10793)
    ("Mcy"                             1052)
    ("mcy"                             1084)
    ("mdash"                           8212)
    ("mDDot"                           8762)
    ("measuredangle"                   8737)
    ("MediumSpace"                     8287)
    ("Mellintrf"                       8499)
    ("Mfr"                             120080)
    ("mfr"                             120106)
    ("mho"                             8487)
    ("micro"                           181)
    ("midast"                          42)
    ("midcir"                          10992)
    ("mid"                             8739)
    ("middot"                          183)
    ("minusb"                          8863)
    ("minus"                           8722)
    ("minusd"                          8760)
    ("minusdu"                         10794)
    ("MinusPlus"                       8723)
    ("mlcp"                            10971)
    ("mldr"                            8230)
    ("mnplus"                          8723)
    ("models"                          8871)
    ("Mopf"                            120132)
    ("mopf"                            120158)
    ("mp"                              8723)
    ("mscr"                            120002)
    ("Mscr"                            8499)
    ("mstpos"                          8766)
    ("Mu"                              924)
    ("mu"                              956)
    ("multimap"                        8888)
    ("mumap"                           8888)
    ("nabla"                           8711)
    ("Nacute"                          323)
    ("nacute"                          324)
 %  ("nang"                            8736, 8402)
    ("nap"                             8777)
 %  ("napE"                            10864, 824)
 %  ("napid"                           8779, 824)
    ("napos"                           329)
    ("napprox"                         8777)
    ("natural"                         9838)
    ("naturals"                        8469)
    ("natur"                           9838)
    ("nbsp"                            160)
 %  ("nbump"                           8782, 824)
 %  ("nbumpe"                          8783, 824)
    ("ncap"                            10819)
    ("Ncaron"                          327)
    ("ncaron"                          328)
    ("Ncedil"                          325)
    ("ncedil"                          326)
    ("ncong"                           8775)
 %  ("ncongdot"                        10861, 824)
    ("ncup"                            10818)
    ("Ncy"                             1053)
    ("ncy"                             1085)
    ("ndash"                           8211)
    ("nearhk"                          10532)
    ("nearr"                           8599)
    ("neArr"                           8663)
    ("nearrow"                         8599)
    ("ne"                              8800)
 %  ("nedot"                           8784, 824)
    ("NegativeMediumSpace"             8203)
    ("NegativeThickSpace"              8203)
    ("NegativeThinSpace"               8203)
    ("NegativeVeryThinSpace"           8203)
    ("nequiv"                          8802)
 %  ("nesear"                          10536)
    ("nesim"                           8770, 824)
    ("NestedGreaterGreater"            8811)
    ("NestedLessLess"                  8810)
    ("NewLine"                         10)
    ("nexist"                          8708)
    ("nexists"                         8708)
    ("Nfr"                             120081)
 %  ("nfr"                             120107)
    ("ngE"                             8807, 824)
    ("nge"                             8817)
    ("ngeq"                            8817)
 %  ("ngeqq"                           8807, 824)
 %  ("ngeqslant"                       10878, 824)
 %  ("nges"                            10878, 824)
 %  ("nGg"                             8921, 824)
    ("ngsim"                           8821)
 %  ("nGt"                             8811, 8402)
    ("ngt"                             8815)
    ("ngtr"                            8815)
 %  ("nGtv"                            8811, 824)
    ("nharr"                           8622)
    ("nhArr"                           8654)
    ("nhpar"                           10994)
    ("ni"                              8715)
    ("nis"                             8956)
    ("nisd"                            8954)
    ("niv"                             8715)
    ("NJcy"                            1034)
    ("njcy"                            1114)
    ("nlarr"                           8602)
    ("nlArr"                           8653)
 %  ("nldr"                            8229)
    ("nlE"                             8806, 824)
    ("nle"                             8816)
    ("nleftarrow"                      8602)
    ("nLeftarrow"                      8653)
    ("nleftrightarrow"                 8622)
    ("nLeftrightarrow"                 8654)
    ("nleq"                            8816)
 %  ("nleqq"                           8806, 824)
 %  ("nleqslant"                       10877, 824)
 %  ("nles"                            10877, 824)
    ("nless"                           8814)
 %  ("nLl"                             8920, 824)
    ("nlsim"                           8820)
 %  ("nLt"                             8810, 8402)
    ("nlt"                             8814)
    ("nltri"                           8938)
    ("nltrie"                          8940)
 %  ("nLtv"                            8810, 824)
    ("nmid"                            8740)
    ("NoBreak"                         8288)
    ("NonBreakingSpace"                160)
    ("nopf"                            120159)
    ("Nopf"                            8469)
    ("Not"                             10988)
    ("not"                             172)
    ("NotCongruent"                    8802)
    ("NotCupCap"                       8813)
    ("NotDoubleVerticalBar"            8742)
    ("NotElement"                      8713)
    ("NotEqual"                        8800)
 %  ("NotEqualTilde"                   8770, 824)
    ("NotExists"                       8708)
    ("NotGreater"                      8815)
    ("NotGreaterEqual"                 8817)
 %  ("NotGreaterFullEqual"             8807, 824)
 %  ("NotGreaterGreater"               8811, 824)
    ("NotGreaterLess"                  8825)
 %  ("NotGreaterSlantEqual"            10878, 824)
    ("NotGreaterTilde"                 8821)
 %  ("NotHumpDownHump"                 8782, 824)
 %  ("NotHumpEqual"                    8783, 824)
    ("notin"                           8713)
 %  ("notindot"                        8949, 824)
 %  ("notinE"                          8953, 824)
    ("notinva"                         8713)
    ("notinvb"                         8951)
    ("notinvc"                         8950)
 %  ("NotLeftTriangleBar"              10703, 824)
    ("NotLeftTriangle"                 8938)
    ("NotLeftTriangleEqual"            8940)
    ("NotLess"                         8814)
    ("NotLessEqual"                    8816)
    ("NotLessGreater"                  8824)
 %  ("NotLessLess"                     8810, 824)
 %  ("NotLessSlantEqual"               10877, 824)
    ("NotLessTilde"                    8820)
 %  ("NotNestedGreaterGreater"         10914, 824)
 %  ("NotNestedLessLess"               10913, 824)
    ("notni"                           8716)
    ("notniva"                         8716)
    ("notnivb"                         8958)
    ("notnivc"                         8957)
    ("NotPrecedes"                     8832)
 %  ("NotPrecedesEqual"                10927, 824)
    ("NotPrecedesSlantEqual"           8928)
    ("NotReverseElement"               8716)
 %  ("NotRightTriangleBar"             10704, 824)
    ("NotRightTriangle"                8939)
    ("NotRightTriangleEqual"           8941)
 %  ("NotSquareSubset"                 8847, 824)
    ("NotSquareSubsetEqual"            8930)
 %  ("NotSquareSuperset"               8848, 824)
    ("NotSquareSupersetEqual"          8931)
 %  ("NotSubset"                       8834, 8402)
    ("NotSubsetEqual"                  8840)
    ("NotSucceeds"                     8833)
 %  ("NotSucceedsEqual"                10928, 824)
    ("NotSucceedsSlantEqual"           8929)
 %  ("NotSucceedsTilde"                8831, 824)
 %  ("NotSuperset"                     8835, 8402)
    ("NotSupersetEqual"                8841)
    ("NotTilde"                        8769)
    ("NotTildeEqual"                   8772)
    ("NotTildeFullEqual"               8775)
    ("NotTildeTilde"                   8777)
    ("NotVerticalBar"                  8740)
    ("nparallel"                       8742)
    ("npar"                            8742)
 %  ("nparsl"                          11005, 8421)
 %  ("npart"                           8706, 824)
    ("npolint"                         10772)
    ("npr"                             8832)
    ("nprcue"                          8928)
    ("nprec"                           8832)
 %  ("npreceq"                         10927, 824)
 %  ("npre"                            10927, 824)
 %  ("nrarrc"                          10547, 824)
    ("nrarr"                           8603)
    ("nrArr"                           8655)
 %  ("nrarrw"                          8605, 824)
    ("nrightarrow"                     8603)
    ("nRightarrow"                     8655)
    ("nrtri"                           8939)
    ("nrtrie"                          8941)
    ("nsc"                             8833)
    ("nsccue"                          8929)
 %  ("nsce"                            10928, 824)
    ("Nscr"                            119977)
    ("nscr"                            120003)
    ("nshortmid"                       8740)
    ("nshortparallel"                  8742)
    ("nsim"                            8769)
    ("nsime"                           8772)
    ("nsimeq"                          8772)
    ("nsmid"                           8740)
    ("nspar"                           8742)
    ("nsqsube"                         8930)
    ("nsqsupe"                         8931)
    ("nsub"                            8836)
 %  ("nsubE"                           10949, 824)
    ("nsube"                           8840)
 %  ("nsubset"                         8834, 8402)
    ("nsubseteq"                       8840)
 %  ("nsubseteqq"                      10949, 824)
    ("nsucc"                           8833)
 %  ("nsucceq"                         10928, 824)
    ("nsup"                            8837)
 %  ("nsupE"                           10950, 824)
    ("nsupe"                           8841)
 %  ("nsupset"                         8835, 8402)
    ("nsupseteq"                       8841)
 %  ("nsupseteqq"                      10950, 824)
    ("ntgl"                            8825)
    ("Ntilde"                          209)
    ("ntilde"                          241)
    ("ntlg"                            8824)
    ("ntriangleleft"                   8938)
    ("ntrianglelefteq"                 8940)
    ("ntriangleright"                  8939)
    ("ntrianglerighteq"                8941)
    ("Nu"                              925)
    ("nu"                              957)
    ("num"                             35)
    ("numero"                          8470)
    ("numsp"                           8199)
 %  ("nvap"                            8781, 8402)
    ("nvdash"                          8876)
    ("nvDash"                          8877)
    ("nVdash"                          8878)
    ("nVDash"                          8879)
 %  ("nvge"                            8805, 8402)
 %  ("nvgt"                            62, 8402)
    ("nvHarr"                          10500)
    ("nvinfin"                         10718)
    ("nvlArr"                          10498)
 %  ("nvle"                            8804, 8402)
 %  ("nvlt"                            60, 8402)
 %  ("nvltrie"                         8884, 8402)
    ("nvrArr"                          10499)
 %  ("nvrtrie"                         8885, 8402)
 %  ("nvsim"                           8764, 8402)
    ("nwarhk"                          10531)
    ("nwarr"                           8598)
    ("nwArr"                           8662)
    ("nwarrow"                         8598)
    ("nwnear"                          10535)
    ("Oacute"                          211)
    ("oacute"                          243)
    ("oast"                            8859)
    ("Ocirc"                           212)
    ("ocirc"                           244)
    ("ocir"                            8858)
    ("Ocy"                             1054)
    ("ocy"                             1086)
    ("odash"                           8861)
    ("Odblac"                          336)
    ("odblac"                          337)
    ("odiv"                            10808)
    ("odot"                            8857)
    ("odsold"                          10684)
    ("OElig"                           338)
    ("oelig"                           339)
    ("ofcir"                           10687)
    ("Ofr"                             120082)
    ("ofr"                             120108)
    ("ogon"                            731)
    ("Ograve"                          210)
    ("ograve"                          242)
    ("ogt"                             10689)
    ("ohbar"                           10677)
    ("ohm"                             937)
    ("oint"                            8750)
    ("olarr"                           8634)
    ("olcir"                           10686)
    ("olcross"                         10683)
    ("oline"                           8254)
    ("olt"                             10688)
    ("Omacr"                           332)
    ("omacr"                           333)
    ("Omega"                           937)
    ("omega"                           969)
    ("Omicron"                         927)
    ("omicron"                         959)
    ("omid"                            10678)
    ("ominus"                          8854)
    ("Oopf"                            120134)
    ("oopf"                            120160)
    ("opar"                            10679)
    ("OpenCurlyDoubleQuote"            8220)
    ("OpenCurlyQuote"                  8216)
    ("operp"                           10681)
    ("oplus"                           8853)
    ("orarr"                           8635)
    ("Or"                              10836)
    ("or"                              8744)
    ("ord"                             10845)
    ("order"                           8500)
    ("orderof"                         8500)
    ("ordf"                            170)
    ("ordm"                            186)
    ("origof"                          8886)
    ("oror"                            10838)
    ("orslope"                         10839)
    ("orv"                             10843)
    ("oS"                              9416)
    ("Oscr"                            119978)
    ("oscr"                            8500)
    ("Oslash"                          216)
    ("oslash"                          248)
    ("osol"                            8856)
    ("Otilde"                          213)
    ("otilde"                          245)
    ("otimesas"                        10806)
    ("Otimes"                          10807)
    ("otimes"                          8855)
    ("Ouml"                            214)
    ("ouml"                            246)
    ("ovbar"                           9021)
    ("OverBar"                         8254)
    ("OverBrace"                       9182)
    ("OverBracket"                     9140)
    ("OverParenthesis"                 9180)
    ("para"                            182)
    ("parallel"                        8741)
    ("par"                             8741)
    ("parsim"                          10995)
    ("parsl"                           11005)
    ("part"                            8706)
    ("PartialD"                        8706)
    ("Pcy"                             1055)
    ("pcy"                             1087)
    ("percnt"                          37)
    ("period"                          46)
    ("permil"                          8240)
    ("perp"                            8869)
    ("pertenk"                         8241)
    ("Pfr"                             120083)
    ("pfr"                             120109)
    ("Phi"                             934)
    ("phi"                             966)
    ("phiv"                            981)
    ("phmmat"                          8499)
    ("phone"                           9742)
    ("Pi"                              928)
    ("pi"                              960)
    ("pitchfork"                       8916)
    ("piv"                             982)
    ("planck"                          8463)
    ("planckh"                         8462)
    ("plankv"                          8463)
    ("plusacir"                        10787)
    ("plusb"                           8862)
    ("pluscir"                         10786)
    ("plus"                            43)
    ("plusdo"                          8724)
    ("plusdu"                          10789)
    ("pluse"                           10866)
    ("PlusMinus"                       177)
    ("plusmn"                          177)
    ("plussim"                         10790)
    ("plustwo"                         10791)
    ("pm"                              177)
    ("Poincareplane"                   8460)
    ("pointint"                        10773)
    ("popf"                            120161)
    ("Popf"                            8473)
    ("pound"                           163)
    ("prap"                            10935)
    ("Pr"                              10939)
    ("pr"                              8826)
    ("prcue"                           8828)
    ("precapprox"                      10935)
    ("prec"                            8826)
    ("preccurlyeq"                     8828)
    ("Precedes"                        8826)
    ("PrecedesEqual"                   10927)
    ("PrecedesSlantEqual"              8828)
    ("PrecedesTilde"                   8830)
    ("preceq"                          10927)
    ("precnapprox"                     10937)
    ("precneqq"                        10933)
    ("precnsim"                        8936)
    ("pre"                             10927)
    ("prE"                             10931)
    ("precsim"                         8830)
    ("prime"                           8242)
    ("Prime"                           8243)
    ("primes"                          8473)
    ("prnap"                           10937)
    ("prnE"                            10933)
    ("prnsim"                          8936)
    ("prod"                            8719)
    ("Product"                         8719)
    ("profalar"                        9006)
    ("profline"                        8978)
    ("profsurf"                        8979)
    ("prop"                            8733)
    ("Proportional"                    8733)
    ("Proportion"                      8759)
    ("propto"                          8733)
    ("prsim"                           8830)
    ("prurel"                          8880)
    ("Pscr"                            119979)
    ("pscr"                            120005)
    ("Psi"                             936)
    ("psi"                             968)
    ("puncsp"                          8200)
    ("Qfr"                             120084)
    ("qfr"                             120110)
    ("qint"                            10764)
    ("qopf"                            120162)
    ("Qopf"                            8474)
    ("qprime"                          8279)
    ("Qscr"                            119980)
    ("qscr"                            120006)
    ("quaternions"                     8461)
    ("quatint"                         10774)
    ("quest"                           63)
    ("questeq"                         8799)
    ("quot"                            34)
    ("QUOT"                            34)
    ("rAarr"                           8667)
 %  ("race"                            8765, 817)
    ("Racute"                          340)
    ("racute"                          341)
    ("radic"                           8730)
    ("raemptyv"                        10675)
    ("rang"                            10217)
    ("Rang"                            10219)
    ("rangd"                           10642)
    ("range"                           10661)
    ("rangle"                          10217)
    ("raquo"                           187)
    ("rarrap"                          10613)
    ("rarrb"                           8677)
    ("rarrbfs"                         10528)
    ("rarrc"                           10547)
    ("rarr"                            8594)
    ("Rarr"                            8608)
    ("rArr"                            8658)
    ("rarrfs"                          10526)
    ("rarrhk"                          8618)
    ("rarrlp"                          8620)
    ("rarrpl"                          10565)
    ("rarrsim"                         10612)
    ("Rarrtl"                          10518)
    ("rarrtl"                          8611)
    ("rarrw"                           8605)
    ("ratail"                          10522)
    ("rAtail"                          10524)
    ("ratio"                           8758)
    ("rationals"                       8474)
    ("rbarr"                           10509)
    ("rBarr"                           10511)
    ("RBarr"                           10512)
    ("rbbrk"                           10099)
    ("rbrace"                          125)
    ("rbrack"                          93)
    ("rbrke"                           10636)
    ("rbrksld"                         10638)
    ("rbrkslu"                         10640)
    ("Rcaron"                          344)
    ("rcaron"                          345)
    ("Rcedil"                          342)
    ("rcedil"                          343)
    ("rceil"                           8969)
    ("rcub"                            125)
    ("Rcy"                             1056)
    ("rcy"                             1088)
    ("rdca"                            10551)
    ("rdldhar"                         10601)
    ("rdquo"                           8221)
    ("rdquor"                          8221)
    ("rdsh"                            8627)
    ("real"                            8476)
    ("realine"                         8475)
    ("realpart"                        8476)
    ("reals"                           8477)
    ("Re"                              8476)
    ("rect"                            9645)
    ("reg"                             174)
    ("REG"                             174)
    ("ReverseElement"                  8715)
    ("ReverseEquilibrium"              8651)
    ("ReverseUpEquilibrium"            10607)
    ("rfisht"                          10621)
    ("rfloor"                          8971)
    ("rfr"                             120111)
    ("Rfr"                             8476)
    ("rHar"                            10596)
    ("rhard"                           8641)
    ("rharu"                           8640)
    ("rharul"                          10604)
    ("Rho"                             929)
    ("rho"                             961)
    ("rhov"                            1009)
    ("RightAngleBracket"               10217)
    ("RightArrowBar"                   8677)
    ("rightarrow"                      8594)
    ("RightArrow"                      8594)
    ("Rightarrow"                      8658)
    ("RightArrowLeftArrow"             8644)
    ("rightarrowtail"                  8611)
    ("RightCeiling"                    8969)
    ("RightDoubleBracket"              10215)
    ("RightDownTeeVector"              10589)
    ("RightDownVectorBar"              10581)
    ("RightDownVector"                 8642)
    ("RightFloor"                      8971)
    ("rightharpoondown"                8641)
    ("rightharpoonup"                  8640)
    ("rightleftarrows"                 8644)
    ("rightleftharpoons"               8652)
    ("rightrightarrows"                8649)
    ("rightsquigarrow"                 8605)
    ("RightTeeArrow"                   8614)
    ("RightTee"                        8866)
    ("RightTeeVector"                  10587)
    ("rightthreetimes"                 8908)
    ("RightTriangleBar"                10704)
    ("RightTriangle"                   8883)
    ("RightTriangleEqual"              8885)
    ("RightUpDownVector"               10575)
    ("RightUpTeeVector"                10588)
    ("RightUpVectorBar"                10580)
    ("RightUpVector"                   8638)
    ("RightVectorBar"                  10579)
    ("RightVector"                     8640)
    ("ring"                            730)
    ("risingdotseq"                    8787)
    ("rlarr"                           8644)
    ("rlhar"                           8652)
    ("rlm"                             8207)
    ("rmoustache"                      9137)
    ("rmoust"                          9137)
    ("rnmid"                           10990)
    ("roang"                           10221)
    ("roarr"                           8702)
    ("robrk"                           10215)
    ("ropar"                           10630)
    ("ropf"                            120163)
    ("Ropf"                            8477)
    ("roplus"                          10798)
    ("rotimes"                         10805)
    ("RoundImplies"                    10608)
    ("rpar"                            41)
    ("rpargt"                          10644)
    ("rppolint"                        10770)
    ("rrarr"                           8649)
    ("Rrightarrow"                     8667)
    ("rsaquo"                          8250)
    ("rscr"                            120007)
    ("Rscr"                            8475)
    ("rsh"                             8625)
    ("Rsh"                             8625)
    ("rsqb"                            93)
    ("rsquo"                           8217)
    ("rsquor"                          8217)
    ("rthree"                          8908)
    ("rtimes"                          8906)
    ("rtri"                            9657)
    ("rtrie"                           8885)
    ("rtrif"                           9656)
    ("rtriltri"                        10702)
    ("RuleDelayed"                     10740)
    ("ruluhar"                         10600)
    ("rx"                              8478)
    ("Sacute"                          346)
    ("sacute"                          347)
    ("sbquo"                           8218)
    ("scap"                            10936)
    ("Scaron"                          352)
    ("scaron"                          353)
    ("Sc"                              10940)
    ("sc"                              8827)
    ("sccue"                           8829)
    ("sce"                             10928)
    ("scE"                             10932)
    ("Scedil"                          350)
    ("scedil"                          351)
    ("Scirc"                           348)
    ("scirc"                           349)
    ("scnap"                           10938)
    ("scnE"                            10934)
    ("scnsim"                          8937)
    ("scpolint"                        10771)
    ("scsim"                           8831)
    ("Scy"                             1057)
    ("scy"                             1089)
    ("sdotb"                           8865)
    ("sdot"                            8901)
    ("sdote"                           10854)
    ("searhk"                          10533)
    ("searr"                           8600)
    ("seArr"                           8664)
    ("searrow"                         8600)
    ("sect"                            167)
    ("semi"                            59)
    ("seswar"                          10537)
    ("setminus"                        8726)
    ("setmn"                           8726)
    ("sext"                            10038)
    ("Sfr"                             120086)
    ("sfr"                             120112)
    ("sfrown"                          8994)
    ("sharp"                           9839)
    ("SHCHcy"                          1065)
    ("shchcy"                          1097)
    ("SHcy"                            1064)
    ("shcy"                            1096)
    ("ShortDownArrow"                  8595)
    ("ShortLeftArrow"                  8592)
    ("shortmid"                        8739)
    ("shortparallel"                   8741)
    ("ShortRightArrow"                 8594)
    ("ShortUpArrow"                    8593)
    ("shy"                             173)
    ("Sigma"                           931)
    ("sigma"                           963)
    ("sigmaf"                          962)
    ("sigmav"                          962)
    ("sim"                             8764)
    ("simdot"                          10858)
    ("sime"                            8771)
    ("simeq"                           8771)
    ("simg"                            10910)
    ("simgE"                           10912)
    ("siml"                            10909)
    ("simlE"                           10911)
    ("simne"                           8774)
    ("simplus"                         10788)
    ("simrarr"                         10610)
    ("slarr"                           8592)
    ("SmallCircle"                     8728)
    ("smallsetminus"                   8726)
    ("smashp"                          10803)
    ("smeparsl"                        10724)
    ("smid"                            8739)
    ("smile"                           8995)
    ("smt"                             10922)
    ("smte"                            10924)
 %  ("smtes"                           10924, 65024)
    ("SOFTcy"                          1068)
    ("softcy"                          1100)
    ("solbar"                          9023)
    ("solb"                            10692)
    ("sol"                             47)
    ("Sopf"                            120138)
    ("sopf"                            120164)
    ("spades"                          9824)
    ("spadesuit"                       9824)
    ("spar"                            8741)
    ("sqcap"                           8851)
 %  ("sqcaps"                          8851, 65024)
    ("sqcup"                           8852)
 %  ("sqcups"                          8852, 65024)
    ("Sqrt"                            8730)
    ("sqsub"                           8847)
    ("sqsube"                          8849)
    ("sqsubset"                        8847)
    ("sqsubseteq"                      8849)
    ("sqsup"                           8848)
    ("sqsupe"                          8850)
    ("sqsupset"                        8848)
    ("sqsupseteq"                      8850)
    ("square"                          9633)
    ("Square"                          9633)
    ("SquareIntersection"              8851)
    ("SquareSubset"                    8847)
    ("SquareSubsetEqual"               8849)
    ("SquareSuperset"                  8848)
    ("SquareSupersetEqual"             8850)
    ("SquareUnion"                     8852)
    ("squarf"                          9642)
    ("squ"                             9633)
    ("squf"                            9642)
    ("srarr"                           8594)
    ("Sscr"                            119982)
    ("sscr"                            120008)
    ("ssetmn"                          8726)
    ("ssmile"                          8995)
    ("sstarf"                          8902)
    ("Star"                            8902)
    ("star"                            9734)
    ("starf"                           9733)
    ("straightepsilon"                 1013)
    ("straightphi"                     981)
    ("strns"                           175)
    ("sub"                             8834)
    ("Sub"                             8912)
    ("subdot"                          10941)
    ("subE"                            10949)
    ("sube"                            8838)
    ("subedot"                         10947)
    ("submult"                         10945)
    ("subnE"                           10955)
    ("subne"                           8842)
    ("subplus"                         10943)
    ("subrarr"                         10617)
    ("subset"                          8834)
    ("Subset"                          8912)
    ("subseteq"                        8838)
    ("subseteqq"                       10949)
    ("SubsetEqual"                     8838)
    ("subsetneq"                       8842)
    ("subsetneqq"                      10955)
    ("subsim"                          10951)
    ("subsub"                          10965)
    ("subsup"                          10963)
    ("succapprox"                      10936)
    ("succ"                            8827)
    ("succcurlyeq"                     8829)
    ("Succeeds"                        8827)
    ("SucceedsEqual"                   10928)
    ("SucceedsSlantEqual"              8829)
    ("SucceedsTilde"                   8831)
    ("succeq"                          10928)
    ("succnapprox"                     10938)
    ("succneqq"                        10934)
    ("succnsim"                        8937)
    ("succsim"                         8831)
    ("SuchThat"                        8715)
    ("sum"                             8721)
    ("Sum"                             8721)
    ("sung"                            9834)
    ("sup1"                            185)
    ("sup2"                            178)
    ("sup3"                            179)
    ("sup"                             8835)
    ("Sup"                             8913)
    ("supdot"                          10942)
    ("supdsub"                         10968)
    ("supE"                            10950)
    ("supe"                            8839)
    ("supedot"                         10948)
    ("Superset"                        8835)
    ("SupersetEqual"                   8839)
    ("suphsol"                         10185)
    ("suphsub"                         10967)
    ("suplarr"                         10619)
    ("supmult"                         10946)
    ("supnE"                           10956)
    ("supne"                           8843)
    ("supplus"                         10944)
    ("supset"                          8835)
    ("Supset"                          8913)
    ("supseteq"                        8839)
    ("supseteqq"                       10950)
    ("supsetneq"                       8843)
    ("supsetneqq"                      10956)
    ("supsim"                          10952)
    ("supsub"                          10964)
    ("supsup"                          10966)
    ("swarhk"                          10534)
    ("swarr"                           8601)
    ("swArr"                           8665)
    ("swarrow"                         8601)
    ("swnwar"                          10538)
    ("szlig"                           223)
    ("Tab"                             9)
    ("target"                          8982)
    ("Tau"                             932)
    ("tau"                             964)
    ("tbrk"                            9140)
    ("Tcaron"                          356)
    ("tcaron"                          357)
    ("Tcedil"                          354)
    ("tcedil"                          355)
    ("Tcy"                             1058)
    ("tcy"                             1090)
    ("tdot"                            8411)
    ("telrec"                          8981)
    ("Tfr"                             120087)
    ("tfr"                             120113)
    ("there4"                          8756)
    ("therefore"                       8756)
    ("Therefore"                       8756)
    ("Theta"                           920)
    ("theta"                           952)
    ("thetasym"                        977)
    ("thetav"                          977)
    ("thickapprox"                     8776)
    ("thicksim"                        8764)
 %  ("ThickSpace"                      8287, 8202)
    ("ThinSpace"                       8201)
    ("thinsp"                          8201)
    ("thkap"                           8776)
    ("thksim"                          8764)
    ("THORN"                           222)
    ("thorn"                           254)
    ("tilde"                           732)
    ("Tilde"                           8764)
    ("TildeEqual"                      8771)
    ("TildeFullEqual"                  8773)
    ("TildeTilde"                      8776)
    ("timesbar"                        10801)
    ("timesb"                          8864)
    ("times"                           215)
    ("timesd"                          10800)
    ("tint"                            8749)
    ("toea"                            10536)
    ("topbot"                          9014)
    ("topcir"                          10993)
    ("top"                             8868)
    ("Topf"                            120139)
    ("topf"                            120165)
    ("topfork"                         10970)
    ("tosa"                            10537)
    ("tprime"                          8244)
    ("trade"                           8482)
    ("TRADE"                           8482)
    ("triangle"                        9653)
    ("triangledown"                    9663)
    ("triangleleft"                    9667)
    ("trianglelefteq"                  8884)
    ("triangleq"                       8796)
    ("triangleright"                   9657)
    ("trianglerighteq"                 8885)
    ("tridot"                          9708)
    ("trie"                            8796)
    ("triminus"                        10810)
    ("TripleDot"                       8411)
    ("triplus"                         10809)
    ("trisb"                           10701)
    ("tritime"                         10811)
    ("trpezium"                        9186)
    ("Tscr"                            119983)
    ("tscr"                            120009)
    ("TScy"                            1062)
    ("tscy"                            1094)
    ("TSHcy"                           1035)
    ("tshcy"                           1115)
    ("Tstrok"                          358)
    ("tstrok"                          359)
    ("twixt"                           8812)
    ("twoheadleftarrow"                8606)
    ("twoheadrightarrow"               8608)
    ("Uacute"                          218)
    ("uacute"                          250)
    ("uarr"                            8593)
    ("Uarr"                            8607)
    ("uArr"                            8657)
    ("Uarrocir"                        10569)
    ("Ubrcy"                           1038)
    ("ubrcy"                           1118)
    ("Ubreve"                          364)
    ("ubreve"                          365)
    ("Ucirc"                           219)
    ("ucirc"                           251)
    ("Ucy"                             1059)
    ("ucy"                             1091)
    ("udarr"                           8645)
    ("Udblac"                          368)
    ("udblac"                          369)
    ("udhar"                           10606)
    ("ufisht"                          10622)
    ("Ufr"                             120088)
    ("ufr"                             120114)
    ("Ugrave"                          217)
    ("ugrave"                          249)
    ("uHar"                            10595)
    ("uharl"                           8639)
    ("uharr"                           8638)
    ("uhblk"                           9600)
    ("ulcorn"                          8988)
    ("ulcorner"                        8988)
    ("ulcrop"                          8975)
    ("ultri"                           9720)
    ("Umacr"                           362)
    ("umacr"                           363)
    ("uml"                             168)
    ("UnderBar"                        95)
    ("UnderBrace"                      9183)
    ("UnderBracket"                    9141)
    ("UnderParenthesis"                9181)
    ("Union"                           8899)
    ("UnionPlus"                       8846)
    ("Uogon"                           370)
    ("uogon"                           371)
    ("Uopf"                            120140)
    ("uopf"                            120166)
    ("UpArrowBar"                      10514)
    ("uparrow"                         8593)
    ("UpArrow"                         8593)
    ("Uparrow"                         8657)
    ("UpArrowDownArrow"                8645)
    ("updownarrow"                     8597)
    ("UpDownArrow"                     8597)
    ("Updownarrow"                     8661)
    ("UpEquilibrium"                   10606)
    ("upharpoonleft"                   8639)
    ("upharpoonright"                  8638)
    ("uplus"                           8846)
    ("UpperLeftArrow"                  8598)
    ("UpperRightArrow"                 8599)
    ("upsi"                            965)
    ("Upsi"                            978)
    ("upsih"                           978)
    ("Upsilon"                         933)
    ("upsilon"                         965)
    ("UpTeeArrow"                      8613)
    ("UpTee"                           8869)
    ("upuparrows"                      8648)
    ("urcorn"                          8989)
    ("urcorner"                        8989)
    ("urcrop"                          8974)
    ("Uring"                           366)
    ("uring"                           367)
    ("urtri"                           9721)
    ("Uscr"                            119984)
    ("uscr"                            120010)
    ("utdot"                           8944)
    ("Utilde"                          360)
    ("utilde"                          361)
    ("utri"                            9653)
    ("utrif"                           9652)
    ("uuarr"                           8648)
    ("Uuml"                            220)
    ("uuml"                            252)
    ("uwangle"                         10663)
    ("vangrt"                          10652)
    ("varepsilon"                      1013)
    ("varkappa"                        1008)
    ("varnothing"                      8709)
    ("varphi"                          981)
    ("varpi"                           982)
    ("varpropto"                       8733)
    ("varr"                            8597)
    ("vArr"                            8661)
    ("varrho"                          1009)
    ("varsigma"                        962)
 %  ("varsubsetneq"                    8842, 65024)
 %  ("varsubsetneqq"                   10955, 65024)
 %  ("varsupsetneq"                    8843, 65024)
 %  ("varsupsetneqq"                   10956, 65024)
    ("vartheta"                        977)
    ("vartriangleleft"                 8882)
    ("vartriangleright"                8883)
    ("vBar"                            10984)
    ("Vbar"                            10987)
    ("vBarv"                           10985)
    ("Vcy"                             1042)
    ("vcy"                             1074)
    ("vdash"                           8866)
    ("vDash"                           8872)
    ("Vdash"                           8873)
    ("VDash"                           8875)
    ("Vdashl"                          10982)
    ("veebar"                          8891)
    ("vee"                             8744)
    ("Vee"                             8897)
    ("veeeq"                           8794)
    ("vellip"                          8942)
    ("verbar"                          124)
    ("Verbar"                          8214)
    ("vert"                            124)
    ("Vert"                            8214)
    ("VerticalBar"                     8739)
    ("VerticalLine"                    124)
    ("VerticalSeparator"               10072)
    ("VerticalTilde"                   8768)
    ("VeryThinSpace"                   8202)
    ("Vfr"                             120089)
    ("vfr"                             120115)
    ("vltri"                           8882)
 %  ("vnsub"                           8834, 8402)
 %  ("vnsup"                           8835, 8402)
    ("Vopf"                            120141)
    ("vopf"                            120167)
    ("vprop"                           8733)
    ("vrtri"                           8883)
    ("Vscr"                            119985)
    ("vscr"                            120011)
 %  ("vsubnE"                          10955, 65024)
 %  ("vsubne"                          8842, 65024)
 %  ("vsupnE"                          10956, 65024)
 %  ("vsupne"                          8843, 65024)
    ("Vvdash"                          8874)
    ("vzigzag"                         10650)
    ("Wcirc"                           372)
    ("wcirc"                           373)
    ("wedbar"                          10847)
    ("wedge"                           8743)
    ("Wedge"                           8896)
    ("wedgeq"                          8793)
    ("weierp"                          8472)
    ("Wfr"                             120090)
    ("wfr"                             120116)
    ("Wopf"                            120142)
    ("wopf"                            120168)
    ("wp"                              8472)
    ("wr"                              8768)
    ("wreath"                          8768)
    ("Wscr"                            119986)
    ("wscr"                            120012)
    ("xcap"                            8898)
    ("xcirc"                           9711)
    ("xcup"                            8899)
    ("xdtri"                           9661)
    ("Xfr"                             120091)
    ("xfr"                             120117)
    ("xharr"                           10231)
    ("xhArr"                           10234)
    ("Xi"                              926)
    ("xi"                              958)
    ("xlarr"                           10229)
    ("xlArr"                           10232)
    ("xmap"                            10236)
    ("xnis"                            8955)
    ("xodot"                           10752)
    ("Xopf"                            120143)
    ("xopf"                            120169)
    ("xoplus"                          10753)
    ("xotime"                          10754)
    ("xrarr"                           10230)
    ("xrArr"                           10233)
    ("Xscr"                            119987)
    ("xscr"                            120013)
    ("xsqcup"                          10758)
    ("xuplus"                          10756)
    ("xutri"                           9651)
    ("xvee"                            8897)
    ("xwedge"                          8896)
    ("Yacute"                          221)
    ("yacute"                          253)
    ("YAcy"                            1071)
    ("yacy"                            1103)
    ("Ycirc"                           374)
    ("ycirc"                           375)
    ("Ycy"                             1067)
    ("ycy"                             1099)
    ("yen"                             165)
    ("Yfr"                             120092)
    ("yfr"                             120118)
    ("YIcy"                            1031)
    ("yicy"                            1111)
    ("Yopf"                            120144)
    ("yopf"                            120170)
    ("Yscr"                            119988)
    ("yscr"                            120014)
    ("YUcy"                            1070)
    ("yucy"                            1102)
    ("yuml"                            255)
    ("Yuml"                            376)
    ("Zacute"                          377)
    ("zacute"                          378)
    ("Zcaron"                          381)
    ("zcaron"                          382)
    ("Zcy"                             1047)
    ("zcy"                             1079)
    ("Zdot"                            379)
    ("zdot"                            380)
    ("zeetrf"                          8488)
    ("ZeroWidthSpace"                  8203)
    ("Zeta"                            918)
    ("zeta"                            950)
    ("zfr"                             120119)
    ("Zfr"                             8488)
    ("ZHcy"                            1046)
    ("zhcy"                            1078)
    ("zigrarr"                         8669)
    ("zopf"                            120171)
    ("Zopf"                            8484)
    ("Zscr"                            119989)
    ("zscr"                            120015)
    ("zwj"                             8205)
    ("zwnj"                            8204)
  ) do put(intern car x, 'unicode_character, cadr x);


endmodule;

end;

D packages/rlisp/rprintf.red => packages/rlisp/rprintf.red +0 -657
@@ 1,657 0,0 @@
module rprintf; % formatted printing

% Note that I must not call this just "printf" because PSL has that as
% an existing module name.

% Author: Arthur Norman.

% Copyright (c) 2016 Arthur Norman.  All rights reserved.

% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are met:
%
%    * Redistributions of source code must retain the relevant copyright
%      notice, this list of conditions and the following disclaimer.
%    * Redistributions in binary form must reproduce the above copyright
%      notice, this list of conditions and the following disclaimer in the
%      documentation and/or other materials provided with the distribution.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
% CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%

% I will support bldmsg by having versions of the print primitives that
% dump characters in a list...

fluid '(bldmsg_chars!* !*ll!*);
bldmsg_chars!* := nil;

symbolic procedure p_princ(u, blankfirst);
  begin
    scalar w;
% With CSL if u is a string or a symbol with a print representation that
% contains characters outside the Basic Latin unicode block then the
% list w will contain a single item for each wide character. If you try the
% same in PSL then you may or may not survive...
    w := explode2 u;
    if bldmsg_chars!* then <<
      if blankfirst then bldmsg_chars!* := '!  . bldmsg_chars!*;
      for each c in w do bldmsg_chars!* := c . bldmsg_chars!* >>
    else <<
      if blankfirst then <<
         if posn() + length w  + 1 > !*ll!* then terpri();
         prin2 " " >>
      else if posn() + length w > !*ll!* then terpri();
      prin2 u >>
  end;

symbolic procedure p_prin(u, blankfirst);
  begin
    scalar w;
    w := explode u;
% At the time I implemented this PSL explodes the symbol with name "_a"
% as just (_ a) rather than as (! _ a). That would mean that the result
% would not read back into Reduce properly - so I stick in the extra
% escape character.
    if eqcar(w, '!_) then w := '!! . w;
    if bldmsg_chars!* then <<
      if blankfirst then bldmsg_chars!* := '!  . bldmsg_chars!*;
      for each c in w do bldmsg_chars!* := c . bldmsg_chars!* >>
    else <<
      if blankfirst then <<
        if posn() + length w + 1 > !*ll!* then terpri();
        prin2 " " >>
      else if posn() + length w > !*ll!* then terpri();
      for each c in w do prin2 c >>
  end;

%
% Code to print potentially re-entrant lists
%

fluid '(!*print!-array!*
        !*print!-length!*
        !*print!-level!*);

!*print!-array!* := t;        % Display contents if vectors if true
!*print!-length!* := nil;     % Limit length of lists printed if an integer
!*print!-level!* := nil;      % Limit depth of nesting if an integer.

fluid '(!*prinl_visited_nodes!* !*prinl_index!* );

!*prinl_visited_nodes!* := mkhash(200, 0, 1.5)$

symbolic procedure p_prinl0(x, escaped);
% print x even if it has loops in it. If escaped is true then printing
% is in the style of prin1, otherwise prin2.
  begin
    scalar !*prinl_index!*;
    !*prinl_index!*:=0;
% Clear the hash table AFTER use, so that the junk that goes into it does
% not gobble memory between calls to prinl. This relies on unwind!-protect
% to make sure that it is indeed always cleared. Errors (eg ^C) during the
% clean-up operation could lead to curious displays in the next use of
% prinl.
    unwind!-protect(<< p_prinl1(x, 0); p_prinl2(x, 0, escaped, nil) >>,
                    clrhash !*prinl_visited_nodes!*);
    return x
  end;

symbolic procedure p_prinl1(x, depth);
% Find all the nodes in x and record them in the hash table.
% The first time a node is met it is inserted with associated value 0.
% If a node is met a second time then it is assigned an unique positive
% integer code that will later be used in its label.
  begin
    scalar w, length;
    if fixp !*print!-level!* and depth > !*print!-level!* then return nil;
    length := 0;
 top:
    if atom x and not vectorp x and not gensymp x then return nil
    else if w := gethash(x,!*prinl_visited_nodes!*) then <<
       if w = 0 then <<
         !*prinl_index!* := !*prinl_index!* + 1;
         puthash(x,!*prinl_visited_nodes!*, !*prinl_index!*) >>;
       return nil >>
    else <<
      puthash(x, !*prinl_visited_nodes!*, 0);
      if vectorp x then <<
        if !*print!-array!* then <<
          length := upbv x;
          if fixp !*print!-length!* and !*print!-length!* < length then
              length := !*print!-length!*;
          for i:=0:length do p_prinl1(getv(x,i), depth+1) >> >>
      else if not atom x then <<
          p_prinl1(car x, depth+1);
          if fixp !*print!-length!* and
             (length := length+1) > !*print!-length!* then return nil;
          x := cdr x;
          go to top >> >>
  end;

symbolic procedure p_printref(w, blankfirst, ch);
% This prints "#NN#" possibly with a blank in front of it and
% perhaps splitting the line. Well it can also do "#NN=".
  begin
    scalar len;
    len := length explode w;
    if blankfirst then len := len + 1;
% Here I will break the line unless I can fit on "#nn#" or " #nn#" as
% relevant.
    if not bldmsg_chars!* and
       posn() + 2 + len > !*ll!* then <<
      blankfirst := nil;
      terpri() >>;
    p_princ("#", blankfirst);
    p_princ(w, nil);
    p_princ(ch, nil)
  end;

symbolic procedure p_prinl2(x, depth, escaped, blankfirst);
% Scan a structure that was previously processed by p_prinl1. Thus all
% nodes in x are already in the hash table. Those with value zero
% are only present once in x, while those with strictly positive values
% occur at least twice.  After printing a label for such value this resets the
% value negative so that the printing can tell when the visit is for
% a second rather than first time.  The output format is intended to
% bear some resemblance to the expectations of Common Lisp.
%
% Note that if the hash table is in fact empty then this will just print
% what "ordinary" prin/princ would.
    if fixp !*print!-level!* and depth > !*print!-level!* then
       p_princ("#", blankfirst)
    else if atom x and not vectorp x and not gensymp x then <<
       if escaped then p_prin(x, blankfirst)
       else p_princ(x, blankfirst) >>
    else begin scalar w, length;
      w := gethash(x,!*prinl_visited_nodes!*);
      if w and not zerop w then <<
        if w < 0 then <<
          p_printref(-w, blankfirst, "#");
          return nil >>
        else <<
          puthash(x,!*prinl_visited_nodes!*, -w);
          p_printref(w, blankfirst, "=");
          blankfirst := nil >> >>;
      if vectorp x then <<
         p_princ("%(", blankfirst);
         if !*print!-array!* then <<
           length := upbv x;
           if fixp !*print!-length!* and !*print!-length!* < length then
               length := !*print!-length!*;
           for i:=0:length do
             p_prinl2(getv(x,i), depth+1, escaped, i neq 0) >>
         else p_princ("...", nil);
         p_princ(")", nil);
         return nil >>
      else if atom x then <<
        if escaped then p_prin(x, blankfirst)
        else p_princ(x, blankfirst);
        return nil >>;
      p_princ("(", blankfirst);
      p_prinl2(car x, depth+1, escaped, nil);
      x:=cdr x;
      length := 0;
  loop:
      if atom x then <<
        if x neq nil then <<
          p_princ(".", t);
          p_prinl2(x, depth, escaped, t) >>;
        return p_princ(")", nil) >>;
      if fixp !*print!-length!* and
         (length := length + 1) > !*print!-length!* then <<
             p_princ("...", t);
             return p_princ(")", nil) >>;
      w := gethash(x, !*prinl_visited_nodes!*);
      if w and not zerop w then <<
        if w < 0 then <<
          p_princ(".", t);
          p_printref(-w, t, "#");
          return p_princ(")", nil) >>
        else <<
          p_princ(".", t);
          p_prinl2(x, depth+1, escaped, t);
          return p_princ(")", nil) >> >>;
      p_prinl2(car x, depth+1, escaped, t);
      x:=cdr x;
      go to loop
    end;

symbolic procedure rlisp_printl x;
 << rplisp_prinl x;
    terpri();
    x >>;

symbolic procedure rlisp_printcl x;
 << rlisp_princl x;
    terpri();
    x >>;

symbolic procedure rlisp_princl x;
  begin
    scalar !*ll!*;
    !*ll!* := linelength nil - 2;
    p_prinl0(x, nil);
    return x;
  end;

symbolic procedure rlisp_prinl x;
  begin
    scalar !*ll!*;
    !*ll!* := linelength nil - 2;
    p_prinl0(x, t);
    return x;
  end;

symbolic procedure portable_print x;
 << portable_prin x;
    terpri();
    x >>;

symbolic procedure portable_printc x;
 << portable_princ x;
    terpri();
    x >>;

symbolic procedure portable_princ x;
  begin
    scalar !*ll!*;
    !*ll!* := linelength nil - 2;
    p_prinl2(x, 0, nil, nil);
    return x;
  end;

symbolic procedure portable_prin x;
  begin
    scalar !*ll!*;
    !*ll!* := linelength nil - 2;
    p_prinl2(x, 0, t, nil);
    return x;
  end;

% The following will print a prefix expression. It will use infix
% notation and understand precedence for expt, times, quotient, plus,
% difference and minus -- all other operators are treated as general
% function applications. If !*SQ is encountered within the formula it
% will be expanded out using prepsq.

% The output from prepf does not use DIFFERENCE as an operator, but in
% case one is fed in from some other odd source I will normalise things
% here.

symbolic procedure p_minus u;
  if eqcar(u, 'minus) then cadr u
  else if eqcar(u, 'plus) then
    'plus . for each v in cdr u collect p_minus v
  else if eqcar(u, 'difference) then
    'plus . p_minus cadr u . cddr u
  else list('minus, u);

symbolic procedure p_diff2minus u;
  begin
    scalar r;
    r := car u;
    while u := cdr u do r := p_minus car u . r;
    return 'plus . reverse r
  end;

symbolic procedure p_prefix(u, prec);
  if atom u then p_princ(u, nil)
  else if eqcar(u, '!*sq) then p_prefix(prepsq cadr u, prec)
  else
    begin
      scalar op, p1;
      op := car u;
% I will have a crude code-based (rather than table-driven) treatment of the
% small number of special cases of infix operators that I support here...
      if op ='expt then <<
        if prec > 3 then p_princ("(", nil);
        p_prefix(cadr u, 4);
        p_princ("^", nil);
        p_prefix(caddr u, 3);
        if prec > 3 then p_princ(")", nil);
        return nil >>
      else if op = 'times or op = 'quotient then <<
        if prec > 2 then p_princ("(", nil);
        p_prefix(car (u := cdr u), 2);
        if op = 'times then << p1 := 2; op := "*" >>
        else << p1 := 3; op := "/" >>;
% If I have (quotient a (times b c)) I must parenthesize the use of "times",
% but if I had (times a (quotient b c)) I need not parenthesize the quotient
% because (a*(b/c)) has the same value as (a*b)/c so can be displated as
% just a*b/c safely.
        while not atom (u := cdr u) do <<
          p_princ(op, nil);
          p_prefix(car u, p1) >>;
        if prec > 2 then p_princ(")", nil);
        return nil >>;
      if op = 'difference then return p_prefix(p_diff2minus cdr u, prec)
      else if op = 'plus then <<
        if prec > 1 then p_princ("(", nil);
        p_prefix(car (u := cdr u), 1);
        while not atom (u := cdr u) do <<
          p1 := car u;
          if eqcar(p1, 'minus) then <<
            p1 := cadr p1;
            p_princ(" - ", nil) >>
          else p_princ(" + ", nil);
          p_prefix(p1, 1) >>;
        if prec > 1 then p_princ(")", nil);
        return nil >>
      else if op = 'minus then <<
        p_princ("-", nil);
        if prec < 2 then prec := 2;
        return p_prefix(cadr u, prec) >>;
% Here I have something I will display as a raw function application. I will
% take special action if the "function" part is complicated!
      if (not atom op) or (numberp op and minusp op) then <<
        p_princ("(", nil);
        p_prefix(op, 0);
        p_princ(")", nil) >>
      else p_princ(op, nil);
      op := "(";
% A function with no args needs "()" after it.
      if atom (u := cdr u) then p_princ("(", nil)
      else for each x in u do <<
        p_princ(op, nil);
        op := ",";
        p_prefix(x, 0) >>;
      return p_princ(")", nil)
    end;

% Sometimes I want to print a Lisp expression starting at the current
% column and with confidence that My Lisp system will keep output within
% consistent line-length limits. Here I provide functions to do that which
% might lead to a display of the style:    (here is where I start an if
%                                          something is not going to fit
%                                          on the line I wrap to the
%                                          starting column. If
%                      someextraordinaryilylongstmbolisincludedthatcannot
%                                          cope with the given width I
%                                          will right-align it as shown.
%

symbolic procedure prin_with_margin u;
   print_with_margin_sub(u, posn(), linelength nil-2, function explode);

symbolic procedure princ_with_margin u;
   print_with_margin_sub(u, posn(), linelength nil-2, function explode2);

symbolic procedure print_with_margin u;
 << prin_with_margin u;
    terpri();
    u >>;

symbolic procedure printc_with_margin u;
 << princ_with_margin u;
    terpri();
    u >>;

% I will cope with symbols, numbers, strings and lists. Vectors and other
% objects will be rendered cryptically at best.

symbolic procedure print_with_margin_sub(u, left, right, explfn);
  begin
    scalar v;
% Override pathologically narrow cases.
    if right < 10 then right := 10;
    if left > right-10 then left := right-10;
    v := u;
% Cope with lists.
    if not atom v then <<
      if posn() >= right then << terpri(); ttab left >>;
      prin2 "(";
      print_with_margin_sub(car v, left, right, explfn);
      while not atom (v := cdr v) do <<
        if posn() >= right then << terpri(); ttab left >>
        else prin2 " ";
        print_with_margin_sub(car v, left, right, explfn) >>;
      if not null v then <<
        if posn() >= right-1 then << terpri(); ttab left; prin2 ". " >>
        else prin2 " .";
        print_with_margin_sub(v, left, right, explfn) >>;
        if posn() >= right then << terpri(); ttab left >>;
        prin2 ")";
      return u >>;
% Here I have something atomic. Use the explode operator I was handed
% to see how long its printed representation would be.
    v := apply(explfn, list u);
% In the case of unreasonably long atoms I will need to split things
% across lines, and I come back to here when I have made at least some
% headway.
verylong:
    if posn() + length v < right then <<
      for each c in v do prin2 c;
      return u >>
    else if length v <= right-left then <<
      terpri();
      ttab left;
      for each c in v do prin2 c;
      return u >>
    else if length v < right then <<
      terpri();
      ttab(right - length v);
      for each c in v do prin2 c;
      return u >>
    else <<
      if posn() >= right-5 then << terpri(); ttab left >>;
      while posn() < right-1 do <<
        prin2 car v;
        v := cdr v >>;
      prin2 "\";
      terpri();
      go to verylong >>
  end;


% Now for printf...

% The special sequences that can occur in format strings are as follows.
% I will make my tests for directives case insensitive, so for instance
% either %b or %B will be recognized.
%       %b    do that many spaces
%       %c    next arg is a character code. display character
%       %d    print an integer (equivalent to %w)
% *     %f    do a terpri() unless posn()=0
%       %l    prin2 items from given list, blank separated
% *     %n    do a terpri()
%       %o    print in octal
%       %q    print as with prin1 but such that looped structures are OK
%       %p    print using prin1
%       %r    As '%q'
%       %s    print as a string (equivalent to %w)
%       %t    move to given column, performing a terpri first
%             if currently beyond it.
%       %w    use prin2
%       %x    print in hexadecimal
% *     %%    print a '%' character
%       %@f   print as standard form
%       %@q   print as standard quotient
%       %@p   print as prefix form
% All except those marked with "*" use an argument.


symbolic procedure bldmsg_internal(fmt, args);
  begin
    scalar bldmsg_chars!*, u, v;
    bldmsg_chars!* := t;
    printf_internal(fmt, args);
    while not atom bldmsg_chars!* do <<
      u := cdr bldmsg_chars!*;
      rplacd(bldmsg_chars!*, v);
      v := bldmsg_chars!*;
      bldmsg_chars!* := u >>;
    return list2widestring v
  end;

symbolic procedure p_posn();
  if bldmsg_chars!* then
  begin
    scalar w, n;
    n := 0;
    w := bldmsg_chars!*;
    while not atom w and not (car w = !$eol!$) do <<
      n := n + 1;
      w := cdr w >>;
    return n
  end
  else posn();

% I want octal and hex printing. For portability I implement my own.

global '(p_hexdigits!*);

<< p_hexdigits!* := mkvect 15;
   putv(p_hexdigits!*, 0, '!0);
   putv(p_hexdigits!*, 1, '!1);
   putv(p_hexdigits!*, 2, '!2);
   putv(p_hexdigits!*, 3, '!3);
   putv(p_hexdigits!*, 4, '!4);
   putv(p_hexdigits!*, 5, '!5);
   putv(p_hexdigits!*, 6, '!6);
   putv(p_hexdigits!*, 7, '!7);
   putv(p_hexdigits!*, 8, '!8);
   putv(p_hexdigits!*, 9, '!9);
   putv(p_hexdigits!*, 10, '!a);
   putv(p_hexdigits!*, 11, '!b);
   putv(p_hexdigits!*, 12, '!c);
   putv(p_hexdigits!*, 13, '!d);
   putv(p_hexdigits!*, 14, '!e);
   putv(p_hexdigits!*, 15, '!f) >>;

symbolic procedure p_prinhex n;
  if not fixp n then p_princ("<not-a-number>", nil)
  else begin
    scalar b, w;
    if n >= 0 then <<
      while n >= 16 do <<
        b := getv(p_hexdigits!*, w := mod(n, 16)) . b;
        n := (n - w)/16 >>;
      b := getv(p_hexdigits!*, mod(n, 16)) . b >>
    else <<
      while n < -1 do <<
        b := getv(p_hexdigits!*, w := mod(n, 16)) . b;
        n := (n - w)/16 >>;
      b := '!~ . getv(p_hexdigits!*, mod(n, 16)) . b >>;
    if null bldmsg_chars!* and (posn() + length b) > !*ll!* then terpri();
    for each c in b do p_princ(c, nil)
  end;

symbolic procedure p_prinoctal n;
  if not fixp n then p_princ("<not-a-number>", nil)
  else begin
    scalar b, w;
    if n >= 0 then <<
      while n >= 8 do <<
        b := (w := mod(n, 8)) . b;
        n := (n - w)/8 >>;
      b := mod(n, 8) . b >>
    else <<
      while n < -1 do <<
        b := (w := mod(n, 8)) . b;
        n := (n - w)/8 >>;
      b := '!~ . mod(n, 8) . b >>;
    if null bldmsg_chars!* and (posn() + length b) > !*ll!* then terpri();
    for each c in b do p_princ(c, nil)
  end;

symbolic procedure printf_internal(fmt, args);
  begin
    scalar a, c, !*ll!*;
    !*ll!* := linelength nil - 2;
    fmt := explode2 fmt;
    while fmt do <<
      c := car fmt;
      fmt := cdr fmt;
      if c neq '!% then p_princ(c, nil)
      else <<
        c := car fmt;
        fmt := cdr fmt;
        if c = '!f then << if not bldmsg_chars!* and
                              not zerop posn() then terpri() >>  
        else if c = '!n or c = '!N then p_princ(!$eol!$, nil)
        else if c = '!% then p_princ(c, nil)
        else <<
          if null args then a := nil
          else <<
            a := car args;
            args := cdr args >>;
          if (c = '!b or c = '!B) and fixp a then
            for i := 1:a do p_princ(" ", nil)
          else if c = '!c or c = '!C then <<
% "%c" will accept either an integer or a symbol that should be a single
% character.
             if fixp a then p_princ(list2widestring list a, nil)
             else p_princ(a, nil) >> 
          else if c = '!l or c = '!L then <<
            if not atom a then <<
              portable_princ car a;
              for each x in cdr a do <<
                p_princ(" ", nil);
                portable_princ x >> >> >>
          else if c = '!o or c = '!O then p_prinoctal a
          else if c = '!p or c = '!P then portable_prin a
          else if c = '!q or c = '!Q then rlisp_prinl a
          else if c = '!r or c = '!R then <<
            p_princ("'", nil); rlisp_prinl a; p_princ("'", nil) >>
          else if (c = '!t or c = '!T) and fixp a then <<
            if p_posn() > a then p_princ(!$eol!$, nil);
            while p_posn() < a do p_princ(" ", nil) >>
% "%w", "%d" and "%s" here all just use princ. The original idea was that
% "%d" was for (decimal) integers and "%s" for strings, but there is no
% really useful optimisation to be had by trying to find type-specific
% print functions to call here.
          else if c = '!w or c = '!d or c = '!s or
                  c = '!W or c = '!D or c = '!S then portable_princ a
% As with octal output, PSL can achieve this a diffenent way and will
% generate differently formatted output.
          else if c = '!x or c = '!X then p_prinhex a
          else if c = '!@ then <<
            c := car fmt;
            fmt := cdr fmt;
            if c = '!f or c = '!F then p_prefix(prepf a, 0)
            else if c = '!q or c = '!Q then p_prefix(prepsq a, 0)
            else if c = '!p or c = '!P then p_prefix(a, 0)
            else << p_princ("%@", nil); p_princ(c, nil) >> >>
          else if c = '!e or c = '!E then eval a 
% Rather than generating an error I will display %? (where ? is any
% unrecognized character) unchanged.
          else << p_princ("%", nil); p_princ(c, nil) >> >> >> >>
  end;

symbolic macro procedure rlisp_printf u;
   list('printf_internal, cadr u, 'list . cddr u);

symbolic macro procedure rlisp_bldmsg u;
  list('bldmsg_internal, cadr u, 'list . cddr u);

flag('(rlisp_printf rlisp_bldmsg), 'variadic);


% There is a significant issue here. PSL has functions printf and
% bldmsg built in to its kernel. They are defined as regular functions
% that take an indefinite number of arguments., and it looks to me
% If I overwrite those definitions with the macro that I use here
% the result is disaster.instead I define my macros with the private
% names rlisp_printf and rlisp_bldmsg then get rlisp to map the names
% printf and bldmsg onto those. 
% I follow this path on both CSL and PSL even though there are no terrible
% clashes with CSL.

put('printf, 'newnam, 'rlisp_printf);
put('bldmsg, 'newnam, 'rlisp_bldmsg);
put('prinl,  'newnam, 'rlisp_prinl);

endmodule;

end;

M packages/rtools/rtrace.red => packages/rtools/rtrace.red +41 -10
@@ 34,7 34,7 @@ module rtrace; % Crude tracing but with output compatible across Lisps
% with file-comprisons on log files. The output may in fact not be
% independent of the Lisp. One particular issue is that when a function
% is recursive the calls to itself may go via the mechanism that lets this
% code interfect them, it may take shortcuts, or the recursion may have been
% code intercept them, it may take shortcuts, or the recursion may have been
% mapped onto iteration.
%
% I do not provide a simple!-untrace function, and I do not protect against


@@ 54,11 54,40 @@ module rtrace; % Crude tracing but with output compatible across Lisps
copyd('!~!~saved_getd, 'getd);
copyd('!~!~saved_putd, 'putd);

% I will need to know how many arguments the function I am going to trace
% has, and I will not be able to cope with FEXPRS or &opt or &rest, and
% with CSL I will not manage to extract that information in the case of
% some built-in functions that take 4 or more arguments.

#if (memq 'psl lispsystem!*)

symbolic procedure s!:argcount fn;
  begin
    scalar n;
    if fixp (n := get(fn, 'number!-of!-args)) then return n;
    n := getd fn;
    if not eqcar(n, 'expr) then return nil;
    n := cdr n;
    if codep n then return code!-number!-of!-arguments n
    else if eqcar(n, 'lambda) then return length cadr n
    else return nil
  end;

#else

symbolic procedure s!:argcount fn;
  begin
    scalar n;
    if (n := get(fn, number!-of!-args)) then return n
    else if (n := symbol!-argcount fn) then return n
    else return nil
  end;

#endif

symbolic procedure s!:traced!-version(fn, nargs, newfn);
  begin
    scalar v := for i := 1:nargs collect gensym(),
           r := gensym(), p, k;
    k := 0;
    scalar r := gensym(), k := 0, v := for i := 1:nargs collect gensym(), p;
    p := list('prog, list r,
            '(cond ((null (zerop (posn))) (terpri))),
            list('prin2, "Entering "),


@@ 79,17 108,19 @@ symbolic procedure s!:traced!-version(fn, nargs, newfn);
   
symbolic procedure s!:trace fn;
  begin
    scalar d := !~!~saved_getd fn,
           g := intern list2string append(explode2 "~saved_", explode2 fn);
    if not eqcar(d, 'expr) then <<
    scalar d := !~!~saved_getd fn, nargs, !*redefmsg,
           g := intern list2string append(explode2 "~saved_", explode2 fn),
           !*comp := t, !*pwrds := nil;
    if not eqcar(d, 'expr) or
       null (nargs := s!:argcount fn) then <<
       if not zerop posn() then terpri();
       prin2 "+++ ";
       print fm;
       prin1 fn;
       prin2 " not traceable";
       return terpri() >>;
    !~!~saved_putd(g, car d, cdr d);
    !~!~saved~putd(fn, 'expr,
       s!:traced!-version(fn, get(fn, 'number!-of!-args), g));
    !~!~saved_putd(fn, 'expr,
       s!:traced!-version(fn, nargs, g));
  end;

symbolic procedure simple!-trace l;

M packages/support/revision.red => packages/support/revision.red +1 -1
@@ 31,6 31,6 @@

fluid '(revision!*);

revision!* := 5847;
revision!* := 5854;

end;

M psl/dist/lap/AMD64_ext/hashtable.b => psl/dist/lap/AMD64_ext/hashtable.b +0 -0
M psl/dist/lap/armv6/hashtable.b => psl/dist/lap/armv6/hashtable.b +0 -0
M psl/dist/lap/linux/hashtable.b => psl/dist/lap/linux/hashtable.b +0 -0
M psl/dist/lap/mingw-w64/hashtable.b => psl/dist/lap/mingw-w64/hashtable.b +0 -0
M psl/dist/nonkernel/aarch64/backtrace.sl => psl/dist/nonkernel/aarch64/backtrace.sl +1 -1
@@ 95,7 95,7 @@
  (prog (here x)
    (unless (member 'addr2id options*)
      (load addr2id))
    (setq here (loc here))
    (setq here (if on-altstack* stack-pointer* (loc here)))
    (for % start a little before here
     (from i here (wshift stacklowerbound 5)
	   (wminus

M psl/dist/nonkernel/aarch64/lap/backtrace.b => psl/dist/nonkernel/aarch64/lap/backtrace.b +0 -0
M psl/dist/util/hashtable.sl => psl/dist/util/hashtable.sl +7 -3
@@ 60,10 60,11 @@

(setq *sxhash-max-depth* 5)

(define-constant *sxhash-cons-default-value* 261835505)
% This is the constant 261835505, truncated to 27bits, in order to make it an inum (posint/negint)
(define-constant *sxhash-cons-default-value* 127617777)

% This is the golden ration times 2^32
%(define-constant !#hash-multiplier!# (wconst 16#9E3779B9))
(define-constant !#hash-multiplier!# 16#9E3779B9)

% For reference: golden ration times 2^64 is 16#9e3779b97f4a7c15



@@ 77,11 78,14 @@
 (progn
   (when (equal bitsperword 64)
     (ds sxhash-float (o) (wshift (floathighorder o) -8))
     (ds get-hash-multiplier () !#hash-multiplier!#)
     )
   (when (equal bitsperword 32)
     (ds sxhash-float (o)
	 (wshift (wxor (floathighorder o) (floatloworder o)) -8))
     )
     % Truncate *sxhash-cons-default-value* to 27bits, in order to make it an inum (posint/negint)
     (ds get-hash-multiplier () (int2sys !#hash-multiplier!#))
   ))

(de sxhash-float-x (o) (sxhash-float o))


@@ 216,7 220,7 @@
      t))

(ds hash-to-key (key shftamount mask)
    (wplus2 1 (wand (wshift (wtimes2 (sxhash key) (wconst 16#9E3779B9)) shftamount) mask)))
    (wplus2 1 (wand (wshift (wtimes2 (sxhash key) (get-hash-multiplier)) shftamount) mask)))

(de puthash (key table value)
    (if (valid-hashtable table 'puthash)

M scripts/make.sh => scripts/make.sh +42 -52
@@ 11,12 11,22 @@

# Note that this tries to identify all potentially relevent build
# directories that contain a "Makefile", that being used as a signature
# that they have been configured. It allows for suffixes "-m32" "-m64"
# and "-debug" as in scripts/findhost.sh.
# that they have been configured. It allows for suffixes such as
# "-debug" as in scripts/findhost.sh.

# It also tries to build both CSL and PSL setups when they have been
# configured.

# To help with a migration to a new scheme here I will arrange that
# if the user has gone "export NEW=NEW" then Makefile.new will be activated

if test "$NEW" = "NEW"
then
  printf "+++ Using Makefile.new +++\n"
  make -f Makefile.new $*
  exit $!
fi

printf "MFLAGS=<%s> MKFLAGS=<%s> MAKECMDGOALS=<%s> args=<%s>\n" \
       "$MFLAGS"    "$MKFLAGS"   "$MAKECMDGOALS"   "$*"



@@ 24,7 34,6 @@ args=""
flags=""
buildcsl="no"
buildpsl="no"
rc=0

for a in $*
do


@@ 87,7 96,7 @@ printf "Current machine tag is %s\n" "$host"
# installed it for themselves. Some BSD variants will build imported
# packages in /pkg/bin so I look there too...

if test "x$MAKE" = "x"
if test "$MAKE" = ""
then
  if test -x /usr/sfw/bin/gmake
  then MAKE=/usr/sfw/bin/gmake


@@ 109,31 118,23 @@ fi

procids=""

rc=0

list=""
if test "$buildcsl" = "yes"
then
  case "$os" in
  *cygwin* | *windows*)
    list="cslbuild/*-cygwin* cslbuild/*-windows*"
    list="cslbuild/*-cygwin*/csl cslbuild/*-windows*/csl"
    ;;
  *)
    list="cslbuild/*${host}*"
    list="cslbuild/*${host}*/csl"
    ;;
  esac
fi

firstcsl=""
if test "x$list" != "x"
firstcsl=${list%% *}
if ! test -f "$firstcsl/Makefile"
then
  for x in $list
  do
    if test "x$firstcsl" = "x" && test -f "$x/csl/Makefile"
    then
      firstcsl="$x"
    fi
  done
  firstcsl=""
fi

if test "$buildpsl" = "yes"


@@ 148,9 149,6 @@ then
  esac
fi

# I will - now - always try building all possible versions in parallel,
# except that I will ensure that I re-create the generated C++ stuff first
# if that needs doing.
case $args in
# If I am making bootstrapreduce or bootstrapreduce.img or csl or csl.img or
# one of the demo programs I do not need the generated C code...


@@ 159,44 157,36 @@ case $args in
  ;;
esac

for l in $list
printf "Will build for\n";
for dd in $list
do
  case $l in
  i686*cygwin*)
    x86_64-w64-mingw32-g++ ?/other-cygwin.cpp -DFORCE32=1 -o cyg32
    PREFIX=./cyg32
    ;;
  *)
    PREFIX=
    ;;
  esac
  if test -f ${l}/Makefile
  printf "  $dd\n"
done

if test "$firstcsl" != ""
then
  $MAKE -C "$firstcsl" c-code MYFLAGS="$flags"
  rc=$?
else
  rc=0
fi

for dd in $list
do
  if test -f $dd/Makefile
  then
    h=`pwd`
    case $l in
    i686*cygwin*)
      x86_64-w64-mingw32-g++ csl/cslbase/other-cygwin.cpp -DFORCE32=1 -o cyg32
      PREFIX=$h/cyg32
      ;;
    *)
      PREFIX=
      ;;
    esac
    cd ${l}
    if test "x$firstcsl" != "x"
    then
      $PREFIX $MAKE c-code
      rc1=$?
      rc=$(($rc1 > $rc ? $rc1 : $rc)) 
      firstcsl=""
    fi
    $PREFIX $MAKE $flags $args MYFLAGS="$flags" 
    printf "++ Build in directory $dd\n"
    $MAKE -C $dd $flags $args MYFLAGS="$flags"
    rc1=$?
    rc=$(($rc1 > $rc ? $rc1 : $rc)) 
    cd "$h"
  fi
done

printf "\nReduce build tasks finished with highest return code $rc\n"
if test "$rc" = "0"
then
  printf "\nReduce build tasks finished.\n"
else
  printf "\nReduce build tasks finished: Highest return code $rc\n"
fi

exit $rc