├── .gitignore ├── BuildCore ├── README.md └── src │ ├── CMakeLists.txt │ ├── absmach.c │ ├── absmach.h │ ├── arith.c │ ├── arith.h │ ├── atops.c │ ├── basics.c │ ├── basics.h │ ├── bitops.c │ ├── blders.c │ ├── blders.h │ ├── compare.c │ ├── compare.h │ ├── defstbl.h │ ├── eval.c │ ├── eval.h │ ├── eval_fun.c │ ├── faults.h │ ├── fileio.c │ ├── fileio.h │ ├── getters.h │ ├── if.h │ ├── insel.c │ ├── insel.h │ ├── lexical.h │ ├── lib_main.c │ ├── lib_main.h │ ├── linalg.c │ ├── linenoise.c │ ├── linenoise.h │ ├── logicops.c │ ├── logicops.h │ ├── main_stu.c │ ├── nialconsts.h │ ├── nialtypes.h │ ├── ops.h │ ├── parse.c │ ├── parse.h │ ├── picture.c │ ├── picture.h │ ├── pkgswchs.h │ ├── profile.c │ ├── profile.h │ ├── qniallim.h │ ├── reserved.h │ ├── resnms.h │ ├── roles.h │ ├── scan.c │ ├── scan.h │ ├── sorts.c │ ├── sorts.h │ ├── states.h │ ├── switches.h │ ├── symtab.c │ ├── symtab.h │ ├── systemops.c │ ├── systemops.h │ ├── token.h │ ├── trig.c │ ├── trig.h │ ├── trs.c │ ├── trs.h │ ├── unixif.c │ ├── unixif.h │ ├── userops.c │ ├── utils.c │ ├── utils.h │ ├── version.h │ ├── windowsif.c │ ├── windowsif.h │ ├── wsmanage.c │ └── wsmanage.h ├── BuildNial ├── README.md ├── pkgblder │ ├── Cmakeheader │ ├── Cmakemiddle │ ├── Cmaketrailer │ ├── addfeatures.ndf │ ├── all_features │ │ ├── DEBUGINCLUDED │ │ │ ├── DEBUGINCLUDED_src │ │ │ │ ├── diag.c │ │ │ │ └── diag.h │ │ │ ├── debugincluded.nh │ │ │ └── debugincluded_cmake │ │ ├── MEMSPACES │ │ │ ├── MEMSPACES_src │ │ │ │ ├── mcore.h │ │ │ │ ├── memspaces.c │ │ │ │ └── memspaces.h │ │ │ ├── memspaces.nh │ │ │ └── memspaces_cmake │ │ ├── NCOMPLEX │ │ │ ├── NCOMPLEX_src │ │ │ │ └── ncomplex.c │ │ │ ├── ncomplex.ndf │ │ │ └── ncomplex.nh │ │ ├── NDYNLOAD │ │ │ ├── NDYNLOAD_src │ │ │ │ └── ndynload.c │ │ │ └── ndynload.nh │ │ ├── NFILES │ │ │ ├── NFILES_src │ │ │ │ └── nfiles.c │ │ │ └── nfiles.nh │ │ ├── NIALDSP │ │ │ ├── NIALDSP_src │ │ │ │ └── nialdsp.c │ │ │ └── nialdsp.nh │ │ ├── NIAL_FFTW │ │ │ ├── NIAL_FFTW_src │ │ │ │ └── nial_fftw.c │ │ │ ├── README.md │ │ │ ├── nial_fftw.nh │ │ │ └── nial_fftw_cmake │ │ ├── NREFS │ │ │ ├── NREFS_src │ │ │ │ └── nrefs.c │ │ │ ├── nrefs.ndf │ │ │ └── nrefs.nh │ │ ├── NSFML_AUDIO │ │ │ ├── NSFML_AUDIO_src │ │ │ │ └── nsfml_audio.c │ │ │ ├── README.md │ │ │ ├── nsfml_audio.nh │ │ │ └── nsfml_audio_cmake │ │ ├── NTABLES │ │ │ ├── NTABLES_src │ │ │ │ └── ntable.c │ │ │ ├── ntables.ndf │ │ │ └── ntables.nh │ │ ├── PROCESS │ │ │ ├── PROCESS_src │ │ │ │ └── process.c │ │ │ └── process.nh │ │ ├── QSORT │ │ │ ├── QSORT_src │ │ │ │ ├── sorts.c │ │ │ │ └── sorts.h │ │ │ └── qsort.nh │ │ ├── REGEXP │ │ │ ├── REGEXP_src │ │ │ │ └── posix_regex.c │ │ │ ├── regexp.ndf │ │ │ └── regexp.nh │ │ ├── SOCKETS │ │ │ ├── SOCKETS_src │ │ │ │ └── sockets.c │ │ │ ├── sockets.ndf │ │ │ ├── sockets.nh │ │ │ └── sockets_cmake │ │ ├── SPROCESS │ │ │ ├── SPROCESS_src │ │ │ │ ├── nstreams.c │ │ │ │ ├── nstreams.h │ │ │ │ └── sprocess.c │ │ │ └── sprocess.nh │ │ └── WINPROCESS │ │ │ ├── WINPROCESS_src │ │ │ └── winprocess.c │ │ │ └── winprocess.nh │ ├── buildfromcore.ndf │ ├── coreprims.nh │ ├── nialcoredefs.ndf │ ├── packages │ │ ├── AllFeatures.txt │ │ ├── FreeBSDCore.txt │ │ ├── LinuxCore.txt │ │ ├── QNial7.txt │ │ ├── README.md │ │ ├── WinAllFeatures.txt │ │ ├── WinQNial7.txt │ │ ├── basic_debug.txt │ │ └── basic_nial.txt │ └── src_nialcore │ │ ├── absmach.c │ │ ├── absmach.h │ │ ├── arith.c │ │ ├── arith.h │ │ ├── atops.c │ │ ├── bitops.c │ │ ├── blders.c │ │ ├── blders.h │ │ ├── compare.c │ │ ├── compare.h │ │ ├── diag.c │ │ ├── diag.h │ │ ├── eval.c │ │ ├── eval.h │ │ ├── eval_fun.c │ │ ├── faults.h │ │ ├── fileio.c │ │ ├── fileio.h │ │ ├── getters.h │ │ ├── if.h │ │ ├── insel.c │ │ ├── insel.h │ │ ├── lexical.h │ │ ├── lib_main.c │ │ ├── lib_main.h │ │ ├── linalg.c │ │ ├── linenoise.c │ │ ├── linenoise.h │ │ ├── logicops.c │ │ ├── logicops.h │ │ ├── main_stu.c │ │ ├── nialconsts.h │ │ ├── nialtypes.h │ │ ├── ops.h │ │ ├── parse.c │ │ ├── parse.h │ │ ├── picture.c │ │ ├── picture.h │ │ ├── profile.c │ │ ├── profile.h │ │ ├── qniallim.h │ │ ├── reserved.h │ │ ├── resnms.h │ │ ├── roles.h │ │ ├── scan.c │ │ ├── scan.h │ │ ├── sorts.c │ │ ├── sorts.h │ │ ├── states.h │ │ ├── switches.h │ │ ├── symtab.c │ │ ├── symtab.h │ │ ├── systemops.c │ │ ├── systemops.h │ │ ├── token.h │ │ ├── trig.c │ │ ├── trig.h │ │ ├── trs.c │ │ ├── trs.h │ │ ├── unixif.c │ │ ├── unixif.h │ │ ├── userops.c │ │ ├── utils.c │ │ ├── utils.h │ │ ├── version.h │ │ ├── windowsif.c │ │ ├── windowsif.h │ │ ├── wsmanage.c │ │ └── wsmanage.h ├── testing │ ├── comparison │ │ ├── DataTrans.java │ │ ├── data_trans.ijs │ │ ├── data_trans.ndf │ │ ├── data_trans.py │ │ ├── primes.ijs │ │ ├── primes.ndf │ │ ├── primes.py │ │ ├── sort_tests.ijs │ │ └── sort_tests.ndf │ ├── extension_testing │ │ ├── atomic_test1.ndf │ │ ├── catch_throw_tests.ndf │ │ ├── catch_throw_tests.nlg │ │ ├── defs.ndf │ │ ├── j.ndf │ │ ├── memspaces.ndf │ │ ├── nial_testing.ndf │ │ ├── nio_test1.ndf │ │ ├── nio_test2.ndf │ │ ├── nipops.ndf │ │ ├── ntableTests.ndf │ │ ├── ntables_tests.ndf │ │ ├── streams_test1.ndf │ │ ├── strsearch.ndf │ │ ├── tcp_worker_client.ndf │ │ ├── tcp_worker_server.ndf │ │ └── worker_test1.ndf │ └── v7testing │ │ ├── README.md │ │ ├── alltests │ │ ├── atcases │ │ ├── autocov.ndf │ │ ├── autodata │ │ ├── autoeval.ndf │ │ ├── autoids.ndf │ │ ├── autoops.ndf │ │ ├── autopic.ndf │ │ ├── autorand.ndf │ │ ├── autotest │ │ ├── benchmk.ndf │ │ ├── binops │ │ ├── breaktest.ndf │ │ ├── check10.ndf │ │ ├── chopheap.ndf │ │ ├── consist.ndf │ │ ├── constant │ │ ├── conststs.ndf │ │ ├── control │ │ ├── coverops.ndf │ │ ├── datagen.ndf │ │ ├── defines │ │ ├── evassign │ │ ├── evtests │ │ ├── exprs │ │ ├── faulteq.ndf │ │ ├── filechk.ndf │ │ ├── fragsped.ndf │ │ ├── fuzzyeq.ndf │ │ ├── ids.ndf │ │ ├── idtests.ndf │ │ ├── indexing │ │ ├── largeintids.ndf │ │ ├── lgdatage.ndf │ │ ├── limits │ │ ├── onerand.ndf │ │ ├── onetest.ndf │ │ ├── otherops │ │ ├── parse2.ndf │ │ ├── parserr.ndf │ │ ├── pervdefs.ndf │ │ ├── pervtsts.ndf │ │ ├── picchk.ndf │ │ ├── picdefs.ndf │ │ ├── pictops │ │ ├── quoted │ │ ├── randtest.ndf │ │ ├── rankbug.ndf │ │ ├── rbug.ndf │ │ ├── recurs │ │ ├── scope │ │ ├── stack.ndf │ │ ├── temp.ndf │ │ ├── testid.ndf │ │ ├── timeit.ndf │ │ ├── tracetest.ndf │ │ ├── trdefs.ndf │ │ ├── trloop.ndf │ │ ├── trs │ │ ├── trtests.ndf │ │ ├── uniops │ │ └── wsfull.ndf └── tools │ └── CmakeTools │ ├── Toolchain-mingw64-Win32.cmake │ └── Toolchain-mingw64-Win64.cmake ├── CONTRIBUTING.md ├── LICENSE ├── NialLogo.jpg ├── Nialroot ├── niallib │ ├── add&count.ndf │ ├── average.ndf │ ├── backtracker.ndf │ ├── benchmark.ndf │ ├── between.ndf │ ├── border.ndf │ ├── btdiffs │ ├── centertext.ndf │ ├── count_all.ndf │ ├── cuttext.ndf │ ├── defs.ndf │ ├── deleteby.ndf │ ├── diagonal.ndf │ ├── diffs.ndf │ ├── dropfront.ndf │ ├── dropindex.ndf │ ├── eigen.ndf │ ├── filelist.ndf │ ├── findby.ndf │ ├── finddefs.ndf │ ├── findpath.ndf │ ├── findstring.ndf │ ├── frequency.ndf │ ├── fuzzyeq.ndf │ ├── gcd.ndf │ ├── htmltools.ndf │ ├── insert.ndf │ ├── intersect.ndf │ ├── labeltable.ndf │ ├── median.ndf │ ├── memspaces.ndf │ ├── money.ndf │ ├── moving_average.ndf │ ├── newhost.ndf │ ├── nstreams.ndf │ ├── reflect.ndf │ ├── replace.ndf │ ├── reverse_polish.ndf │ ├── romberg.ndf │ ├── round.ndf │ ├── select.ndf │ ├── shiftpad.ndf │ ├── simpledb.ndf │ ├── simpson.ndf │ ├── solve.ndf │ ├── sprocess.ndf │ ├── stripblanks.ndf │ ├── teach.ndf │ ├── tostring.ndf │ ├── towords.ndf │ ├── unitarray.ndf │ ├── utils.ndf │ ├── wsdump.ndf │ └── xref.ndf └── tutorial │ ├── ai.dat │ ├── apl.dat │ ├── arith.dat │ ├── control.dat │ ├── data.dat │ ├── file.dat │ ├── intro.dat │ ├── lisp.dat │ ├── moretext │ ├── ops.dat │ ├── pervasive.dat │ ├── set.dat │ ├── start.doc │ ├── syntax.dat │ ├── system.dat │ ├── test.dat │ └── textfile ├── README.md ├── binaries ├── FreeBSD │ └── nial64 ├── Linux │ └── nial64 ├── OSX │ └── Basic │ │ └── nial ├── Old │ ├── Linux │ │ ├── nial │ │ ├── nial32 │ │ └── nial64 │ ├── OSX │ │ ├── nial │ │ └── nial64 │ ├── Raspbian │ │ ├── nial │ │ └── nial64 │ └── Windows │ │ ├── nial32.exe │ │ └── nial64.exe ├── Readme.md └── Windows │ ├── Old │ └── nial64.exe │ ├── README.md │ ├── Win64All.zip │ └── Win64Basic.zip ├── docs ├── Array Theory and the Design of Nial.pdf ├── Design of QNial V7.pdf ├── Manuals │ ├── Introduction │ │ ├── NialIntroduction.epub │ │ ├── NialIntroduction.html │ │ └── NialIntroduction.pdf │ ├── Language Definition │ │ ├── Styles.css │ │ ├── V6LanguageDefinition.css │ │ ├── V6LanguageDefinition.epub │ │ ├── V6LanguageDefinition.html │ │ └── V6LanguageDefinition.pdf │ └── pandoc tools │ │ ├── NialIntroduction │ │ ├── EpubHeader.md │ │ ├── HtmlHeader.md │ │ ├── NialIntroduction.epub │ │ ├── NialIntroduction.html │ │ ├── NialIntroduction.md │ │ ├── NialIntroduction.pdf │ │ ├── PdfHeader.md │ │ ├── Styles.css │ │ ├── make_epub.sh │ │ ├── make_html.sh │ │ └── make_pdf.sh │ │ ├── V6LanguageDefinition │ │ ├── EpubHeader.md │ │ ├── HtmlHeader.md │ │ ├── PdfHeader.md │ │ ├── V6LanguageDefinition.css │ │ ├── V6LanguageDefinition.html │ │ ├── V6LanguageDefinition.md │ │ ├── V6LanguageDefinition.pdf │ │ ├── cover.png │ │ ├── make_all.sh │ │ ├── make_epub.sh │ │ ├── make_html.sh │ │ └── make_pdf.sh │ │ └── V7Extensions │ │ └── V7NialExtensions.md ├── README.md ├── V7 Nial Extensions.pdf ├── V7 QNial Dictionary.html └── old NSL website files │ ├── AboutNial.html │ ├── AboutQNial.html │ ├── ArrayTheory.html │ ├── NialLecture.html │ ├── NialSaga.html │ └── small_bullet.gif ├── examples ├── Basic │ ├── data_trans.ndf │ ├── primes.ndf │ └── tables.ndf ├── Plotting │ ├── README.md │ ├── demo.ndf │ └── gplot.ndf ├── README.md ├── Shared Memory │ ├── atomic_test1.ndf │ └── errors.txt ├── Simulated Annealing │ ├── sa_queens.ndf │ └── sim_anneal.ndf └── Streams and Processes │ ├── tcp_worker_client.ndf │ ├── tcp_worker_server.ndf │ └── worker_test1.ndf └── makefile /.gitignore: -------------------------------------------------------------------------------- 1 | BuildCore/build/* 2 | BuildNial/build/* 3 | BuildNial/src/* 4 | auto.nlg 5 | nialbasic 6 | nialcore 7 | -------------------------------------------------------------------------------- /BuildCore/src/arith.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | ARITH.H: header for ARITH.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2016 6 | 7 | This contains the prototypes of the arithmetic and other functions 8 | 9 | ================================================================*/ 10 | 11 | 12 | /* sumints is used in atops.c */ 13 | extern int sumints(nialint * ptrx, nialint n, nialint * res); 14 | 15 | /* prodints is used in atops.c and trs.c */ 16 | extern int prodints(nialint * ptrx, nialint n, nialint * res); 17 | -------------------------------------------------------------------------------- /BuildCore/src/compare.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | COMPARE.H: header for COMPARE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | 13 | extern int equal(nialptr x, nialptr y); 14 | /* used by atops.c, eval_fun.c */ 15 | 16 | extern int up(nialptr x, nialptr y); 17 | /* used by atops.c, trs.c */ 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BuildCore/src/defstbl.h: -------------------------------------------------------------------------------- 1 | /*================================================================== 2 | 3 | defsndf.h 4 | 5 | required for loaddefs. 6 | 7 | ==================================================================*/ 8 | 9 | #define NOLINES 1 10 | 11 | static char *defsndf[1] = { 12 | "#NIALCORE.NDF - definitions included in nialcore build", 13 | }; 14 | -------------------------------------------------------------------------------- /BuildCore/src/faults.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | FAULTS.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains Macros to generate common faults 8 | 9 | ================================================================*/ 10 | 11 | #define Cipher makefault("?") 12 | #define Arith makefault("?A") 13 | /* need Logical not to produce a temporary 14 | #define Logical makefault("?L") 15 | */ 16 | #define Divzero makefault("?div") 17 | -------------------------------------------------------------------------------- /BuildCore/src/fileio.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER FILEIO.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | Header file for fileio.c 8 | 9 | ================================================================*/ 10 | 11 | /* Bit flags for use in nprintf */ 12 | enum { 13 | OF_NORMAL = 2, OF_MESSAGE = 4, OF_DEBUG = 8, OF_LOG = 16}; 14 | 15 | /* convienence bit flags for use in nprintf */ 16 | /* _LOG is ignored so these could be simplified */ 17 | #define OF_NORMAL_LOG (OF_NORMAL + OF_LOG) 18 | #define OF_MESSAGE_LOG (OF_MESSAGE + OF_LOG) 19 | #define OF_DEBUG_LOG (OF_DEBUG + OF_LOG) 20 | 21 | #define STDIN stdin 22 | #define STDOUT stdout 23 | #define STDERR stderr 24 | 25 | 26 | /* prototypes from fileio.c */ 27 | 28 | extern int nprintf(int flags, char *fmt,...); 29 | extern void startfilesystem(void); /* used by lib_main.c mainlp.c */ 30 | extern void closeuserfiles(void); /* used by mainlp.c */ 31 | extern void pushsysfile(FILE * pn); /* used by wsmanage.c */ 32 | extern void popsysfile(void); /* used by wsmanage.c */ 33 | extern void cleardeffiles(void); 34 | extern int readfileline(FILE * fnum, int mode); 35 | extern void readinput(void); /* used by eval.c fileio.c */ 36 | extern void show(nialptr arr); 37 | /* used by diag.c eval.c fileio.c mainlp.c wsmanage.c */ 38 | extern void writelog(char *text, int textl, int newlineflg); 39 | /* used by coreif.c fileio.c unixif.c win32if.c wsmanage.c */ 40 | extern void rl_gets (char *promptstr, char *inputline); 41 | /* used in main_stu.c to get top level input */ -------------------------------------------------------------------------------- /BuildCore/src/if.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | IF.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | selector of if libs 8 | 9 | ================================================================*/ 10 | 11 | 12 | 13 | #include "unixif.h" 14 | 15 | 16 | -------------------------------------------------------------------------------- /BuildCore/src/insel.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER INSEL.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The prototypes of internal routines in insel.c used by other modules. 8 | 9 | ================================================================*/ 10 | 11 | 12 | extern void select1(nialptr exp); /* used in eval_fun.c */ 13 | extern void insert(nialptr exp); /* used in eval_fun.c */ 14 | extern int choose(nialptr a, nialptr addrs); 15 | /* used in atops.c insel.c trs.c */ 16 | -------------------------------------------------------------------------------- /BuildCore/src/lexical.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | LEXICAL.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains macros used by several files 8 | 9 | ================================================================*/ 10 | 11 | 12 | #define NOERROR 0 13 | #define REALOVERFLOW 1 14 | #define BADREAL 0 /* should be 2 */ 15 | #define INTEGEROVERFLOW 3 16 | #define BADINTEGER 0 /* should be 4 */ 17 | #define COMPLEXOVERFLOW 5 18 | #define BADCOMPLEX 0 /* should be 6 */ 19 | 20 | #define COMMENTSYMBOL '%' 21 | #define EMPTYMARKER '\\' 22 | #define ENDOFSCANLINE '\0' /* do not change this to a newline. */ 23 | #define BLANK ' ' 24 | #define SEMICOLON ';' 25 | #define MINUS '-' 26 | #define PLUS '+' 27 | #define DOT '.' 28 | #define GRAVE '`' 29 | #define QUOTE '\'' 30 | #define ccdigit(x) ('0'+(x)) 31 | 32 | 33 | #define HASHSYMBOL '#' 34 | #define ESCAPESYMBOL '\\' 35 | #define RIGHTPAREN ')' 36 | #define EXCLAMATION '!' 37 | #define RIGHTBRACKET ']' -------------------------------------------------------------------------------- /BuildCore/src/logicops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | LOGICOPS.H: HEADER FOR LOGICOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the logical functions used 8 | by other modules. 9 | 10 | ================================================================*/ 11 | 12 | extern void b_or(void); /* used by compare.c and logicops.c */ 13 | extern void b_and(void); /* used by compare.c and logicops.c */ 14 | 15 | extern int orbools(nialptr x, nialint n); 16 | /* used by compare.c and logicops.c */ 17 | 18 | extern int andbools(nialptr x, nialint n); 19 | /* used by compare.c and logicops.c */ 20 | 21 | extern int xorbools(nialptr x, nialint n); 22 | 23 | -------------------------------------------------------------------------------- /BuildCore/src/ops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | OPS.H: header for ATOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | extern void append(nialptr x, nialptr y); 13 | /* used by absmach.c, dll.c, eval.c, parse.c */ 14 | extern void hitch(nialptr x, nialptr y); 15 | /* used by parse.c */ 16 | extern void reshape(nialptr x, nialptr y); 17 | /* used by insel.c, picture.c */ 18 | extern void pair(nialptr x, nialptr y); 19 | /* used by arith.c, dll.c, eval.c, eval_fun.c, picture.c, 20 | symtab.c, trs.c, userops.c */ 21 | extern void splitfb(nialptr z, nialptr * x, nialptr * y); 22 | /* used by arith.c, compare.c, eval_fun.c */ 23 | extern int simple(nialptr x); 24 | /* used by compare.c, eval.c, insel.c, linalg.c, picture.c, 25 | trs.c */ 26 | extern nialptr ToAddress(nialint in, nialint * shp, nialint v); 27 | /* used by trs.c */ 28 | extern nialptr generateints(nialint n); 29 | /* used by insel.c */ 30 | extern void findall(nialptr x, nialptr y); 31 | /* used by trs.c */ 32 | extern nialptr nial_raise(nialptr x, int n); 33 | /* used by picture.c */ 34 | extern void cull(nialptr arr, int diversesw); 35 | /* used by trs.c */ 36 | extern int check_sorted(nialptr x); 37 | /* trs.c */ 38 | 39 | -------------------------------------------------------------------------------- /BuildCore/src/picture.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | PICTURE.H: header for PICTURE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the macros and prototypes for the array drawing functions. 8 | 9 | ================================================================*/ 10 | 11 | extern void initformat(char *); 12 | extern void initboxchars(int usedefault); 13 | extern char stdformat[20]; 14 | 15 | 16 | #define lft 0 /* Types for justification for pictures */ 17 | #define rght 1 18 | #define centered 2 19 | 20 | 21 | 22 | 23 | /* defines the box characters on the IBMPC */ 24 | 25 | #define ibm_luc 218 26 | #define ibm_ruc 191 27 | #define ibm_llc 192 28 | #define ibm_rlc 217 29 | #define ibm_ut 194 30 | #define ibm_lt 193 31 | #define ibm_rt 180 32 | #define ibm_gt 195 33 | #define ibm_cro 197 34 | #define ibm_hor 196 35 | #define ibm_ver 179 36 | 37 | #define ibm_wluc 201 38 | #define ibm_wruc 187 39 | #define ibm_wllc 200 40 | #define ibm_wrlc 188 41 | #define ibm_whor 205 42 | #define ibm_wver 186 43 | 44 | 45 | #define def_luc '+' 46 | #define def_ruc '+' 47 | #define def_llc '+' 48 | #define def_rlc '+' 49 | #define def_ut '+' 50 | #define def_lt '+' 51 | #define def_rt '+' 52 | #define def_gt '+' 53 | #define def_cro '+' 54 | #define def_hor '-' 55 | #define def_ver '|' 56 | 57 | #define def_wluc luc 58 | #define def_wruc ruc 59 | #define def_wllc llc 60 | #define def_wrlc rlc 61 | #define def_whor hor 62 | #define def_wver ver 63 | 64 | 65 | 66 | 67 | /* functions to get and set the format string */ 68 | 69 | char *getformat(void); 70 | void setformat(char *newformat); 71 | -------------------------------------------------------------------------------- /BuildCore/src/pkgswchs.h: -------------------------------------------------------------------------------- 1 | /*================================================================== 2 | 3 | pkgswchs.h 4 | 5 | GENERATED by procpkg.ndf 6 | 7 | ==================================================================*/ 8 | 9 | #define CORE 10 | 11 | -------------------------------------------------------------------------------- /BuildCore/src/profile.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | PROFILE.H: header for PROFILE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the macros and prototypes for the profiling functions 8 | 9 | ================================================================*/ 10 | 11 | /* access Macros for callgraph node */ 12 | 13 | #define set_opid(_X_,_Y_) (_X_->opid = _Y_) 14 | #define set_parent(_X_,_Y_) (_X_->parent = _Y_) 15 | #define set_start_time(_X_,_Y_) (_X_->start_time = _Y_) 16 | #define set_end_time(_X_,_Y_) (_X_->end_time = _Y_) 17 | #define set_total_time(_X_,_Y_) (_X_->total_time = _Y_) 18 | #define set_total_calls(_X_,_Y_) (_X_->total_calls = _Y_) 19 | #define inc_total_calls(_X_) (_X_->total_calls++) 20 | #define inc_num_children(_X_) (_X_->num_children++) 21 | #define add_time(_X_) (_X_->total_time += (_X_->end_time - _X_->start_time)) 22 | 23 | /* size constants for profiler */ 24 | 25 | #define LOCLISTSIZE 20 26 | #define SYMLISTSIZE 50 27 | #define NODESIZE 5 28 | 29 | extern void profile_ops_start(nialptr entr); 30 | extern void profile_ops_stop(nialptr entr); 31 | extern void clear_profiler(void); 32 | -------------------------------------------------------------------------------- /BuildCore/src/reserved.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER RESERVED.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the reserved words. 8 | 9 | ================================================================*/ 10 | 11 | #define NORESWORDS 48 12 | 13 | #define r_IS "IS" 14 | #define r_DOT "." 15 | #define r_LPAREN "(" 16 | #define r_RPAREN ")" 17 | #define r_LBRACKET "[" 18 | #define r_OLBRACKET "<<" 19 | #define r_RBRACKET "]" 20 | #define r_ORBRACKET ">>" 21 | #define r_SEMICOLON ";" 22 | #define r_IF "IF" 23 | #define r_THEN "THEN" 24 | #define r_ELSE "ELSE" 25 | #define r_GETS "GETS" 26 | #define r_ASSIGNSYM ":=" 27 | #define r_WHILE "WHILE" 28 | #define r_DO "DO" 29 | #define r_ENDWHILE "ENDWHILE" 30 | #define r_REPEAT "REPEAT" 31 | #define r_UNTIL "UNTIL" 32 | #define r_ENDREPEAT "ENDREPEAT" 33 | #define r_FOR "FOR" 34 | #define r_WITH "WITH" 35 | #define r_ENDFOR "ENDFOR" 36 | #define r_CASE "CASE" 37 | #define r_FROM "FROM" 38 | #define r_COLON ":" 39 | #define r_BEGIN "BEGIN" 40 | #define r_END "END" 41 | #define r_ENDCASE "ENDCASE" 42 | #define r_ENDIF "ENDIF" 43 | #define r_VARIABLE "VARIABLE" 44 | #define r_EXPRESSION "EXPRESSION" 45 | #define r_OP "OP" 46 | #define r_OPERATION "OPERATION" 47 | #define r_TR "TR" 48 | #define r_TRANSFORMER "TRANSFORMER" 49 | #define r_EXTERNAL "EXTERNAL" 50 | #define r_LCURLY "{" 51 | #define r_RCURLY "}" 52 | #define r_COMMA "," 53 | #define r_LOCAL "LOCAL" 54 | #define r_NONLOCAL "NONLOCAL" 55 | #define r_PGMQUOTE "!" 56 | #define r_CAT "@" 57 | #define r_BAR "|" 58 | #define r_HASH "#" 59 | #define r_EXIT "EXIT" 60 | #define r_ELSEIF "ELSEIF" 61 | -------------------------------------------------------------------------------- /BuildCore/src/resnms.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER RESNMS.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The array of reserved words as strings 8 | 9 | ================================================================*/ 10 | 11 | 12 | #define NORESWORDS 48 13 | 14 | static char *reswords[NORESWORDS] = { 15 | "IS", 16 | ".", 17 | "(", 18 | ")", 19 | "[", 20 | "<<", 21 | "]", 22 | ">>", 23 | ";", 24 | "IF", 25 | "THEN", 26 | "ELSE", 27 | "GETS", 28 | ":=", 29 | "WHILE", 30 | "DO", 31 | "ENDWHILE", 32 | "REPEAT", 33 | "UNTIL", 34 | "ENDREPEAT", 35 | "FOR", 36 | "WITH", 37 | "ENDFOR", 38 | "CASE", 39 | "FROM", 40 | ":", 41 | "BEGIN", 42 | "END", 43 | "ENDCASE", 44 | "ENDIF", 45 | "VARIABLE", 46 | "EXPRESSION", 47 | "OP", 48 | "OPERATION", 49 | "TR", 50 | "TRANSFORMER", 51 | "EXTERNAL", 52 | "{", 53 | "}", 54 | ",", 55 | "LOCAL", 56 | "NONLOCAL", 57 | "!", 58 | "@", 59 | "|", 60 | "#", 61 | "EXIT", 62 | "ELSEIF", 63 | }; 64 | -------------------------------------------------------------------------------- /BuildCore/src/roles.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER ROLES.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the syntactic roles of variables 8 | 9 | ================================================================*/ 10 | 11 | #define Rres 0 12 | #define Rident 1 13 | #define Rconst 2 14 | #define Roptn 3 15 | #define Rtrans 4 16 | #define Rvar 5 17 | #define Rexpr 6 18 | -------------------------------------------------------------------------------- /BuildCore/src/scan.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SCAN.H: header for SCAN.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains macros and prototypes of the scan functions 8 | 9 | ================================================================*/ 10 | 11 | void initscan(void); 12 | 13 | #define Upper(x) (islower(x) ? toupper(x) : x) 14 | #define Lower(x) (isupper(x) ? tolower(x) : x) 15 | -------------------------------------------------------------------------------- /BuildCore/src/sorts.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SORTS.H: header for SORTS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | 13 | extern void iqsort(void); 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BuildCore/src/switches.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER SWITCHES.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-20016 6 | 7 | This file contains switch settings for building QNial. 8 | It assumes the build is for a Unix based operating system e.g (OSX or Linux) 9 | and that the target architecture is an Intel like chip that supports 32 and 64 bit words. 10 | 11 | ================================================================*/ 12 | 13 | 14 | #ifndef _SWITCHES_H_ 15 | #define _SWITCHES_H_ 16 | 17 | /* 18 | This file controls what code gets included or excluded when 19 | the code of Q'Nial is processed. 20 | */ 21 | 22 | 23 | /* compiler command lines can set the following switches to remove 24 | some capabilities and set up variant versions. 25 | 26 | DEBUG - removes features that interfere with debugging. 27 | Also includes substantial debugging checks. 28 | LINUX or OSX - used in the code to handle minor differences or capabilities 29 | 30 | */ 31 | 32 | #define SYSTEM 33 | #define DIRECTIO 34 | #define V6AT 35 | #define COMMAND 36 | #define TIMEHOOK 37 | #define DIRECTIO 38 | #define PROFILE 39 | 40 | #include "pkgswchs.h" /* load the defines constructed by Pkgblder */ 41 | 42 | /* switches set for LINUX or OSX builds. */ 43 | 44 | /* operating system capabilities */ 45 | 46 | #define ABORTSIGNAL 47 | #define JOBCONTROL 48 | #define FP_EXCEPTION_FLAG 49 | #define USER_BREAK_FLAG 50 | 51 | /* define these four switches below to trade speed for space */ 52 | 53 | #define FETCHARRAYMACRO 54 | #define STOREARRAYMACRO 55 | #define FREEUPMACRO 56 | #define STACKMACROS 57 | 58 | /* they should always be undefined if a DEBUG build is being made */ 59 | 60 | #ifdef DEBUG 61 | #undef FETCHARRAYMACRO 62 | #undef STOREARRAYMACRO 63 | #undef FREEUPMACRO 64 | #undef STACKMACROS 65 | #endif 66 | 67 | /* the following includes set up types and constants appropriate for 32 or 64 bits systems */ 68 | 69 | #include "nialtypes.h" 70 | #include "nialconsts.h" 71 | 72 | #endif /* _SWITCHES_H_ */ 73 | -------------------------------------------------------------------------------- /BuildCore/src/systemops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SYSTEMOPS.H: header for SYSTEMOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the host function. 8 | 9 | ================================================================*/ 10 | 11 | 12 | 13 | extern void ihost(void); -------------------------------------------------------------------------------- /BuildCore/src/token.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER TOKEN.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the token properties used by scan.c and parse.c 8 | 9 | ================================================================*/ 10 | 11 | /* Token Properties */ 12 | #define delimprop 1 13 | #define identprop 2 14 | #define commentprop 3 15 | #define eolprop 4 /* accept in parse.c expects these to */ 16 | #define indentprop 5 /* be the last three properties */ 17 | #define exdentprop 6 18 | 19 | #define constprop 10 20 | #define constphprop 15 /* because sPhrase is 5 */ 21 | 22 | /* constant tokens are 10 + state value in scan */ 23 | 24 | #define indentamt 3 /* used to control indenting in descan */ 25 | #define commentamt 2 /* used to control comment indenting in descan */ 26 | 27 | void initdeparse(void); 28 | -------------------------------------------------------------------------------- /BuildCore/src/trig.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | TRIG.H: header for TRIG.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the trigonometric functions 8 | 9 | ================================================================*/ 10 | 11 | /* constants: define to appropriate precision 12 | (here are enough digits for any machine) 13 | #define PI 3.141592653589793238462643 14 | #define PIBYTWO 1.570796326794896619231322 15 | */ 16 | 17 | #ifndef PI 18 | #define PI 3.1415926535897932 19 | #endif 20 | 21 | #define PIBYTWO 1.57079632679489662 22 | 23 | #ifdef SCIENTIFIC 24 | 25 | 26 | extern void isin(void); 27 | extern void icos(void); 28 | extern void itan(void); 29 | extern void isinh(void); 30 | extern void icosh(void); 31 | extern void itanh(void); 32 | extern void iarcsin(void); 33 | extern void iarctan(void); 34 | extern void iarccos(void); 35 | extern void iexp(void); 36 | extern void iln(void); 37 | extern void ilog(void); 38 | extern void isqrt(void); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /BuildCore/src/trs.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | TRS.H: header for TRS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the transformer second order functions 8 | 9 | ================================================================*/ 10 | 11 | 12 | extern void int_each(void (*f) (void), nialptr x); 13 | extern void real_each(double (*f) (double), nialptr x); 14 | extern void int_eachboth(void (*f) (void), nialptr x, nialptr y); 15 | void sort(nialptr f, nialptr x, int gradesw); 16 | -------------------------------------------------------------------------------- /BuildCore/src/utils.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | UTILS.H: header for UTILS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of various utility functions 8 | 9 | ================================================================*/ 10 | 11 | extern nialptr int_to_real(nialptr x); 12 | extern nialptr bool_to_real(nialptr x); 13 | extern nialptr arithconvert(nialptr x, int *newk); 14 | extern nialptr to_real(nialptr x); 15 | extern int convert(nialptr * x, int *kx, int k); 16 | extern nialptr testfaults(nialptr x, nialptr stdfault); 17 | extern nialptr testbinfaults(nialptr x, nialptr stdfault, int divflag); 18 | extern int tkncompare(nialptr x, nialptr y); 19 | extern nialptr boolstoints(nialptr x); 20 | extern void cnvtup(char *str); 21 | extern nialint ngetname(nialptr x, char *value); 22 | extern nialptr getuppername(void); 23 | extern char *slower(char *in_s); 24 | -------------------------------------------------------------------------------- /BuildCore/src/version.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | VERSION.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This defines macros to set up the banner line for various versions. 8 | 9 | ================================================================*/ 10 | 11 | #ifndef _VERSION_H_ 12 | #define _VERSION_H_ 13 | 14 | /* The banner information is constructed from: 15 | special 16 | nialversion 17 | machine 18 | wordsize 19 | opsys 20 | debugstatus 21 | date 22 | */ 23 | 24 | /* 25 | The internal variable systemname is used to set the Nial 26 | expression System that is available for programs to test which 27 | version is being used. Only one of these cases is chosen. 28 | */ 29 | 30 | #ifndef __DATE__ 31 | 32 | /* compiler does not provide date functionality, set date directly 33 | below and remove the words (Possibly incorrect)*/ 34 | 35 | #define __DATE__ "Feb 07, 2007 (Possibly incorrect)" 36 | 37 | #endif 38 | 39 | /* Version 6.3 is the public domain version released as open source */ 40 | 41 | #define nialversion " 7.0" 42 | 43 | 44 | /* 45 | The internal variable systemname is used to set the Nial 46 | expression System that is available for programs to test which 47 | version is being used. Only one of these cases is chosen. 48 | */ 49 | 50 | 51 | 52 | #ifdef LINUX 53 | #define opsys " Linux" 54 | #endif 55 | 56 | #ifdef FREEBSD 57 | #define opsys "FreeBSD" 58 | #endif 59 | 60 | #ifdef OSX 61 | #define opsys " Mac OSX" 62 | #endif 63 | 64 | #ifdef WINNIAL 65 | #define opsys "Windows" 66 | #endif 67 | 68 | 69 | /* inducate word size */ 70 | 71 | #ifdef INTS32 72 | #define wordsize " 32bit" 73 | #elif INTS64 74 | #define wordsize " 64bit" 75 | #else 76 | #error set wordsize for this configuration 77 | #endif 78 | 79 | #ifdef DEBUG 80 | #define debugstatus " DEBUG" 81 | #else 82 | #define debugstatus "" 83 | #endif 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /BuildCore/src/wsmanage.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | WSMANAGE.H: header for WSMANAGE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the workspace load and save functions 8 | 9 | ================================================================*/ 10 | 11 | /* Flags used by doloadsave */ 12 | 13 | 14 | enum { 15 | FORCE_EXTENSION = 1, NOFORCE_EXTENSION = 0 16 | }; 17 | 18 | extern void wsdump(FILE * f1); 19 | extern void wsload(FILE * f1); 20 | extern void check_ext(char *str, char *ext,int force); 21 | extern int loaddefs(int fromfile, char *fname, int mode); 22 | 23 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/Cmakemiddle: -------------------------------------------------------------------------------- 1 | 2 | ) 3 | 4 | 5 | # ---------------- Standard Libraries -------------------- 6 | 7 | # Linux specific settings 8 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 9 | set (NIAL_LIBS m util dl rt) 10 | endif (CMAKE_SYSTEM_NAME MATCHES "Linux") 11 | 12 | # FreeBSD specific settings 13 | if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 14 | set (NIAL_LIBS m util dl) 15 | endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") 16 | 17 | # Cygwin specific settings 18 | if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") 19 | set (NIAL_LIBS m util dl rt) 20 | endif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") 21 | 22 | # OSX specific flags 23 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 24 | set (NIAL_LIBS m util dl) 25 | endif (CMAKE_SYSTEM_NAME MATCHES "Darwin") 26 | 27 | # Windows specific flags 28 | if (CMAKE_SYSTEM_NAME MATCHES "Windows") 29 | set (NIAL_LIBS "") 30 | endif (CMAKE_SYSTEM_NAME MATCHES "Windows") 31 | 32 | # ---------------- Extension Options --------------------- 33 | 34 | # Compilation options for 32 bit system 35 | if (USE_INTS32) 36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DINTS32") 37 | endif (USE_INTS32) 38 | 39 | # Compilation options for 64 bit system 40 | if (USE_INTS64) 41 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DINTS64") 42 | endif (USE_INTS64) 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/Cmaketrailer: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ---------------- Nial Executable ------------------------- 4 | 5 | 6 | add_executable(nial ${NIAL_SRCS}) 7 | target_link_libraries(nial ${NIAL_LIBS}) 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/DEBUGINCLUDED/DEBUGINCLUDED_src/diag.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER DIAG.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the debugging operations. 8 | 9 | ================================================================*/ 10 | 11 | extern char *memchk(void); 12 | extern void wa(nialptr x); 13 | extern void wb(nialptr x); 14 | extern void printarray(nialptr x); 15 | extern void showfl(void); 16 | extern void chkfl(void); 17 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/DEBUGINCLUDED/debugincluded.nh: -------------------------------------------------------------------------------- 1 | DEBUG U wa iwa 2 | DEBUG U wan iwan 3 | DEBUG U wbn iwbn 4 | DEBUG U dumpatomtbl idumpatomtbl 5 | DEBUG E usedspace iusedspace 6 | DEBUG E showfl ishowfl 7 | DEBUG E dumpstack idumpstack 8 | DEBUG U dumpheap idumpheap 9 | DEBUG U setdebugmessages isetdebugmessages -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/DEBUGINCLUDED/debugincluded_cmake: -------------------------------------------------------------------------------- 1 | option(USE_DEBUG "Build a DEBUG system" OFF) 2 | 3 | # Compilation options for DEBUG system 4 | if (USE_DEBUG) 5 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG") 6 | endif (USE_DEBUG) -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/MEMSPACES/MEMSPACES_src/mcore.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Primitives for synchronisation across multiple processes 3 | */ 4 | 5 | 6 | 7 | #ifdef LINUX 8 | #define AtomicCompareAndSwap(ptr, oldval, newval) \ 9 | __sync_bool_compare_and_swap(ptr, oldval, newval) 10 | 11 | #define AtomicIncrement(ptr) \ 12 | __sync_add_and_fetch(ptr,(nialint)1) 13 | 14 | #define AtomicDecrement(ptr) \ 15 | __sync_sub_and_fetch(ptr,(nialint)1) 16 | 17 | #endif 18 | 19 | #ifdef OSX 20 | #include 21 | 22 | #ifdef INTS32 23 | #define AtomicCompareAndSwap(ptr, oldval, newval) \ 24 | OSAtomicCompareAndSwap32Barrier((int32_t)oldval,(int32_t)newval,(int32_t*)ptr) 25 | 26 | #define AtomicIncrement(ptr,val) \ 27 | OSAtomicIncrement32Barrier((int32_t*)ptr) 28 | 29 | #define AtomicDecrement(ptr,val) \ 30 | OSAtomicDecrement32Barrier((int32_t*)ptr) 31 | 32 | #endif 33 | #ifdef INTS64 34 | #define AtomicCompareAndSwap(ptr,oldval,newval) \ 35 | OSAtomicCompareAndSwap64Barrier((int64_t)oldval,(int64_t)newval,(int64_t*)ptr) 36 | 37 | #define AtomicIncrement(ptr,val) \ 38 | OSAtomicIncrement64Barrier((int64_t*)ptr) 39 | 40 | #define AtomicDecrement(ptr,val) \ 41 | OSAtomicDecrement64Barrier((int64_t*)ptr) 42 | 43 | #endif 44 | #endif 45 | 46 | 47 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/MEMSPACES/MEMSPACES_src/memspaces.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Alternative macros for 3 | * 4 | */ 5 | 6 | #ifdef OSX 7 | /* MAP_ANONYMOUS is undefined for OSX */ 8 | #ifndef MAP_ANONYNOUS 9 | #define MAP_ANONYMOUS 0 10 | #endif 11 | #endif 12 | 13 | 14 | /** 15 | * Types of data 16 | */ 17 | #define MSP_INTTYPE 1 18 | #define MSP_BOOLTYPE 2 19 | #define MSP_CHARTYPE 3 20 | #define MSP_REALTYPE 4 21 | 22 | 23 | /** 24 | * Different types of memory spaces 25 | */ 26 | #define MSP_LOCAL 0 27 | #define MSP_SHARED 1 28 | 29 | 30 | 31 | /** 32 | * Memory space definition 33 | */ 34 | typedef struct { 35 | int mtype; /* type of memory space */ 36 | void *handle; /* OS specific handle */ 37 | nialint *mbase; /* base address for memory */ 38 | nialint msize; /* No of bytes of memory */ 39 | } MemSpace, *MemSpacePtr; 40 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/MEMSPACES/memspaces.nh: -------------------------------------------------------------------------------- 1 | MEMSPACES U msp_put_raw imsp_put_raw 2 | MEMSPACES U msp_get_raw imsp_get_raw 3 | MEMSPACES U msp_shm_open imsp_shm_open 4 | MEMSPACES U msp_shm_unlink imsp_shm_unlink 5 | MEMSPACES U msp_map_local imsp_map_local 6 | MEMSPACES U msp_map_fd imsp_map_fd 7 | MEMSPACES U msp_msize imsp_msize 8 | MEMSPACES U msp_atomic_cas imsp_cas 9 | MEMSPACES U msp_sysconfig imsp_sysconfig 10 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/MEMSPACES/memspaces_cmake: -------------------------------------------------------------------------------- 1 | if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 2 | set (NIAL_LIBS ${NIAL_LIBS} rt) 3 | endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 4 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NCOMPLEX/ncomplex.nh: -------------------------------------------------------------------------------- 1 | NCOMPLEX U _iscomplex iis_complex 2 | NCOMPLEX U _cprod ic_prod 3 | NCOMPLEX U _cdiv ic_div 4 | NCOMPLEX U _csum ic_sum 5 | NCOMPLEX U _csub ic_sub 6 | NCOMPLEX U _cexp ic_exp 7 | NCOMPLEX U _csplit isplit_complex 8 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NDYNLOAD/ndynload.nh: -------------------------------------------------------------------------------- 1 | NDYNLOAD U ndlLoad indlLoad 2 | NDYNLOAD U ndlError indlError 3 | NDYNLOAD U ndlGetsym indlGetsym 4 | NDYNLOAD U ndlClose indlClose 5 | NDYNLOAD U ndlCall indlCall 6 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NFILES/nfiles.nh: -------------------------------------------------------------------------------- 1 | NFILES U mkdir imkdir 2 | NFILES U rmdir irmdir 3 | NFILES U rename irename 4 | NFILES U fullpathname ifullpathname 5 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NIALDSP/nialdsp.nh: -------------------------------------------------------------------------------- 1 | NIALDSP U _dspfilter idsp_filter 2 | NIALDSP U _dspfilter2 idsp_filter2 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NIAL_FFTW/README.md: -------------------------------------------------------------------------------- 1 | This directory contains the extension for the FFTW (Fastest Fourier 2 | Transform in the West) library which can be found at *fftw.org*. 3 | 4 | The extension relies on header files and libraries that you can download from 5 | the *fftw.org* site or from your operating systems package manager in some 6 | cases. You can also download the source code to build the library. 7 | 8 | If you have placed the headers and libraries in some place not directly 9 | accessible to your compiler then you will need to set the *NIAL_FFTW_INCLUDE* 10 | and *NIAL_FFTW_LIB* environment variables before running CMake. 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NIAL_FFTW/nial_fftw.nh: -------------------------------------------------------------------------------- 1 | NIAL_FFTW U _fft_forward ifft_forward 2 | NIAL_FFTW U _fft_backward ifft_backward 3 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NIAL_FFTW/nial_fftw_cmake: -------------------------------------------------------------------------------- 1 | include_directories($ENV{NIAL_FFTW_INCLUDE}) 2 | link_directories($ENV{NIAL_FFTW_LIB}) 3 | if (CMAKE_SYSTEM_NAME MATCHES "Linux") 4 | set(NIAL_LIBS ${NIAL_LIBS} fftw3) 5 | endif (CMAKE_SYSTEM_NAME MATCHES "Linux") 6 | if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") 7 | set(NIAL_LIBS ${NIAL_LIBS} fftw3) 8 | endif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN") 9 | if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 10 | set(NIAL_LIBS ${NIAL_LIBS} fftw3) 11 | endif (CMAKE_SYSTEM_NAME MATCHES "Darwin") 12 | if (CMAKE_SYSTEM_NAME MATCHES "Windows") 13 | set(NIAL_LIBS ${NIAL_LIBS} fftw3-3) 14 | endif (CMAKE_SYSTEM_NAME MATCHES "Windows") 15 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NREFS/nrefs.ndf: -------------------------------------------------------------------------------- 1 | 2 | # ================================================ 3 | # 4 | # Additional refcell code in Nial 5 | # 6 | # =============================================== 7 | 8 | # Allow a function to update the values of a cell 9 | # 10 | # _refupdate Fn Cell Data 11 | # 12 | 13 | _refupdate is transformer fn operation Cell Data { 14 | Cell _refset ((_refget Cell) fn Data) 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NREFS/nrefs.nh: -------------------------------------------------------------------------------- 1 | NREFLECTION U _newref inewref 2 | NREFLECTION U _refset irefset 3 | NREFLECTION U _refget irefget 4 | 5 | 6 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NSFML_AUDIO/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an extension to use the Audio component of 2 | SFML (the Simple Fast Multimedia Library). 3 | 4 | To include this extension you will need to download the C headers and libraries 5 | for CSFML, the C interface to SFML, for your particular machine. 6 | 7 | Once you have done that set the environment variables *NIAL_SFML_INCLUDE* and 8 | *NIAL_SFML_LIB* to the appropriate directories before running CMake. 9 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NSFML_AUDIO/nsfml_audio.nh: -------------------------------------------------------------------------------- 1 | NSFML_AUDIO U nsfml_music_from_file insfml_music_from_file 2 | NSFML_AUDIO U nsfml_play insfml_play 3 | NSFML_AUDIO U nsfml_pause insfml_pause 4 | NSFML_AUDIO U nsfml_stop insfml_stop 5 | NSFML_AUDIO U nsfml_destroy insfml_destroy 6 | NSFML_AUDIO U nsfml_soundbuffer_from_file insfml_soundbuffer_from_file 7 | NSFML_AUDIO U nsfml_soundbuffer_to_file insfml_soundbuffer_to_file 8 | NSFML_AUDIO U nsfml_soundbuffer_from_memory insfml_soundbuffer_from_memory 9 | NSFML_AUDIO U nsfml_soundbuffer_from_samples insfml_soundbuffer_from_samples 10 | NSFML_AUDIO U nsfml_create_sound insfml_create_sound 11 | NSFML_AUDIO U nsfml_sound_set_buffer insfml_sound_set_buffer 12 | NSFML_AUDIO U nsfml_get_channel_count insfml_get_channel_count 13 | NSFML_AUDIO U nsfml_get_sample_count insfml_get_sample_count 14 | NSFML_AUDIO U nsfml_get_sample_rate insfml_get_sample_rate 15 | NSFML_AUDIO U nsfml_get_samples insfml_get_samples 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NSFML_AUDIO/nsfml_audio_cmake: -------------------------------------------------------------------------------- 1 | include_directories($ENV{NIAL_SFML_INCLUDE}) 2 | link_directories($ENV{NIAL_SFML_LIB}) 3 | set(NIAL_LIBS ${NIAL_LIBS} csfml-audio) 4 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/NTABLES/ntables.nh: -------------------------------------------------------------------------------- 1 | NTABLES U _tcreate iht_create 2 | NTABLES U _tset iht_set 3 | NTABLES U _tget iht_get 4 | NTABLES U istable iis_ht_table 5 | NTABLES U tsetm iht_setmeta 6 | NTABLES U tgetm iht_getmeta 7 | NTABLES U _tdel iht_delete 8 | NTABLES U _getkeys iht_getkeys -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/PROCESS/process.nh: -------------------------------------------------------------------------------- 1 | PROCESS_CONTROL E process_fork iprocess_fork 2 | PROCESS_CONTROL U authenticate iauthenticate 3 | PROCESS_CONTROL U crypt icrypt 4 | PROCESS_CONTROL E getpid igetpid 5 | PROCESS_CONTROL E getgid igetgid 6 | PROCESS_CONTROL U setpgid isetpgid 7 | PROCESS_CONTROL U killpg ikillpg -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/QSORT/QSORT_src/sorts.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SORTS.H: header for SORTS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | 13 | extern void iqsort(void); 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/QSORT/qsort.nh: -------------------------------------------------------------------------------- 1 | QSORT U qsort iqsort 2 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/REGEXP/regexp.nh: -------------------------------------------------------------------------------- 1 | REGEXP U re_compile iregexp_c 2 | REGEXP U re_test iregexp_t 3 | REGEXP U re_match iregexp_m 4 | REGEXP U re_extract iregexp_extract 5 | REGEXP U re_split iregexp_split 6 | REGEXP U re_splice iregexp_splice -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/SOCKETS/sockets.nh: -------------------------------------------------------------------------------- 1 | SOCKETS U socket_listen isocket_listen 2 | SOCKETS U socket_accept isocket_accept 3 | SOCKETS U socket_close isocket_close 4 | SOCKETS U socket_receive isocket_receive 5 | SOCKETS U socket_peek isocket_peek 6 | SOCKETS U socket_send isocket_send 7 | SOCKETS U socket_connect isocket_connect 8 | SOCKETS U socket_bind isocket_bind 9 | SOCKETS U socket_nodelay isocket_nodelay -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/SOCKETS/sockets_cmake: -------------------------------------------------------------------------------- 1 | if (CMAKE_SYSTEM_NAME MATCHES "Windows") 2 | set(NIAL_LIBS ${NIAL_LIBS} ws2_32) 3 | endif (CMAKE_SYSTEM_NAME MATCHES "Windows") 4 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/SPROCESS/sprocess.nh: -------------------------------------------------------------------------------- 1 | SPROCESS U spawn_shell ispawn_shell 2 | SPROCESS U spawn_cmd ispawn_cmd 3 | SPROCESS U spawn_child ispawn_child 4 | SPROCESS U interrupt_child iinterrupt_child 5 | SPROCESS U child_reader ichild_reader 6 | SPROCESS U child_writer ichild_writer 7 | SPROCESS U child_status ichild_status 8 | SPROCESS U _sys_exit isys_exit 9 | SPROCESS U nio_open inio_openStream 10 | SPROCESS U nio_close inio_closeStream 11 | SPROCESS U nio_write_stream inio_write_stream 12 | SPROCESS U nio_read_stream inio_read_stream 13 | SPROCESS U nio_count inio_count 14 | SPROCESS U nio_status inio_status 15 | SPROCESS U nio_write inio_write 16 | SPROCESS U nio_read inio_read 17 | SPROCESS U nio_writeln inio_writeln 18 | SPROCESS U nio_readln inio_readln 19 | SPROCESS U nio_newpipe inio_newpipe 20 | SPROCESS U nio_socketpair inio_socketpair 21 | SPROCESS U nio_block_array inio_block_array 22 | SPROCESS U nio_unblock_array inio_unblock_array 23 | SPROCESS U nio_set_nonblock inio_set_nonblock 24 | SPROCESS U nio_get_fd inio_get_fd 25 | SPROCESS U nio_poll inio_poll 26 | SPROCESS U nio_is_readable inio_is_readable 27 | SPROCESS U nio_is_writeable inio_is_writeable 28 | SPROCESS U nano_time inano_time 29 | SPROCESS U nano_sleep inano_sleep -------------------------------------------------------------------------------- /BuildNial/pkgblder/all_features/WINPROCESS/winprocess.nh: -------------------------------------------------------------------------------- 1 | WINPROCESS U proc_open irun_child 2 | WINPROCESS U proc_read ichild_read 3 | WINPROCESS U proc_write ichild_write 4 | WINPROCESS U proc_close ichild_close 5 | WINPROCESS U proc_running ichild_running 6 | WINPROCESS U proc_count ichild_count -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/AllFeatures.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | 5 | REGEXP 6 | SOCKETS 7 | SPROCESS 8 | NTABLES 9 | MEMSPACES 10 | NCOMPLEX 11 | QSORT 12 | NFILES 13 | NDYNLOAD 14 | 15 | NSFML_AUDIO 16 | NIALDSP 17 | #WINPROCESS 18 | NIAL_FFTW 19 | 20 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/FreeBSDCore.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | 5 | REGEXP 6 | SOCKETS 7 | SPROCESS 8 | NTABLES 9 | NCOMPLEX 10 | NFILES 11 | 12 | #NSFML_AUDIO 13 | #NIALDSP 14 | #WINPROCESS 15 | #NIAL_FFTW 16 | 17 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/LinuxCore.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | 5 | REGEXP 6 | SOCKETS 7 | SPROCESS 8 | NTABLES 9 | MEMSPACES 10 | NCOMPLEX 11 | NFILES 12 | NDYNLOAD 13 | NREFS 14 | 15 | #NSFML_AUDIO 16 | #NIALDSP 17 | #WINPROCESS 18 | #NIAL_FFTW 19 | 20 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/QNial7.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | 5 | REGEXP 6 | SOCKETS 7 | #SPROCESS 8 | NTABLES 9 | #MEMSPACES 10 | NCOMPLEX 11 | QSORT 12 | NFILES 13 | #NDYNLOAD 14 | #NSFML_AUDIO 15 | #NIALDSP 16 | #WINPROCESS 17 | #NIAL_FFTW 18 | 19 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/README.md: -------------------------------------------------------------------------------- 1 | # Predefined Nial Packages 2 | 3 | This directory contains a set of predefined packages for configuring 4 | a Nial executable. 5 | 6 | Packages prefixed by *Win* contain extensions specific to Windows and 7 | ommit extensions that will not build on Windows. 8 | 9 | All other packages are suitable for Linux, OSX, Raspbian and Cygwin. 10 | 11 | None of these package definitions include extensions that rely on 12 | external 3rd party libraries. 13 | 14 | Such packages require that you download or build the 3rd party code first 15 | before building Nial. The required libraries are mentioned in the README 16 | for the particular package. 17 | 18 | Once you are familiar with building and extending Nial you can create 19 | your own package definition. 20 | 21 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/WinAllFeatures.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | 5 | #REGEXP 6 | SOCKETS 7 | #SPROCESS 8 | NTABLES 9 | #MEMSPACES 10 | NCOMPLEX 11 | NFILES 12 | #NDYNLOAD 13 | NSFML_AUDIO 14 | NIALDSP 15 | WINPROCESS 16 | NIAL_FFTW 17 | 18 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/WinQNial7.txt: -------------------------------------------------------------------------------- 1 | extendnial 2 | 3 | #PROCESS 4 | #REGEXP 5 | SOCKETS 6 | NTABLES 7 | #MEMSPACES 8 | NCOMPLEX 9 | NFILES 10 | #NDYNLOAD 11 | #NSFML_AUDIO 12 | #NIALDSP 13 | WINPROCESS 14 | #NIAL_FFTW 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/basic_debug.txt: -------------------------------------------------------------------------------- 1 | debug basic version 2 | 3 | DEBUGINCLUDED -------------------------------------------------------------------------------- /BuildNial/pkgblder/packages/basic_nial.txt: -------------------------------------------------------------------------------- 1 | basic Nial version 2 | 3 | # builds "nial" with no features added -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/arith.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | ARITH.H: header for ARITH.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2016 6 | 7 | This contains the prototypes of the arithmetic and other functions 8 | 9 | ================================================================*/ 10 | 11 | 12 | /* sumints is used in atops.c */ 13 | extern int sumints(nialint * ptrx, nialint n, nialint * res); 14 | 15 | /* prodints is used in atops.c and trs.c */ 16 | extern int prodints(nialint * ptrx, nialint n, nialint * res); 17 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/compare.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | COMPARE.H: header for COMPARE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | 13 | extern int equal(nialptr x, nialptr y); 14 | /* used by atops.c, eval_fun.c */ 15 | 16 | extern int up(nialptr x, nialptr y); 17 | /* used by atops.c, trs.c */ 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/diag.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER DIAG.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the debugging operations. 8 | 9 | ================================================================*/ 10 | 11 | extern char *memchk(void); 12 | extern void wa(nialptr x); 13 | extern void wb(nialptr x); 14 | extern void printarray(nialptr x); 15 | extern void showfl(void); 16 | extern void chkfl(void); 17 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/faults.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | FAULTS.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains Macros to generate common faults 8 | 9 | ================================================================*/ 10 | 11 | #define Cipher makefault("?") 12 | #define Arith makefault("?A") 13 | /* need Logical not to produce a temporary 14 | #define Logical makefault("?L") 15 | */ 16 | #define Divzero makefault("?div") 17 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/fileio.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER FILEIO.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | Header file for fileio.c 8 | 9 | ================================================================*/ 10 | 11 | /* Bit flags for use in nprintf */ 12 | enum { 13 | OF_NORMAL = 2, OF_MESSAGE = 4, OF_DEBUG = 8, OF_LOG = 16}; 14 | 15 | /* convienence bit flags for use in nprintf */ 16 | /* _LOG is ignored so these could be simplified */ 17 | #define OF_NORMAL_LOG (OF_NORMAL + OF_LOG) 18 | #define OF_MESSAGE_LOG (OF_MESSAGE + OF_LOG) 19 | #define OF_DEBUG_LOG (OF_DEBUG + OF_LOG) 20 | 21 | #define STDIN stdin 22 | #define STDOUT stdout 23 | #define STDERR stderr 24 | 25 | 26 | /* prototypes from fileio.c */ 27 | 28 | extern int nprintf(int flags, char *fmt,...); 29 | extern void startfilesystem(void); /* used by lib_main.c mainlp.c */ 30 | extern void closeuserfiles(void); /* used by mainlp.c */ 31 | extern void pushsysfile(FILE * pn); /* used by wsmanage.c */ 32 | extern void popsysfile(void); /* used by wsmanage.c */ 33 | extern void cleardeffiles(void); 34 | extern int readfileline(FILE * fnum, int mode); 35 | extern void readinput(void); /* used by eval.c fileio.c */ 36 | extern void show(nialptr arr); 37 | /* used by diag.c eval.c fileio.c mainlp.c wsmanage.c */ 38 | extern void writelog(char *text, int textl, int newlineflg); 39 | /* used by coreif.c fileio.c unixif.c win32if.c wsmanage.c */ 40 | extern void rl_gets (char *promptstr, char *inputline); 41 | /* used in main_stu.c to get top level input */ -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/if.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | IF.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | selector of if libs 8 | 9 | ================================================================*/ 10 | 11 | 12 | 13 | #include "unixif.h" 14 | 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/insel.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER INSEL.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The prototypes of internal routines in insel.c used by other modules. 8 | 9 | ================================================================*/ 10 | 11 | 12 | extern void select1(nialptr exp); /* used in eval_fun.c */ 13 | extern void insert(nialptr exp); /* used in eval_fun.c */ 14 | extern int choose(nialptr a, nialptr addrs); 15 | /* used in atops.c insel.c trs.c */ 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/lexical.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | LEXICAL.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains macros used by several files 8 | 9 | ================================================================*/ 10 | 11 | 12 | #define NOERROR 0 13 | #define REALOVERFLOW 1 14 | #define BADREAL 0 /* should be 2 */ 15 | #define INTEGEROVERFLOW 3 16 | #define BADINTEGER 0 /* should be 4 */ 17 | #define COMPLEXOVERFLOW 5 18 | #define BADCOMPLEX 0 /* should be 6 */ 19 | 20 | #define COMMENTSYMBOL '%' 21 | #define EMPTYMARKER '\\' 22 | #define ENDOFSCANLINE '\0' /* do not change this to a newline. */ 23 | #define BLANK ' ' 24 | #define SEMICOLON ';' 25 | #define MINUS '-' 26 | #define PLUS '+' 27 | #define DOT '.' 28 | #define GRAVE '`' 29 | #define QUOTE '\'' 30 | #define ccdigit(x) ('0'+(x)) 31 | 32 | 33 | #define HASHSYMBOL '#' 34 | #define ESCAPESYMBOL '\\' 35 | #define RIGHTPAREN ')' 36 | #define EXCLAMATION '!' 37 | #define RIGHTBRACKET ']' -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/logicops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | LOGICOPS.H: HEADER FOR LOGICOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the logical functions used 8 | by other modules. 9 | 10 | ================================================================*/ 11 | 12 | extern void b_or(void); /* used by compare.c and logicops.c */ 13 | extern void b_and(void); /* used by compare.c and logicops.c */ 14 | 15 | extern int orbools(nialptr x, nialint n); 16 | /* used by compare.c and logicops.c */ 17 | 18 | extern int andbools(nialptr x, nialint n); 19 | /* used by compare.c and logicops.c */ 20 | 21 | extern int xorbools(nialptr x, nialint n); 22 | 23 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/ops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | OPS.H: header for ATOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | extern void append(nialptr x, nialptr y); 13 | /* used by absmach.c, dll.c, eval.c, parse.c */ 14 | extern void hitch(nialptr x, nialptr y); 15 | /* used by parse.c */ 16 | extern void reshape(nialptr x, nialptr y); 17 | /* used by insel.c, picture.c */ 18 | extern void pair(nialptr x, nialptr y); 19 | /* used by arith.c, dll.c, eval.c, eval_fun.c, picture.c, 20 | symtab.c, trs.c, userops.c */ 21 | extern void splitfb(nialptr z, nialptr * x, nialptr * y); 22 | /* used by arith.c, compare.c, eval_fun.c */ 23 | extern int simple(nialptr x); 24 | /* used by compare.c, eval.c, insel.c, linalg.c, picture.c, 25 | trs.c */ 26 | extern nialptr ToAddress(nialint in, nialint * shp, nialint v); 27 | /* used by trs.c */ 28 | extern nialptr generateints(nialint n); 29 | /* used by insel.c */ 30 | extern void findall(nialptr x, nialptr y); 31 | /* used by trs.c */ 32 | extern nialptr nial_raise(nialptr x, int n); 33 | /* used by picture.c */ 34 | extern void cull(nialptr arr, int diversesw); 35 | /* used by trs.c */ 36 | extern int check_sorted(nialptr x); 37 | /* trs.c */ 38 | 39 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/picture.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | PICTURE.H: header for PICTURE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the macros and prototypes for the array drawing functions. 8 | 9 | ================================================================*/ 10 | 11 | extern void initformat(char *); 12 | extern void initboxchars(int usedefault); 13 | extern char stdformat[20]; 14 | 15 | 16 | #define lft 0 /* Types for justification for pictures */ 17 | #define rght 1 18 | #define centered 2 19 | 20 | 21 | 22 | 23 | /* defines the box characters on the IBMPC */ 24 | 25 | #define ibm_luc 218 26 | #define ibm_ruc 191 27 | #define ibm_llc 192 28 | #define ibm_rlc 217 29 | #define ibm_ut 194 30 | #define ibm_lt 193 31 | #define ibm_rt 180 32 | #define ibm_gt 195 33 | #define ibm_cro 197 34 | #define ibm_hor 196 35 | #define ibm_ver 179 36 | 37 | #define ibm_wluc 201 38 | #define ibm_wruc 187 39 | #define ibm_wllc 200 40 | #define ibm_wrlc 188 41 | #define ibm_whor 205 42 | #define ibm_wver 186 43 | 44 | 45 | #define def_luc '+' 46 | #define def_ruc '+' 47 | #define def_llc '+' 48 | #define def_rlc '+' 49 | #define def_ut '+' 50 | #define def_lt '+' 51 | #define def_rt '+' 52 | #define def_gt '+' 53 | #define def_cro '+' 54 | #define def_hor '-' 55 | #define def_ver '|' 56 | 57 | #define def_wluc luc 58 | #define def_wruc ruc 59 | #define def_wllc llc 60 | #define def_wrlc rlc 61 | #define def_whor hor 62 | #define def_wver ver 63 | 64 | 65 | 66 | 67 | /* functions to get and set the format string */ 68 | 69 | char *getformat(void); 70 | void setformat(char *newformat); 71 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/profile.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | PROFILE.H: header for PROFILE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the macros and prototypes for the profiling functions 8 | 9 | ================================================================*/ 10 | 11 | /* access Macros for callgraph node */ 12 | 13 | #define set_opid(_X_,_Y_) (_X_->opid = _Y_) 14 | #define set_parent(_X_,_Y_) (_X_->parent = _Y_) 15 | #define set_start_time(_X_,_Y_) (_X_->start_time = _Y_) 16 | #define set_end_time(_X_,_Y_) (_X_->end_time = _Y_) 17 | #define set_total_time(_X_,_Y_) (_X_->total_time = _Y_) 18 | #define set_total_calls(_X_,_Y_) (_X_->total_calls = _Y_) 19 | #define inc_total_calls(_X_) (_X_->total_calls++) 20 | #define inc_num_children(_X_) (_X_->num_children++) 21 | #define add_time(_X_) (_X_->total_time += (_X_->end_time - _X_->start_time)) 22 | 23 | /* size constants for profiler */ 24 | 25 | #define LOCLISTSIZE 20 26 | #define SYMLISTSIZE 50 27 | #define NODESIZE 5 28 | 29 | extern void profile_ops_start(nialptr entr); 30 | extern void profile_ops_stop(nialptr entr); 31 | extern void clear_profiler(void); 32 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/reserved.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER RESERVED.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the reserved words. 8 | 9 | ================================================================*/ 10 | 11 | #define NORESWORDS 48 12 | 13 | #define r_IS "IS" 14 | #define r_DOT "." 15 | #define r_LPAREN "(" 16 | #define r_RPAREN ")" 17 | #define r_LBRACKET "[" 18 | #define r_OLBRACKET "<<" 19 | #define r_RBRACKET "]" 20 | #define r_ORBRACKET ">>" 21 | #define r_SEMICOLON ";" 22 | #define r_IF "IF" 23 | #define r_THEN "THEN" 24 | #define r_ELSE "ELSE" 25 | #define r_GETS "GETS" 26 | #define r_ASSIGNSYM ":=" 27 | #define r_WHILE "WHILE" 28 | #define r_DO "DO" 29 | #define r_ENDWHILE "ENDWHILE" 30 | #define r_REPEAT "REPEAT" 31 | #define r_UNTIL "UNTIL" 32 | #define r_ENDREPEAT "ENDREPEAT" 33 | #define r_FOR "FOR" 34 | #define r_WITH "WITH" 35 | #define r_ENDFOR "ENDFOR" 36 | #define r_CASE "CASE" 37 | #define r_FROM "FROM" 38 | #define r_COLON ":" 39 | #define r_BEGIN "BEGIN" 40 | #define r_END "END" 41 | #define r_ENDCASE "ENDCASE" 42 | #define r_ENDIF "ENDIF" 43 | #define r_VARIABLE "VARIABLE" 44 | #define r_EXPRESSION "EXPRESSION" 45 | #define r_OP "OP" 46 | #define r_OPERATION "OPERATION" 47 | #define r_TR "TR" 48 | #define r_TRANSFORMER "TRANSFORMER" 49 | #define r_EXTERNAL "EXTERNAL" 50 | #define r_LCURLY "{" 51 | #define r_RCURLY "}" 52 | #define r_COMMA "," 53 | #define r_LOCAL "LOCAL" 54 | #define r_NONLOCAL "NONLOCAL" 55 | #define r_PGMQUOTE "!" 56 | #define r_CAT "@" 57 | #define r_BAR "|" 58 | #define r_HASH "#" 59 | #define r_EXIT "EXIT" 60 | #define r_ELSEIF "ELSEIF" 61 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/resnms.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER RESNMS.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The array of reserved words as strings 8 | 9 | ================================================================*/ 10 | 11 | 12 | #define NORESWORDS 48 13 | 14 | static char *reswords[NORESWORDS] = { 15 | "IS", 16 | ".", 17 | "(", 18 | ")", 19 | "[", 20 | "<<", 21 | "]", 22 | ">>", 23 | ";", 24 | "IF", 25 | "THEN", 26 | "ELSE", 27 | "GETS", 28 | ":=", 29 | "WHILE", 30 | "DO", 31 | "ENDWHILE", 32 | "REPEAT", 33 | "UNTIL", 34 | "ENDREPEAT", 35 | "FOR", 36 | "WITH", 37 | "ENDFOR", 38 | "CASE", 39 | "FROM", 40 | ":", 41 | "BEGIN", 42 | "END", 43 | "ENDCASE", 44 | "ENDIF", 45 | "VARIABLE", 46 | "EXPRESSION", 47 | "OP", 48 | "OPERATION", 49 | "TR", 50 | "TRANSFORMER", 51 | "EXTERNAL", 52 | "{", 53 | "}", 54 | ",", 55 | "LOCAL", 56 | "NONLOCAL", 57 | "!", 58 | "@", 59 | "|", 60 | "#", 61 | "EXIT", 62 | "ELSEIF", 63 | }; 64 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/roles.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER ROLES.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the syntactic roles of variables 8 | 9 | ================================================================*/ 10 | 11 | #define Rres 0 12 | #define Rident 1 13 | #define Rconst 2 14 | #define Roptn 3 15 | #define Rtrans 4 16 | #define Rvar 5 17 | #define Rexpr 6 18 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/scan.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SCAN.H: header for SCAN.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains macros and prototypes of the scan functions 8 | 9 | ================================================================*/ 10 | 11 | void initscan(void); 12 | 13 | #define Upper(x) (islower(x) ? toupper(x) : x) 14 | #define Lower(x) (isupper(x) ? tolower(x) : x) 15 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/sorts.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SORTS.H: header for SORTS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the internal array theory operations 8 | used by other routines. 9 | 10 | ================================================================*/ 11 | 12 | 13 | extern void iqsort(void); 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/switches.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER SWITCHES.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-20016 6 | 7 | This file contains switch settings for building QNial. 8 | It assumes the build is for a Unix based operating system e.g (OSX or Linux) 9 | and that the target architecture is an Intel like chip that supports 32 and 64 bit words. 10 | 11 | ================================================================*/ 12 | 13 | 14 | #ifndef _SWITCHES_H_ 15 | #define _SWITCHES_H_ 16 | 17 | /* 18 | This file controls what code gets included or excluded when 19 | the code of Q'Nial is processed. 20 | */ 21 | 22 | 23 | /* compiler command lines can set the following switches to remove 24 | some capabilities and set up variant versions. 25 | 26 | DEBUG - removes features that interfere with debugging. 27 | Also includes substantial debugging checks. 28 | LINUX or OSX - used in the code to handle minor differences or capabilities 29 | 30 | */ 31 | 32 | #define SYSTEM 33 | #define DIRECTIO 34 | #define V6AT 35 | #define COMMAND 36 | #define TIMEHOOK 37 | #define DIRECTIO 38 | #define PROFILE 39 | 40 | #include "pkgswchs.h" /* load the defines constructed by Pkgblder */ 41 | 42 | /* switches set for LINUX or OSX builds. */ 43 | 44 | /* operating system capabilities */ 45 | 46 | #define ABORTSIGNAL 47 | #define JOBCONTROL 48 | #define FP_EXCEPTION_FLAG 49 | #define USER_BREAK_FLAG 50 | 51 | /* define these four switches below to trade speed for space */ 52 | 53 | #define FETCHARRAYMACRO 54 | #define STOREARRAYMACRO 55 | #define FREEUPMACRO 56 | #define STACKMACROS 57 | 58 | /* they should always be undefined if a DEBUG build is being made */ 59 | 60 | #ifdef DEBUG 61 | #undef FETCHARRAYMACRO 62 | #undef STOREARRAYMACRO 63 | #undef FREEUPMACRO 64 | #undef STACKMACROS 65 | #endif 66 | 67 | /* the following includes set up types and constants appropriate for 32 or 64 bits systems */ 68 | 69 | #include "nialtypes.h" 70 | #include "nialconsts.h" 71 | 72 | #endif /* _SWITCHES_H_ */ 73 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/systemops.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | SYSTEMOPS.H: header for SYSTEMOPS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the host function. 8 | 9 | ================================================================*/ 10 | 11 | 12 | 13 | extern void ihost(void); -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/token.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | HEADER TOKEN.H 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | The macros for the token properties used by scan.c and parse.c 8 | 9 | ================================================================*/ 10 | 11 | /* Token Properties */ 12 | #define delimprop 1 13 | #define identprop 2 14 | #define commentprop 3 15 | #define eolprop 4 /* accept in parse.c expects these to */ 16 | #define indentprop 5 /* be the last three properties */ 17 | #define exdentprop 6 18 | 19 | #define constprop 10 20 | #define constphprop 15 /* because sPhrase is 5 */ 21 | 22 | /* constant tokens are 10 + state value in scan */ 23 | 24 | #define indentamt 3 /* used to control indenting in descan */ 25 | #define commentamt 2 /* used to control comment indenting in descan */ 26 | 27 | void initdeparse(void); 28 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/trig.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | TRIG.H: header for TRIG.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the trigonometric functions 8 | 9 | ================================================================*/ 10 | 11 | /* constants: define to appropriate precision 12 | (here are enough digits for any machine) 13 | #define PI 3.141592653589793238462643 14 | #define PIBYTWO 1.570796326794896619231322 15 | */ 16 | 17 | #ifndef PI 18 | #define PI 3.1415926535897932 19 | #endif 20 | 21 | #define PIBYTWO 1.57079632679489662 22 | 23 | #ifdef SCIENTIFIC 24 | 25 | 26 | extern void isin(void); 27 | extern void icos(void); 28 | extern void itan(void); 29 | extern void isinh(void); 30 | extern void icosh(void); 31 | extern void itanh(void); 32 | extern void iarcsin(void); 33 | extern void iarctan(void); 34 | extern void iarccos(void); 35 | extern void iexp(void); 36 | extern void iln(void); 37 | extern void ilog(void); 38 | extern void isqrt(void); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/trs.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | TRS.H: header for TRS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the transformer second order functions 8 | 9 | ================================================================*/ 10 | 11 | 12 | extern void int_each(void (*f) (void), nialptr x); 13 | extern void real_each(double (*f) (double), nialptr x); 14 | extern void int_eachboth(void (*f) (void), nialptr x, nialptr y); 15 | void sort(nialptr f, nialptr x, int gradesw); 16 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/utils.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | UTILS.H: header for UTILS.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of various utility functions 8 | 9 | ================================================================*/ 10 | 11 | extern nialptr int_to_real(nialptr x); 12 | extern nialptr bool_to_real(nialptr x); 13 | extern nialptr arithconvert(nialptr x, int *newk); 14 | extern nialptr to_real(nialptr x); 15 | extern int convert(nialptr * x, int *kx, int k); 16 | extern nialptr testfaults(nialptr x, nialptr stdfault); 17 | extern nialptr testbinfaults(nialptr x, nialptr stdfault, int divflag); 18 | extern int tkncompare(nialptr x, nialptr y); 19 | extern nialptr boolstoints(nialptr x); 20 | extern void cnvtup(char *str); 21 | extern nialint ngetname(nialptr x, char *value); 22 | extern nialptr getuppername(void); 23 | extern char *slower(char *in_s); 24 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/version.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | VERSION.H: 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This defines macros to set up the banner line for various versions. 8 | 9 | ================================================================*/ 10 | 11 | #ifndef _VERSION_H_ 12 | #define _VERSION_H_ 13 | 14 | /* The banner information is constructed from: 15 | special 16 | nialversion 17 | machine 18 | wordsize 19 | opsys 20 | debugstatus 21 | date 22 | */ 23 | 24 | /* 25 | The internal variable systemname is used to set the Nial 26 | expression System that is available for programs to test which 27 | version is being used. Only one of these cases is chosen. 28 | */ 29 | 30 | #ifndef __DATE__ 31 | 32 | /* compiler does not provide date functionality, set date directly 33 | below and remove the words (Possibly incorrect)*/ 34 | 35 | #define __DATE__ "Feb 07, 2007 (Possibly incorrect)" 36 | 37 | #endif 38 | 39 | /* Version 6.3 is the public domain version released as open source */ 40 | 41 | #define nialversion " 7.0.1" 42 | 43 | 44 | /* 45 | The internal variable systemname is used to set the Nial 46 | expression System that is available for programs to test which 47 | version is being used. Only one of these cases is chosen. 48 | */ 49 | 50 | 51 | 52 | #ifdef LINUX 53 | #define opsys " Linux" 54 | #endif 55 | 56 | #ifdef FREEBSD 57 | #define opsys "FreeBSD" 58 | #endif 59 | 60 | #ifdef OSX 61 | #define opsys " Mac OSX" 62 | #endif 63 | 64 | #ifdef WINNIAL 65 | #define opsys "Windows" 66 | #endif 67 | 68 | 69 | /* inducate word size */ 70 | 71 | #ifdef INTS32 72 | #define wordsize " 32bit" 73 | #elif INTS64 74 | #define wordsize " 64bit" 75 | #else 76 | #error set wordsize for this configuration 77 | #endif 78 | 79 | #ifdef DEBUG 80 | #define debugstatus " DEBUG" 81 | #else 82 | #define debugstatus "" 83 | #endif 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /BuildNial/pkgblder/src_nialcore/wsmanage.h: -------------------------------------------------------------------------------- 1 | /*============================================================== 2 | 3 | WSMANAGE.H: header for WSMANAGE.C 4 | 5 | COPYRIGHT NIAL Systems Limited 1983-2005 6 | 7 | This contains the prototypes of the workspace load and save functions 8 | 9 | ================================================================*/ 10 | 11 | /* Flags used by doloadsave */ 12 | 13 | 14 | enum { 15 | FORCE_EXTENSION = 1, NOFORCE_EXTENSION = 0 16 | }; 17 | 18 | extern void wsdump(FILE * f1); 19 | extern void wsload(FILE * f1); 20 | extern void check_ext(char *str, char *ext,int force); 21 | extern int loaddefs(int fromfile, char *fname, int mode); 22 | 23 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/DataTrans.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | // Create an array of vectors of random numbers 4 | // For each vector compute its mean and standard 5 | // deviation and adjust the entries of the vector 6 | // to be number of standard deviations from the mean 7 | 8 | 9 | class DataTrans { 10 | 11 | static final int nentries = 60000; 12 | static final int narrays = 1024; 13 | static final int n_iter = 20; 14 | 15 | // The initial array of arrays 16 | static double[][] a = null; 17 | 18 | // Hold for result 19 | static double[][] res = new double[narrays][]; 20 | 21 | private static double random_val() { 22 | return Math.random(); 23 | } 24 | 25 | // Initialise the program 26 | private static void setup() { 27 | a = new double[narrays][nentries]; 28 | for (int i = 0; i < narrays; i++) { 29 | for (int j = 0; j < nentries; j++) 30 | a[i][j] = random_val(); 31 | } 32 | return; 33 | } 34 | 35 | private static double[] one_row(double[] inp) { 36 | double avg = 0.0, std = 0.0; 37 | double[] d = new double[nentries]; 38 | for (int j = 0; j < nentries; j++) 39 | avg += (d[j] = inp[j]); 40 | avg /= nentries; 41 | for (int j = 0; j < nentries; j++) { 42 | double ev = d[j] - avg; 43 | std += ev*ev; 44 | d[j] = ev; 45 | } 46 | std = Math.sqrt(std/nentries); 47 | for (int j = 0; j < nentries; j++) 48 | d[j] /= std; 49 | 50 | return d; 51 | } 52 | 53 | 54 | public static void main(String[] args) { 55 | 56 | setup(); 57 | 58 | // Get Jitted so no complaints 59 | res[0] = one_row(a[0]); 60 | 61 | long startTime = System.nanoTime(); 62 | for (int i = 0; i < n_iter; i++) 63 | for (int j = 1; j < narrays; j++) 64 | res[j] = one_row(a[j]); 65 | long endTime = System.nanoTime(); 66 | 67 | System.out.println("Average time: " + ((endTime - startTime)/(1.0*n_iter))); 68 | 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/data_trans.ijs: -------------------------------------------------------------------------------- 1 | NB. Numeric tests to compute the number of 2 | NB. standard deviations from the mean for each element 3 | NB. of a 1024x60000 real matrix 4 | 5 | NB. Create a test matrix 6 | 7 | testm =: ?"0 ( 1024 60000 {. 0) 8 | 9 | NB. Monadic vector function to compute the number of 10 | NB. standard deviations from the mean for each element 11 | NB. of the vector 12 | 13 | transv =: monad define 14 | avg =: (+/ y) % #y 15 | mean_offset =: y - avg 16 | std =: 2 %: ((+/ (mean_offset*mean_offset)) % #y) 17 | mean_offset % std 18 | ) 19 | 20 | 21 | NB. Test is run by loading this script and computing 22 | NB. the average time over 10 iterations as follows - 23 | NB. 24 | NB. 10 (6!:2) 'transv"1 testm' 25 | NB. -------------------------------------------------------------------------------- /BuildNial/testing/comparison/data_trans.ndf: -------------------------------------------------------------------------------- 1 | # Create an array of vectors of random numbers 2 | # For each vector compute its mean and standard 3 | # deviation and adjust the entries of the vector 4 | # to be number of standard deviations from the mean 5 | 6 | 7 | nentries := 60000; 8 | narrays := 1024; 9 | 10 | a := each random (narrays take nentries); 11 | 12 | one_row is op x { 13 | m := (sum x)/(tally x); 14 | ax := x - m; 15 | s := sqrt ((sum (ax*ax))/(tally x)); 16 | ax/s 17 | } 18 | 19 | 20 | write 'Starting time test'; 21 | 22 | n_iter := 20; 23 | i := 0; 24 | 25 | start_time := time; 26 | while i < n_iter do 27 | res := each one_row a; 28 | i := i + 1; 29 | endwhile; 30 | end_time := time; 31 | 32 | write 'Duration' ((end_time-start_time)/n_iter); 33 | bye; 34 | 35 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/data_trans.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | a = np.random.rand(1024, 60000) 3 | import time 4 | 5 | n = 0 6 | n_iter = 20 7 | 8 | start_time = time.time() 9 | 10 | while n < n_iter: 11 | for i, j in enumerate(a): 12 | m = j.mean() 13 | s = j.std() 14 | a[i] = a[i] - m 15 | a[i] = a[i]/s 16 | n = n + 1 17 | 18 | print((time.time() - start_time)/n_iter) 19 | 20 | 21 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/primes.ijs: -------------------------------------------------------------------------------- 1 | NB. Test the peformance of J in computing 2 | NB. primes in a simple way 3 | 4 | is_prime =: monad define 5 | (y > 1) *. (*./ (0 < ((2 }. i. (1 + <. 2 %: y)) | y))) 6 | ) 7 | 8 | isp_time =: dyad define 9 | d =: 1 + i. y 10 | x (6!:2) '(is_prime"0) d' 11 | 12 | isp_list =: monad define 13 | d =: 1 + i. y 14 | (is_prime"0) d 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/primes.ndf: -------------------------------------------------------------------------------- 1 | # Test is a number is a prime 2 | 3 | isp is op X { (X > 1) and (and (0 < (X eachright mod (2 drop tell (1 + floor sqrt X))))) } 4 | 5 | 6 | # Timing tests to determine the average time to determine if a list of 7 | # numbers is a prime using N iterations with numbers 1..M 8 | # 9 | 10 | isp_time is op N M { 11 | durn := 0.0; 12 | for i with (count N) do 13 | d := count M; 14 | t1 := time; 15 | r := each isp d; 16 | t2 := time; 17 | durn := durn + (t2 - t1); 18 | endfor; 19 | durn/N 20 | } 21 | 22 | isp_list is op N { 23 | r := each isp (count N); 24 | r sublist (count N) 25 | } 26 | 27 | write 'Nial duration' (10 isp_time 1000000); 28 | 29 | bye; 30 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/primes.py: -------------------------------------------------------------------------------- 1 | import math 2 | import time 3 | 4 | 5 | def isprime1(n): 6 | return (0==len([x for x in range(2, 1+int(math.sqrt(n))) if (n%x)==0])) 7 | 8 | 9 | def isprime(m): 10 | res = [0==len([x for x in range(2, 1+int(math.sqrt(n))) if (n%x)==0]) for n in range(2,m)] 11 | return res 12 | 13 | t1 = time.time() 14 | s = [x for x in range(2,1000000) if isprime1(x)] 15 | t2 = time.time() 16 | print 'Duration',(t2-t1) 17 | -------------------------------------------------------------------------------- /BuildNial/testing/comparison/sort_tests.ijs: -------------------------------------------------------------------------------- 1 | 2 | NB. niter test_sort_int n 3 | NB. averages the performance of /:~ over 4 | NB. niter iterations selecting n random integers from 5 | NB. [0..n) 6 | 7 | test_sort_int =: dyad define 8 | cn =: 0 9 | durn =: 0.0 10 | while. cn < x do. 11 | d =: ? (y + (y {. 0)) 12 | durn =: durn + (5 (6!:2) '(/:~) d') 13 | cn =: cn + 1 14 | end. 15 | durn%x 16 | ) 17 | 18 | 19 | NB. niter test_sort_real n 20 | NB. averages the performance of /:~ over 21 | NB. niter iterations selecting n random reals from 22 | NB. [0.0 .. 1.0) 23 | 24 | test_sort_real =: dyad define 25 | cn =: 0 26 | durn =: 0.0 27 | while. cn < x do. 28 | d =: ? (y {. 0) 29 | durn =: durn + (5 (6!:2) '(/:~) d') 30 | cn =: cn + 1 31 | end. 32 | durn%x 33 | ) 34 | 35 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/j.ndf: -------------------------------------------------------------------------------- 1 | case state from 2 | "start : { 3 | if ch = 'i' then 4 | state := "number; 5 | elseif ch = 'l' then 6 | state := "list; 7 | elseif ch = 'd' then 8 | state := "dictionary; 9 | elseif ((ch <= 'z') and (ch >= 'a')) then 10 | buf := ch; 11 | state := "count; 12 | else 13 | write 'invalid input'; 14 | endif 15 | } 16 | else { 17 | write 'not handled'; 18 | } 19 | endcase; 20 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/memspaces.ndf: -------------------------------------------------------------------------------- 1 | # memory spaces 2 | # ------------- 3 | # 4 | # Nial memory spaces are a way to connect two Nial processes 5 | # via shared memory or connect Nial to another system. 6 | # 7 | # 8 | # 9 | # space := msp_map_shared size flags 10 | # 11 | # Creates an anonymous read/write shared mapped memory space 12 | # for the process and any children. 13 | # 14 | # msp_put_raw space object offset count 15 | # 16 | # Stores the data from object into the shared space at the 17 | # nominated offset. The count is of entries. 18 | # 19 | # msp_get_raw space type offset count 20 | # 21 | # Fetches data from the shared memory space at the supplied 22 | # offset as a Nial object of the nominated type 23 | # 24 | # msp_atomic_cas space offset oldval newval 25 | # 26 | # Performs an atomic compare and swap operation on a nial 27 | # integer stored in the nominated space at the supplied 28 | # offset (which must be aligned on a nial integer boundary). 29 | # It returns true if the operation succeeds. 30 | # 31 | 32 | # Types of Nial objects 33 | 34 | msp_inttype := 1; 35 | msp_booltype := 2; 36 | msp_chartype := 3; 37 | msp_realtype := 4; 38 | 39 | 40 | # flags 41 | 42 | msp_private := 1; 43 | msp_shared := 0; 44 | 45 | 46 | # Sizes of basic types 47 | 48 | msp_intsize := msp_msize msp_inttype 1; 49 | msp_realsize := msp_msize msp_realtype 1; 50 | 51 | 52 | # 53 | 54 | msp_wsize is op num { 55 | num/msp_intsize 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/nial_testing.ndf: -------------------------------------------------------------------------------- 1 | failCount := 0; 2 | successCount := 0; 3 | 4 | square is op A { 5 | A*A 6 | } 7 | 8 | assert is op TName Res { 9 | nonlocal failCount successCount; 10 | if Res then 11 | successCount := successCount + 1; 12 | write link TName ' succeeded'; 13 | else 14 | failCount := failCount + 1; 15 | write link TName ' failed'; 16 | endif; 17 | l 18 | } 19 | 20 | 21 | almost_zero is op Delta A { 22 | (tally A) = sum (Delta > (abs A)) 23 | } 24 | 25 | 26 | almost_one is op Delta A { 27 | (tally A) = sum (Delta > (abs (1.0 - A))) 28 | } 29 | 30 | 31 | 32 | is_identical_to is op A B { 33 | and (A = B) 34 | } 35 | 36 | 37 | 38 | # Trig functions 39 | ---------------- 40 | 41 | 'trig1' assert (1.0e-5 almost_one ((square sin count 1024) + (square cos count 1024))); 42 | 43 | 44 | # Basic arithmetic 45 | ------------------ 46 | 47 | 'arith1' assert (1.0e-5 almost_one ((count 1024)/(count 1024))); 48 | 49 | 50 | # Comparison tests 51 | ------------------ 52 | 53 | 'simple test' assert ((count 1024) = count 1024); 54 | 55 | 56 | # Selection tests 57 | ----------------- 58 | 59 | 'selection1' assert (((512.5 > (count 1024)) sublist (count 1024)) is_identical_to (count 512)); 60 | 61 | # Tidy up 62 | --------- 63 | 64 | write (link 'Success count: ' (string successCount)); 65 | write (link 'Failure count: ' (string failCount)); 66 | 67 | bye 68 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/nio_test1.ndf: -------------------------------------------------------------------------------- 1 | # Very simple test to block and unblock an array 2 | 3 | s := nio_open -1 0; 4 | 5 | write 'writing array to stream'; 6 | d := 2 3 4 5 reshape count 120; 7 | nio_block_array s d; 8 | 9 | write 'unblocking array from stream'; 10 | r := nio_unblock_array s; 11 | 12 | write 'comparing'; 13 | write (r = d); 14 | 15 | bye; 16 | 17 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/nio_test2.ndf: -------------------------------------------------------------------------------- 1 | # Very simple test to block and unblock an array 2 | 3 | s := nio_open -1 0; 4 | 5 | d := 2 3 4 5 reshape count 120; 6 | 7 | ntries := 100000; 8 | 9 | # Get the number of bytes after encoding 10 | 11 | nio_block_array s d; 12 | e_bytes := nio_count s; 13 | nio_unblock_array s; 14 | 15 | 16 | write 'Testing'; 17 | i := 0; 18 | t_start := time; 19 | while i < ntries do 20 | nio_block_array s d; 21 | r := nio_unblock_array s; 22 | i := i + 1; 23 | if r ~= d then 24 | write 'Invalid result at ' i; 25 | bye; 26 | endif; 27 | endwhile; 28 | t_end := time; 29 | 30 | write 'Performance' ((ntries*e_bytes)/(t_end - t_start)); 31 | 32 | bye; 33 | 34 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/nipops.ndf: -------------------------------------------------------------------------------- 1 | nip_dump is op A { 2 | A eachright nip_getword ((count (nip_blocksize A)) - 1) 3 | } -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/ntableTests.ndf: -------------------------------------------------------------------------------- 1 | loaddefs "ntable 2 | 3 | probecount is op T A { 4 | T tset A; 5 | tprobes T 6 | } 7 | 8 | 9 | ttest1 is op N { 10 | t := tcreate 0; 11 | v := count N; 12 | a := each phrase ('a' eachright link (each string v)); 13 | e := a eachboth pair v; 14 | p := t eachright probecount e; 15 | p 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/ntables_tests.ndf: -------------------------------------------------------------------------------- 1 | 2 | # Add an item to the table both as the key and the value 3 | # and return the number of probes to perform the insert 4 | 5 | probe_add1 is OP T M { 6 | T tset ([(phrase string), pass] M); 7 | tprobes T 8 | } 9 | 10 | 11 | probe_add2 is OP T M { 12 | T tset M; 13 | tprobes T 14 | } 15 | 16 | 17 | # Add the integers from 1 to N to the table and 18 | # return some statistics. The second argument M is the 19 | # initial table size 20 | # 21 | # - the number of entries in the table 22 | # - the total size of the table after adding 23 | # - the average number of probes to insert an entry 24 | # - the maximum number of probes to add an entry 25 | 26 | ntables_test1 is OP N M { 27 | write 'trying' N M; 28 | t := tcreate M; 29 | entries := (each [(phrase string), pass] (count N)); 30 | write 'entry count: ' (tally entries); 31 | st := time; 32 | p := t eachright probe_add2 entries; 33 | durn := time - st; 34 | if durn > 0 then 35 | write ('inserts per second: ' link string (N/durn)); 36 | endif; 37 | avg_p := (sum p)/(tally p); 38 | write [(tcount t), (tsize t), avg_p, (max p)]; 39 | t 40 | } 41 | 42 | 43 | # test adding and retrieving entries to a table. 44 | # N entries are added to the table and then retrieved in the 45 | # reverse order. the number of correct retrievals is returned. 46 | 47 | ntables_test2 is OP N { 48 | t := tcreate 1; 49 | entries := each [(phrase string), pass] (count N); 50 | t eachright tset entries; 51 | keys := each phrase (reverse count N); 52 | correct := 0; 53 | for i with reverse count N do 54 | key := phrase string i; 55 | if (t tget key) = i then 56 | correct := correct + 1; 57 | endif; 58 | endfor; 59 | correct 60 | } 61 | 62 | 63 | ntables_test1 100000 1; 64 | ntables_test1 100000 100000; 65 | %ntables_test1 1000000 1; 66 | 67 | bye 68 | 69 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/streams_test1.ndf: -------------------------------------------------------------------------------- 1 | # 2 | # Some performance testing of streams 3 | # 4 | library "nstreams 5 | 6 | write_size := 1034*1024; 7 | num_writes := 512; 8 | 9 | data := write_size take 'a'; 10 | 11 | test_write is op N { 12 | s := nio_open -1 0; 13 | i := 0; 14 | while i < N do 15 | nio_write s data; 16 | i := i + 1; 17 | endwhile; 18 | s 19 | } 20 | 21 | t_start := time; 22 | s := test_write num_writes; 23 | res := nio_count s; 24 | t_end := time; 25 | 26 | write '*** Write Test 1 ***'; 27 | write 'Res' res; 28 | write 'Time' (t_end - t_start); 29 | write 'Performance' (Res / (t_end - t_start)); 30 | 31 | write ''; 32 | 33 | read_test is op S N { 34 | i:= 0; 35 | while i < N do 36 | nio_read s write_size; 37 | i := i + 1; 38 | endwhile; 39 | s 40 | } 41 | 42 | write '*** Read Test ***'; 43 | 44 | cnt := nio_count s; 45 | t_start := time; 46 | s := read_test s num_writes; 47 | res := nio_count s; 48 | t_end := time; 49 | 50 | write 'Res' res; 51 | write 'Time' (t_end - t_start); 52 | write 'Performance' (cnt / (t_end - t_start)); 53 | 54 | write '*** Write Test 2 ***'; 55 | 56 | t_start := time; 57 | s := test_write num_writes; 58 | res := nio_count s; 59 | t_end := time; 60 | 61 | write 'Res' res; 62 | write 'Time' (t_end - t_start); 63 | write 'Performance' (Res / (t_end - t_start)); 64 | 65 | write ''; 66 | 67 | bye; 68 | 69 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/strsearch.ndf: -------------------------------------------------------------------------------- 1 | # routines to support my regular expression design 2 | 3 | # routine strsearch uses a support routine re_matchall 4 | which repeatedly uses the compiled regular expression 5 | 6 | strsearch IS OP A { 7 | re_matchall is OP Target Regexp Options { 8 | Matches := Null; 9 | Done := o; 10 | Offset := 0; 11 | WHILE not Done DO 12 | Match := re_match 0 Target 1 Options; 13 | IF empty Match THEN 14 | Done := True; 15 | ELSE 16 | Pos Len := first Match; 17 | Matches := Matches append (Offset + Pos) Len; 18 | Offset := Offset + Pos + Len; 19 | Target := (Len + Pos) drop Target; 20 | ENDIF; 21 | ENDWHILE; 22 | Matches 23 | }; 24 | IF tally A notin 2 3 THEN 25 | Res := fault '?invalid args in strsearch'; 26 | ELSE 27 | IF tally A = 2 THEN 28 | Regexp Target := A; 29 | Options := 1; 30 | ELSEIF tally A = 3 THEN 31 | Regexp Target Options := A; 32 | ENDIF; 33 | Res := re_compile 0 Regexp Options; 34 | IF Res THEN 35 | Res := re_matchall Target Regexp Options; 36 | ENDIF; 37 | ENDIF; 38 | Res 39 | } 40 | 41 | # nial routine to replace re_extract 42 | 43 | re_extract1 IS OP Target Posnlens { 44 | Posns Lens := flip Posnlens; 45 | Parts := Posns EACHBOTH + EACH tell Lens; 46 | Parts EACHLEFT choose Target } 47 | 48 | 49 | # nial routine to replace re_split 50 | 51 | re_split1 is OP Target Posnlens ( 52 | Posns Lens := flip Posnlens; 53 | Parts := Posns EACHBOTH + EACH tell Lens; 54 | grid Target EACHLEFT in Posns cut Target 55 | ) 56 | 57 | #nial routine to replace re_splice 58 | 59 | re_splice1 is OP Val Parts { 60 | link (front Parts eachleft Link Val) link last Parts 61 | } 62 | 63 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/tcp_worker_client.ndf: -------------------------------------------------------------------------------- 1 | # 2 | # TCP/IP Client process to test the server 3 | # 4 | 5 | library "sprocess; 6 | 7 | write 'Starting client'; 8 | sock := socket_connect 'localhost' 5000; 9 | write ['connected', sock]; 10 | 11 | chan := [nio_open sock 0, nio_open sock 0]; 12 | 13 | ntries := 100; 14 | success := 0; 15 | ndata := 2 3 4 5 reshape count 120; 16 | 17 | while ntries > 0 do 18 | ipc_write_array chan ndata; 19 | res := ipc_read_array chan; 20 | if res = ndata then 21 | success := success + 1; 22 | write 'succeeded'; 23 | else 24 | write 'failed'; 25 | write res; 26 | endif; 27 | ntries := ntries - 1; 28 | endwhile; 29 | 30 | % disconnect; 31 | ipc_write_array chan "done; 32 | write (ipc_read_array chan); 33 | 34 | write ['success', success]; 35 | 36 | bye; 37 | 38 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/tcp_worker_server.ndf: -------------------------------------------------------------------------------- 1 | # 2 | # Create a remote Nial process connected by a stream over TCP/IP. 3 | # 4 | 5 | library "sprocess; 6 | 7 | 8 | # echo actor is a simple Nial function that echoes what it receives 9 | # on a stream 10 | # 11 | 12 | echo_actor is op chan { 13 | running := l; 14 | while running do 15 | res := ipc_read_array chan; 16 | ipc_write_array chan res; 17 | if res = "done then 18 | running := o; 19 | endif; 20 | endwhile; 21 | "done 22 | } 23 | 24 | 25 | # 26 | # Start child spawns a Nial child process to handle the connection. 27 | # It receives two arguments, the connection and a function to 28 | # perform the work 29 | # 30 | 31 | start_child is op con actor { 32 | % Create a reader/write pair; 33 | chan := [nio_open con 0, nio_open con 0]; 34 | % Spawn a child with suitable id; 35 | id := 'socket' link string con; 36 | child := spawn_child id; 37 | if child = Null then 38 | % Actions in child; 39 | res := catch apply actor chan; 40 | ipc_write_array chan res; 41 | bye; 42 | else 43 | % actions in parent; 44 | res := child; 45 | endif; 46 | [id, child] 47 | } 48 | 49 | 50 | # 51 | # Start a socket server to accept incoming connections 52 | # on a nominated host/port combination. 53 | # 54 | # When a connection is accepted a child process is created to 55 | # handle the interaction through a nominated function/actor 56 | # 57 | 58 | start_controller is op host port actor { 59 | write ['starting controller', host, port]; 60 | sock aport := socket_bind host port; 61 | write ['bind', sock, aport]; 62 | socket_listen sock 5; 63 | while l do 64 | con := socket_accept sock; 65 | write ['accepting', con]; 66 | id child := start_child con actor; 67 | endwhile; 68 | "done 69 | } 70 | 71 | 72 | 73 | # Simple test code, start a controller on this machine with an 74 | # echo actor to do the work. Use a host of '0.0.0.0' to accept 75 | # connections on all network addresses for this host. 76 | 77 | start_controller '0.0.0.0' 5000 "echo_actor; 78 | 79 | 80 | -------------------------------------------------------------------------------- /BuildNial/testing/extension_testing/worker_test1.ndf: -------------------------------------------------------------------------------- 1 | library "sprocess 2 | 3 | # Very simple worker process that just echoes back anything 4 | # read on the comms channel 5 | 6 | echo_worker is op chan args { 7 | while l do 8 | data := ipc_read_array chan; 9 | cnt := ipc_write_array chan data; 10 | endwhile; 11 | l 12 | } 13 | 14 | write 'Starting echo worker'; 15 | 16 | try_count := 100000; 17 | tries := try_count; 18 | success := 0; 19 | test_data := 2 3 4 5 reshape count 120; 20 | 21 | # Create a worker process to implement the echo_worker function 22 | # defined above. 23 | 24 | chan io_chan proc := create_worker "echo1 !echo_worker 1; 25 | 26 | write child_id proc; 27 | 28 | # loop sending the test data to the child process and reading what 29 | # is sent back. Count the number of correct responses. 30 | 31 | start_time := time; 32 | while (tries > 0) do 33 | %write 'Sending array'; 34 | ipc_write_array chan test_data; 35 | %write 'Reading array'; 36 | res := ipc_read_array chan; 37 | if (res = test_data) then 38 | success := success + 1; 39 | else 40 | write o; 41 | endif; 42 | tries := tries - 1; 43 | endwhile; 44 | end_time := time; 45 | 46 | # Write the count of successes 47 | 48 | write 'Ending test'; 49 | write success; 50 | write 'Performance in messages/sec'; 51 | write ((2*try_count)/(end_time - start_time)); 52 | 53 | # Terminate the child process to avoid zombies 54 | 55 | kill_child proc; 56 | bye 57 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/atcases: -------------------------------------------------------------------------------- 1 | # tests of the 3 by 3 juxtaposition table 2 | 3 | a a = 3 3 4 | a f a = 4 4 5 | a T f a = 5 5 6 | f a = 4 7 | f f a = 5 8 | T f a = 5 9 | T a f a = 4 (5 5) 10 | T f a = 5 11 | T T f a = 7 12 | 13 | # tests of sequences of AT objects up to length 5 14 | 15 | a a a a a = 3 3 3 3 3 16 | a a a f a = (4 4 4) 4 17 | a a f a a = (4 4)(4 4) 18 | a f a a a = 4 (4 4 4) 19 | f a a a a = 4 4 4 4 20 | a a f f a = (4 4) 5 21 | a f a f a = (5 5) 4 22 | f a a f a = (5 5) 4 23 | a f f f a = 4 6 24 | f f a f a = 6 4 25 | f a f f a = 5 5 26 | f f f f a = 7 27 | a a T f a = (5 5) 5 28 | a T a f a = 4 (5 (5 5)) 29 | T a a f a = (4 4) ((5 5) 5) 30 | a f T f a = 4 6 31 | f a T f a = 6 5 32 | f T a f a = 5 (6 6) 33 | T a f f a = 4 (5 6) 34 | T f a f a = 6 4 35 | a T T f a = 7 7 36 | T a T f a = 5 (7 7) 37 | T T a f a = 4 (5 (6 (7 7))) 38 | T T T f a = 11 39 | 40 | # tests of list constructs 41 | 42 | [] = Null 43 | [a] = solitary 3 44 | [a,a] = 3 3 45 | [a,a,a] = 3 3 3 46 | [a a] = solitary 3 3 47 | [a,a a] = 3 (3 3) 48 | [a a,a] = (3 3) 3 49 | [,] = ??noexpr ??noexpr 50 | [a,] = 3 ??noexpr 51 | [,a] = ??noexpr 3 52 | [[a,a],a] = (3 3) 3 53 | [f] a = solitary 4 54 | [f,f] a = 4 4 55 | [f,[f,f]] a = 4 (4 4) 56 | [f f] a = solitary 5 57 | [T f] a = solitary 5 58 | 59 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autocov.ndf: -------------------------------------------------------------------------------- 1 | # automated coverage tests 2 | 3 | Spacelost := 0; 4 | 5 | loaddefs "coverops 6 | 7 | Startunary 8 | 9 | Startbinary 10 | 11 | Startpict 12 | 13 | write link 'total space lost: '(string Spacelost); 14 | 15 | Bye 16 | 17 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autoids.ndf: -------------------------------------------------------------------------------- 1 | 2 | # Identity Testing Program. 3 | 4 | 5 | # This program drives the testing of the identity given as an 6 | # argument string. It is expected to be run by loading 7 | # a file like "idtests.ndf" that gives a call to the operation 8 | # "idtest" with arguments the description of the id and the list of 9 | # names of data sets to which it is to be applied. 10 | 11 | Quiet := l; 12 | settrigger o; 13 | 14 | loaddefs "datagen 15 | 16 | setlogname "ids.log; set "log; 17 | 18 | write status; 19 | 20 | spacelost := 0; 21 | 22 | loaddefs "testid 23 | 24 | loaddefs "ids 25 | 26 | loaddefs "largeintids 27 | 28 | loaddefs "idtests l 29 | 30 | loaddefs "pervdefs 31 | 32 | loaddefs "pervtsts l 33 | 34 | loaddefs "consist 35 | 36 | loaddefs "conststs l 37 | 38 | loaddefs "trdefs 39 | 40 | loaddefs "trtests l 41 | 42 | write "Done; 43 | 44 | write status; 45 | 46 | write link 'total space lost: '(string spacelost); 47 | 48 | Bye 49 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autoops.ndf: -------------------------------------------------------------------------------- 1 | # file to do automatic testing of operation semantics 2 | 3 | # Operation Semantics Checking Test Program. 4 | 5 | # This program complements the checking done with ids by testing 6 | # that specific operations result in the values expected from 7 | # specific results. The goal is to have a case in here for each major 8 | # code segment in the C routines that implement the operations. 9 | 10 | loaddefs "datagen 11 | 12 | loaddefs "fuzzyeq 13 | 14 | testop is op Opname Arg Answer { 15 | Result gets apply Opname Arg; 16 | if not (Result fuzzyeq Answer) then 17 | appendfile "testops.out (link 'operation is: ' (string Opname)); 18 | appendfile "testops.out (link 'argument is: ' (display Arg)); 19 | appendfile "testops.out (link 'result is: ' (display Result)); 20 | appendfile "testops.out (link 'Answer should be: ' (display Answer)); 21 | appendfile "testops.out (display first status); 22 | appendfile "testops.out ' '; 23 | endif; 24 | } 25 | 26 | Init is op filenm { 27 | NONLOCAL fnm; 28 | fnm gets open filenm "r; 29 | if isfault fnm then 30 | write fnm; 31 | write 'Leaving Nial.'; 32 | bye; 33 | endif; 34 | } 35 | 36 | Run is { 37 | Str := ''; 38 | while not isfault Str do 39 | Str gets readfile Fnm; 40 | write Str; 41 | execute Str; 42 | endwhile; 43 | write 'Done autoops.ndf from Run'; 44 | Bye; 45 | } 46 | 47 | Run 48 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autopic.ndf: -------------------------------------------------------------------------------- 1 | # this file runs the tests of the picture algorithm 2 | 3 | # this file checks the semantics of the picture operations. It assumes 4 | # that sketch and display work as expected on atoms, and tests that the pictures 5 | # are built up correctly. 6 | 7 | loaddefs "picdefs 8 | 9 | dcheck is equal[diagram,_diagram] 10 | 11 | scheck is equal[sketch,_sketch] 12 | 13 | loaddefs "datagen 14 | 15 | piccheck is op a { 16 | for setting with "nodecor "decor do 17 | set setting; 18 | for i with grid a do 19 | write link 'testing diagram on ' a@i ' with setting ' (string setting); 20 | res := each dcheck execute a@i; 21 | IF not and res THEN 22 | appendfile "pic.out (link 'diagram check failed on ' a@i); 23 | appendfile "pic.out (sketch res); 24 | write 'failed'; 25 | write res; 26 | ENDIF; 27 | write link 'testing sketch on ' a@i; 28 | res := each scheck execute a@i; 29 | IF not and res THEN 30 | appendfile "pic.out (link 'sketch check failed on ' a@i); 31 | appendfile "pic.out (sketch res); 32 | write 'failed'; 33 | write res; 34 | ENDIF; 35 | endfor; 36 | endfor; 37 | } 38 | 39 | setformat '%25.17g'; 40 | 41 | setlogname "pic.log; 42 | 43 | set "log; 44 | 45 | write status; 46 | 47 | piccheck 'atoms' 'allatompairs' 'funny' 'valent' 'tables' 'empties'; 48 | 49 | write status; 50 | 51 | Bye 52 | 53 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autorand.ndf: -------------------------------------------------------------------------------- 1 | # this file does the testing of randomly generated arrays 2 | # It does not create a log so that large tests can be run without 3 | # eating up disk space. 4 | 5 | loaddefs"randtest 6 | 7 | noisy := o; 8 | 9 | quiet := l; 10 | 11 | Tries := 0; 12 | 13 | setlogname "rand.log; 14 | set"log; write status; set "nolog; 15 | 16 | #set seed if you want to always run same tests 17 | %seed .31323334; 18 | 19 | Limit := 5000; 20 | 21 | set"log; write status; set "nolog; 22 | 23 | settrigger o; 24 | 25 | Starters := random Limit ; 26 | 27 | Spacelost := 0; 28 | 29 | randtest 30 | 31 | %restarting 540 550 32 | 33 | set"log; 34 | write status; 35 | write link 'total space lost: ' (string spacelost); 36 | 37 | set "nolog; 38 | 39 | Bye 40 | 41 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/autotest: -------------------------------------------------------------------------------- 1 | rm *.out 2 | rm *.log 3 | ./nial +size 1000000 -defs autoids 4 | ./nial +size 1000000 -defs autocov 5 | ./nial +size 1000000 -defs autoops 6 | ./nial +size 1000000 -defs autoeval 7 | ./nial +size 1000000 -defs autopic 8 | ./nial +size 1000000 -defs autorand 9 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/binops: -------------------------------------------------------------------------------- 1 | allin 2 | append 3 | blend 4 | choose 5 | cut 6 | cutall 7 | deepplace 8 | divide 9 | drop 10 | dropright 11 | except 12 | find 13 | findall 14 | fuse 15 | hitch 16 | in 17 | innerproduct 18 | like 19 | match 20 | mate 21 | minus 22 | mod 23 | notin 24 | pair 25 | pick 26 | place 27 | placeall 28 | plus 29 | power 30 | quotient 31 | raise 32 | reach 33 | reshape 34 | rotate 35 | seek 36 | solve 37 | split 38 | sublist 39 | take 40 | takeright 41 | times 42 | < 43 | <= 44 | > 45 | >= 46 | up 47 | mold 48 | lower 49 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/breaktest.ndf: -------------------------------------------------------------------------------- 1 | 2 | 3 | f is op A {A := A + 1; tell A} 4 | 5 | breaktest is op A { 6 | write 'started operation'; 7 | break; 8 | write 'use stepv, then nextv, and then toend in the following loop'; 9 | FOR I WITH count 3 DO 10 | y gets f 5 6; 11 | x gets (3 + 4) * y; 12 | write 'still in loop'; 13 | ENDFOR; 14 | write 'after loop'; 15 | if a = 1 then 16 | breaktest 2; 17 | write 'after breaktest inner call'; 18 | endif; 19 | write 'after breaktest outer call'; 20 | } 21 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/check10.ndf: -------------------------------------------------------------------------------- 1 | # Fork is a primitive transformer which can take an arbitrary number 2 | of operations in its argument list. It cannot be directly 3 | simulated in general, but can be for a fixed number of arguments. 4 | 5 | #FORK3 is tr f g h op a { 6 | if f a then g a else h a endif } 7 | 8 | #CHECK10 is tr f g h (equal [FORK [f,g,h],FORK3[f,g,h]) 9 | 10 | testid 'CHECK10 [atomic,abs,opposite]' Mixedargs 11 | 12 | testid 'CHECK10 [simple,first,second]' Mixedargs 13 | 14 | testid 'CHECK10 [empty ,Null first,(3 reshape)]' Mixedargs 15 | 16 | testid 'CHECK10 [atomic,solitary,single]' Mixedargs 17 | 18 | testid 'CHECK10 [Null = shape,link,cart]' Mixedargs 19 | 20 | testid 'CHECK10 [simple,sum,max]' Mixedargs 21 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/chopheap.ndf: -------------------------------------------------------------------------------- 1 | # This program generates random arrays and stores them in the workspace in 2 | random variable names. It erases every other one to create a heap that is 3 | badly fragmanted. 4 | 5 | # It should be run to examine the behaviour of a fixed size workspace as it 6 | gets full. 7 | 8 | Varnum := 0; 9 | 10 | genname is phrase link 'X ' (string (Varnum := Varnum + 1)); 11 | 12 | generate is op seedno ( 13 | seed seedno; 14 | Size gets 1; 15 | repeat 16 | assign (Nm := genname) (tell Size); 17 | assign genname (tell (Size+1)); 18 | assign genname (tell (Size + 2)); 19 | erase Nm; 20 | Size := Size + 3; 21 | write "Varnum Varnum "Size Size; 22 | write status; 23 | until false endrepeat; 24 | ) 25 | 26 | set"log; 27 | 28 | generate (Pi/10.) 29 | 30 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/consist.ndf: -------------------------------------------------------------------------------- 1 | # definitions for consistency checks 2 | 3 | Zeros is o 0 0.0 4 | 5 | Ones is l 1 1.0 6 | 7 | Args is Zeros Ones 8 | 9 | Zzpairs is list cart Zeros Zeros 10 | 11 | Zopairs is list cart Zeros Ones 12 | 13 | Ozpairs is list cart Ones Zeros 14 | 15 | Oopairs is list cart Ones Ones 16 | 17 | Binargs is ZZpairs Zopairs Ozpairs Oopairs 18 | 19 | CHECK IS TRANSFORMER f ( and OUTER mate (2 reshape [EACH f]) ) 20 | 21 | loaddefs "fuzzyeq 22 | 23 | CHECK1 IS TRANSFORMER f ( and OUTER fuzzyeq (2 reshape [EACH f]) ) 24 | 25 | Zeros1 is o 0; 26 | 27 | Ones1 is l 1; 28 | 29 | Zzpairs1 is list cart Zeros1 Zeros1 30 | 31 | Zopairs1 is list cart Zeros1 Ones1 32 | 33 | Ozpairs1 is list cart Ones1 Zeros1 34 | 35 | Oopairs1 is list cart Ones1 Ones1 36 | 37 | Binargs1 is ZZpairs1 Zopairs1 Ozpairs1 Oopairs1 38 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/constant: -------------------------------------------------------------------------------- 1 | # some simple lexical tests to ensure all constants and symbols are 2 | # handled correctly. 3 | 4 | (second second second parse scan 'l') = (3 = 3) 5 | (second second second parse scan 'o') = (3 ~= 3) 6 | (second second second parse scan 'lollo') = ('abcde' EACHLEFT in 'acd') 7 | (second second second parse scan '-285') = opposite 285 8 | (second second second parse scan '1024') = (2 power 10) 9 | (second second second parse scan '0') = (5 - 5) 10 | (second second second parse scan '07') = (5 + 2) 11 | (second second second parse scan '3.') = (4.0 - 1.0) 12 | (second second second parse scan '3.5') = (3.0 + reciprocal 2.0) 13 | (second second second parse scan '.25') = reciprocal 4.0 14 | (second second second parse scan '0.25') = reciprocal 4.0 15 | (second second second parse scan '-0.25') = opposite reciprocal 4.0 16 | (second second second parse scan '-0.25e5') = opposite (reciprocal 4.0 * (10. power 5)) 17 | (second second second parse scan '-0.25e+5') = opposite (reciprocal 4.0 * (10. power 5)) 18 | (second second second parse scan '-0.25e-5') = opposite (reciprocal 4.0 * (10. power -5)) 19 | (second second second parse scan '3j4') = (3 + (4 * 0j1)) 20 | (second second second parse scan '-3j-4') = opposite (3 + (4 * 0j1)) 21 | (second second second parse scan '`x') = first 'xyz' 22 | (second second second parse scan '`''') = first '''' 23 | (second second second parse scan '`'' ') = second ' '' ' 24 | (second second second parse scan '``') = first '`' 25 | (second second second parse scan '''abcd''') = link 'ab' 'cd' 26 | (second second second parse scan '''Queen''''s''') = ('Queen' append `' append `s) 27 | (second second second parse scan '''''') = Null 28 | (second second second parse scan '"abcd') = phrase 'abcd' 29 | (second second second parse scan '"abc:') = phrase 'abc:' 30 | (second second second parse scan '""abcd') = phrase '"abcd' 31 | (second second second parse scan '""') = phrase '"' 32 | (second second second parse scan '??') = fault '?' 33 | 34 | # tests from earlier files 35 | 36 | [((((((((((((((((((((((((2)))))))))))))))))))))))) 3] = solitary 2 3 37 | ((((((((((((((((((((((((2 3)))))))))))))))))))))))) = 2 3 38 | (2(3(4(5(6(7(8(9(0 0))))))))) = [2,[3,[4,[5,[6,[7,[8,[9,[0,0]]]]]]]]] 39 | (each each each each each each each each each first 3) = 3 40 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/conststs.ndf: -------------------------------------------------------------------------------- 1 | # tests for consistency checks 2 | 3 | testid 'CHECK abs' ['Args'] 4 | 5 | testid 'CHECK arccos' ['Args'] 6 | 7 | testid 'CHECK arcsin' ['Args'] 8 | 9 | testid 'CHECK1 arctan' ['Args'] 10 | 11 | testid 'CHECK cos' ['Args'] 12 | 13 | testid 'CHECK cosh' ['Args'] 14 | 15 | testid 'CHECK exp' ['Args'] 16 | 17 | testid 'CHECK ln' ['Args'] 18 | 19 | testid 'CHECK log' ['Args'] 20 | 21 | testid 'CHECK opposite' ['Args'] 22 | 23 | testid 'CHECK pass' ['Args'] 24 | 25 | testid 'CHECK reciprocal' ['Args'] 26 | 27 | testid 'CHECK sin' ['Args'] 28 | 29 | testid 'CHECK sinh' ['Args'] 30 | 31 | testid 'CHECK sqrt' ['Args'] 32 | 33 | testid 'CHECK tan' ['Args'] 34 | 35 | testid 'CHECK tanh' ['Args'] 36 | 37 | testid 'CHECK type' ['Args'] 38 | 39 | # checking binaries 40 | 41 | testid 'CHECK divide' ['Binargs'] 42 | 43 | testid 'CHECK mate' ['Binargs'] 44 | 45 | testid 'CHECK minus' ['Binargs'] 46 | 47 | testid 'CHECK plus' ['Binargs'] 48 | 49 | testid 'CHECK power' ['Binargs'] 50 | 51 | testid 'CHECK times' ['Binargs'] 52 | 53 | testid 'CHECK <' ['Binargs'] 54 | 55 | testid 'CHECK <=' ['Binargs'] 56 | 57 | testid 'CHECK >' ['Binargs'] 58 | 59 | testid 'CHECK >=' ['Binargs'] 60 | 61 | # change values to test mod and quotient 62 | 63 | testid 'CHECK mod' ['Binargs1'] 64 | 65 | testid 'CHECK quotient' ['Binargs1'] 66 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/defines: -------------------------------------------------------------------------------- 1 | # evaluation tests to check out the definition facility 2 | 3 | # defining expressions 4 | 5 | xy is 5;xy = 5 6 | v is external variable;xy is v;v gets 10;xy = 10 7 | xy is 2*v;v gets 30;xy = 60 8 | xy is (2*v);v gets 30;xy = 60 9 | xy is {2*v};v gets 30;xy = 60 10 | xy is external expression;xy is 5;xy = 5 11 | 12 | # defining operations 13 | 14 | f is count;f 3 = 1 2 3 15 | f is 3 *;f 3 = 9 16 | f is rest rest;f count 5 = 3 4 5 17 | f is EACH count;f 2 3 = (1 2) (1 2 3) 18 | f is op a(a+1);f 20 = 21 19 | f is op a{f is rest;f f a};f count 5 = 3 4 5 20 | f is external operation;f is count;f 3 = 1 2 3 21 | 22 | # defining transformers 23 | 24 | T is EACH;T count 2 3 = (1 2) (1 2 3) 25 | T is tr f(3 FOLD f);T rest count 5 = 4 5 26 | T is tr f (equal EACH f);T (first count) 2 3 4 = l 27 | T is tr f (EACH EACH f);T tally [[[1,2,3],[4,5]],[[2,3],[4,5,6,7]]] = [[3,2],[2,4]] 28 | T is tr f(f f);T rest count 5 = 3 4 5 29 | T is tr f op a([f,f]a);T count 2 = [1 2,1 2] 30 | T is external transformer;T is EACH;T count 2 3 = (1 2) (1 2 3) 31 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/evassign: -------------------------------------------------------------------------------- 1 | # test cases for evaluator on assignment 2 | 3 | (v gets 3;v) = 3 4 | (v gets 3 4 5;v) = 3 4 5 5 | (v b c gets 3 4 5;v b c) = 3 4 5 6 | (v b c gets 3 4 5;v) = 3 7 | (v b c gets 3 4 5;b) = 4 8 | (v b c gets 3 4 5;c) = 5 9 | (v:=b:=3 4;v b) = (3 4) (3 4) 10 | (v:=3;5+(v:=v+2;10)+v) = 20 11 | (v:=3;(v:=v+2)+v) = 10 12 | (v:=3;(v:=v+2)+v;v) = 5 13 | (v:=3;v+(v:=v+2)) = 8 14 | (v:=3;v+(v:=v+2);v) = 5 15 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/evtests: -------------------------------------------------------------------------------- 1 | # Code to call evaluation tester on various test suites 2 | 3 | testcases "atcases 4 | 5 | testcases "control 6 | 7 | testcases "scope 8 | 9 | testcases "evassign 10 | 11 | testcases "indexing 12 | 13 | testcases "quoted 14 | 15 | testcases "defines 16 | 17 | testcases "recurs 18 | 19 | testcases "constant 20 | 21 | testcases "limits 22 | 23 | 24 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/exprs: -------------------------------------------------------------------------------- 1 | break 2 | callstack 3 | bye 4 | copyright 5 | continue 6 | clearws 7 | clearscreen 8 | clearline 9 | clearwindow 10 | cleartoend 11 | filestatus 12 | false 13 | falsehood 14 | nialroot 15 | no_expr 16 | null 17 | pi 18 | readchar 19 | readcursor 20 | refresh 21 | restart 22 | resume 23 | screensize 24 | separator 25 | status 26 | step 27 | system 28 | time 29 | toplevel 30 | timestamp 31 | true 32 | truth 33 | version 34 | window 35 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/faulteq.ndf: -------------------------------------------------------------------------------- 1 | # an equality test that considers its arguments equal 2 | if they are equal within roundof error, if one of them is a fault, or they 3 | are of the same shape and their items are equal within the 4 | same constraints. 5 | 6 | faulteq IS OP A B { 7 | IF A fuzzyeq B THEN 8 | True 9 | ELSEIF or EACH isfault A B THEN 10 | True 11 | ELSEIF or EACH atomic A B THEN 12 | A = B 13 | ELSEIF shape A = shape B THEN 14 | and EACHBOTH faulteq A B 15 | ELSE 16 | False 17 | ENDIF } 18 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/fragsped.ndf: -------------------------------------------------------------------------------- 1 | # a test to show speed of computation in the face of fragmentation. 2 | Run 3 | timeit test 1000 10000 4 | There should be no delay between the 4th and 5th outputs of status 5 | and time. The old memory allocator had a significant delay there. 6 | 7 | test is OP M N { 8 | Z := floor (M times random n); 9 | write status; write time; 10 | X gets EACH string Z; 11 | write status; write time; 12 | Y gets cull X; 13 | write status; write time; 14 | X gets 5; 15 | write status; write time; 16 | EACH string Z; 17 | write status; write time; 18 | Y gets 10; 19 | write status; write time; 20 | } 21 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/fuzzyeq.ndf: -------------------------------------------------------------------------------- 1 | # an equality test that considers its arguments equal 2 | if they are numerically equal within relative fuzz. 3 | 4 | fuzzyeq is op a b { 5 | fuzz is 1e-13; 6 | numeric is op a (type a in o 0 0.); 7 | if a = b then 8 | True 9 | elseif atomic a and atomic b then 10 | if numeric a and numeric b then 11 | abs(a - b) <= (fuzz*max abs a b) or (abs(a - b) <= fuzz) 12 | else 13 | a = b 14 | endif 15 | elseif shape a = shape b then 16 | and eachboth fuzzyeq a b 17 | else 18 | False 19 | endif } 20 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/idtests.ndf: -------------------------------------------------------------------------------- 1 | 2 | IF isfault (2 power 32) THEN 3 | write 'Skipping large int tests'; 4 | ELSE 5 | testid 'largintids1' Largeintargs; 6 | testid 'largintids2' Largeintpairargs; 7 | ENDIF; 8 | 9 | testid 'cartids' Allargs 10 | 11 | 12 | testid 'linkids' Allargs 13 | 14 | 15 | testid 'reshapeids' Allargs 16 | 17 | 18 | testid 'reshapeids1' (Binaryargs append 'pickargs') 19 | 20 | 21 | testid 'singleids' Allargs 22 | 23 | 24 | testid 'rowcolids' Allargs 25 | 26 | 27 | testid 'fuseids' Allargs 28 | 29 | 30 | testid 'packids' Allargs 31 | 32 | 33 | testid 'splitblendids' (Binaryargs append 'pickargs') 34 | 35 | 36 | testid 'measureids' Allargs 37 | 38 | 39 | testid 'pickids' Allargs 40 | 41 | 42 | testid 'selectionids' ['pickargs' , 'chooseargs' , 'reachargs'] 43 | 44 | 45 | testid 'selectids1' ['picktriples'] 46 | 47 | 48 | testid 'arithids' Numargs 49 | 50 | testid 'arithids1' Binaryargs 51 | 52 | testid 'logicids' Bitargs 53 | 54 | testid 'logicids1' Binaryargs 55 | 56 | 57 | testid 'compareids' Binaryargs 58 | 59 | 60 | testid 'equalityids' Allargs 61 | 62 | 63 | testid 'cullids' Allargs 64 | 65 | 66 | testid 'seekids' Binaryargs 67 | 68 | 69 | testid 'listids' Allargs 70 | 71 | testid 'listids1' Binaryargs 72 | 73 | testid 'simpleids' Allargs 74 | 75 | testid 'eachids' Allargs 76 | 77 | testid 'eachids1' Binaryargs 78 | 79 | testid 'maxminids' Allargs 80 | 81 | testid 'maxminids1' Binaryargs 82 | 83 | testid 'reverseids' Allargs 84 | 85 | testid 'rotateids' (Binaryargs append 'pickargs') 86 | 87 | testid 'sublistids' Binaryargs 88 | 89 | testid 'exceptids' Binaryargs 90 | 91 | testid 'takedropids' (Binaryargs append 'pickargs') 92 | 93 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/largeintids.ndf: -------------------------------------------------------------------------------- 1 | 2 | 3 | ordered is op A ( 4 | and (front A <= rest A)) 5 | 6 | largeintids1 IS op A { 7 | and ( 8 | (ceiling A = opposite floor opposite A) 9 | (diverse A = (diverse sortup A)) 10 | (sortup cull A = cull sortup A) 11 | (grid A EACHLEFT in (A EACHLEFT find A) sublist A = cull A) 12 | (diverse A = (cull A equal list A)) 13 | (diverse A implies (grid A = (A EACHLEFT find A))) 14 | (ordered sortup A) 15 | ) } 16 | 17 | largeintids2 IS op A B { 18 | and ( 19 | (floor (A - (B * (A quotient B))) faulteq (A mod B)) 20 | (A quotient B faulteq floor (A divide B)) 21 | (A except B = (A EACHLEFT notin B sublist A)) 22 | (A except B = (list A except list B)) 23 | (sortup (A except B) = (sortup A except sortup B)) 24 | ) } 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/limits: -------------------------------------------------------------------------------- 1 | # tests that push the limits of token size for constants and variables 2 | 3 | (and second second second parse scan 'llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll') = l 4 | 5 | 6 | (second second second parse scan '.3333333333333333333333333333333333333333333333333333333333333333333') = reciprocal 3 7 | 8 | (second second second parse scan '.33333333333333333333333333333333333333333333333333333333333333333j0') = reciprocal 3j0 9 | 10 | (second second second parse scan '.0000000000000000000000000000000000000000000000000000000000000001e30') = 1e-34 11 | 12 | (string second second second parse scan '"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA') = toupper 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 13 | 14 | (tally string second second second parse scan '?bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') = 67 15 | 16 | aa:=3;abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr:=aa;5+abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr = 8 17 | 18 | # an example of a multiple line comment 19 | 20 | (%(and second second parse scan 'llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll') = l (second second parse scan '10000000000000000000000000000000000000000000000000000000000000000000') = 1e67 (second second parse scan '.3333333333333333333333333333333333333333333333333333333333333333333') = reciprocal 3 (second second parse scan '.33333333333333333333333333333333333333333333333333333333333333333j0') = reciprocal 3j0 (second second parse scan '.0000000000000000000000000000000000000000000000000000000000000001e30') = 1e-34 (string second second parse scan '"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA') = toupper 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' (tally string second second parse scan '?bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') = 67;) = ??noexpr 21 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/onerand.ndf: -------------------------------------------------------------------------------- 1 | # this file does the testing of randomly generated arrays 2 | # It does not create a log so that large tests can be run without 3 | # eating up disk space. 4 | 5 | loaddefs ‘rtemp.ndf’ l 6 | 7 | noisy := o; 8 | 9 | quiet := l; 10 | 11 | Tries := 0; 12 | 13 | setlogname "rand.log; 14 | set"log; write status; set "nolog; 15 | 16 | 17 | %seed .5; 18 | %Limit := 2000; 19 | 20 | seed .9362837; 21 | %Limit := 5000; 22 | 23 | %seed .314159; 24 | %Limit := 500; 25 | 26 | %seed .31323334; 27 | Limit := 2505; 28 | 29 | set"log; write status; set "nolog; 30 | 31 | settrigger o; 32 | 33 | Starters := random Limit ; 34 | 35 | Spacelost := 0; 36 | 37 | onerandtest 38 | 39 | %restarting 540 550 40 | 41 | set"log; 42 | write status; 43 | write link 'total space lost: ' (string spacelost); 44 | 45 | set "nolog; 46 | 47 | #Bye 48 | 49 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/onetest.ndf: -------------------------------------------------------------------------------- 1 | 2 | 3 | IF isfault (2 power 32) THEN 4 | write 'Skipping large int tests'; 5 | ELSE 6 | testid 'largintids1' Largeintargs; 7 | testid 'largintids2' Largeintpairargs; 8 | ENDIF; 9 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/otherops: -------------------------------------------------------------------------------- 1 | above 2 | appendfile 3 | apply 4 | assign 5 | below 6 | close 7 | deepupdate 8 | defedit 9 | deparse 10 | descan 11 | div 12 | edit 13 | erase 14 | eraserecord 15 | eval 16 | execute 17 | filetally 18 | getdef 19 | getfile 20 | gt 21 | gte 22 | help 23 | higher 24 | host 25 | inv 26 | istruthvalue 27 | library 28 | load 29 | loaddefs 30 | lower 31 | lt 32 | lte 33 | no_op 34 | open 35 | opp 36 | parse 37 | prod 38 | putfile 39 | quiet_fault 40 | read 41 | readarray 42 | readfile 43 | readrecord 44 | readscreen 45 | recip 46 | save 47 | scan 48 | see 49 | seed 50 | set 51 | setcursor 52 | setdeftrace 53 | setformat 54 | setinterrupts 55 | setlogname 56 | setprompt 57 | settrigger 58 | setwidth 59 | symbols 60 | update 61 | updateall 62 | value 63 | write 64 | writearray 65 | writechars 66 | writefile 67 | writerecord 68 | writescreen 69 | * 70 | + 71 | - 72 | / 73 | = 74 | ~= 75 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/pervdefs.ndf: -------------------------------------------------------------------------------- 1 | # file containing transformers that express general operation properities 2 | and tests that validate the property for each operation with that 3 | property. 4 | 5 | 6 | MULTIPERVASIVE IS TR f OP A (f A = EACH f pack A) 7 | 8 | UNARYPERVASIVE IS TR F op A (f A = EACH f A) 9 | 10 | BINARYPERVASIVE IS TR f OP A B (A f B faulteq EACH f (A pack B)) 11 | 12 | #commutative test 13 | 14 | COMMUTATIVE is TR f OP A B ((A f B) = (B f A)) 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/picchk.ndf: -------------------------------------------------------------------------------- 1 | # this file checks the semantics of the picture operations. It assumes 2 | that sketch and display work as expected on atoms, and tests that the pictures 3 | are built up correctly. 4 | 5 | loaddefs "picdefs 6 | 7 | dcheck is equal[diagram,_diagram] 8 | 9 | scheck is equal[sketch,_sketch] 10 | 11 | loaddefs "datagen 12 | 13 | piccheck is op a { 14 | for setting with "nodecor "decor do 15 | set setting; 16 | for i with grid a do 17 | write link 'testing diagram on ' a@i ' with setting ' (string setting); 18 | res := each dcheck execute a@i; 19 | IF not and res THEN 20 | appendfile "pic.out (link 'diagram check failed on ' a@i); 21 | appendfile "pic.out (sketch res); 22 | write 'failed'; 23 | write res; 24 | ENDIF; 25 | write link 'testing sketch on ' a@i; 26 | res := each scheck execute a@i; 27 | IF not and res THEN 28 | appendfile "pic.out (link 'sketch check failed on ' a@i); 29 | appendfile "pic.out (sketch res); 30 | write 'failed'; 31 | write res; 32 | ENDIF; 33 | endfor; 34 | endfor; 35 | } 36 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/pictops: -------------------------------------------------------------------------------- 1 | diagram 2 | display 3 | paste 4 | picture 5 | positions 6 | sketch 7 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/quoted: -------------------------------------------------------------------------------- 1 | # evaluation test for the quoted program construct 2 | 3 | eval !a = a 4 | eval !(a) = a 5 | eval !(a a) = a a 6 | eval !(a f a) = (a f a) 7 | apply !(a f) a = (a f a) 8 | eval !(a T f a) = (a T f a) 9 | apply !(a T f) a = (a T f a) 10 | apply !(T f) (a a) = (a T f a) 11 | eval !(f a) = f a 12 | eval !(f f a) = f f a 13 | apply !(f f) a = f f a 14 | eval !(f T f a) = f T f a 15 | apply !(f T f) a = f T f a 16 | eval !(T a f a) = T a f a 17 | apply !(T a f) a = T a f a 18 | eval !(T f a) = T f a 19 | apply !(T f) a = T f a 20 | eval !(T T f a) = T T f a 21 | apply !(T T f) a = T T f a 22 | eval !([a,a]) = a a 23 | apply !([f,f]) a = [f,f] a 24 | eval !(v gets 5;count 5) = (v gets 5;count 5) 25 | eval !(if l then 2 else 3 endif) = (if l then 2 else 3 endif) 26 | eval !(eval !a) = a 27 | 28 | 29 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/rankbug.ndf: -------------------------------------------------------------------------------- 1 | 2 | # Identity Testing Program. 3 | 4 | # This program drives the testing of the identity given as an 5 | argument string. It is expected to be run by loading 6 | a file like "idtests.ndf" that gives a call to the operation 7 | "idtest" with arguments the description of the id and the list of 8 | names of data sets to which it is to be applied. 9 | 10 | Quiet := l; 11 | 12 | loaddefs "datagen 13 | 14 | loaddefs "testid 15 | 16 | loaddefs "ids 17 | 18 | loaddefs "trdefs 19 | 20 | setlogname "ids.log; set "log; 21 | 22 | loaddefs "check10 l 23 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/rbug.ndf: -------------------------------------------------------------------------------- 1 | set"log 2 | 3 | test1 is (i:=5;repeat i:=i - 1;if i<3 then exit i endif until i<=0 endrepeat) 4 | 5 | test2 is (i:=5;repeat i:=i - 1;if i<3 then i endif until i<=0 endrepeat) 6 | 7 | getdef "test1 8 | 9 | getdef "test2 10 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/recurs: -------------------------------------------------------------------------------- 1 | # evaluation tests that test out various kinds of recursion 2 | 3 | # recursive expression 4 | 5 | cnt is external variable;ex is {NONLOCAL cnt; if cnt = 0 then cnt else cnt := cnt - 1;ex endif};cnt := 5;ex = 0 6 | 7 | # recursive operations 8 | 9 | fact is op n(if n<=0 then 1 else n * fact (n - 1) endif);fact 5 = 120 10 | fact1 is FORK[0<,* [pass,fact1 - [pass,1 first]],1 first];fact1 5 = 120 11 | fib is op n(if n<=2 then 1 else fib (n - 1) + fib (n - 2)endif);fib 10 = 55 12 | fib1 is FORK[2<,sum [fib1 - [pass,1 first],fib1 - [pass,2 first]],1 first];fib1 10 = 55 13 | lftally is FORK [atomic, tally, EACH lftally]; lftally 1 (2 3) = 1 (1 1) 14 | 15 | 16 | # recursive transformers 17 | 18 | LEAF1 is tr f op a(if atomic a then f a else each leaf1 f a endif);leaf1 abs [-1,[-2,[-3,-4]]] = [1,[2,[3,4]]] 19 | LEAF1 is tr f(FORK[atomic,f,each leaf1 f]);leaf1 abs [-1,[-2,[-3,-4]]] = [1,[2,[3,4]]] 20 | NIX is tr f(0 FOLD f);ONCE is tr f (1 FOLD f);LEAF1 is tr f (FORK[atomic NIX f,ONCE f,EACH LEAF1 f] f);LEAF1 abs [-1,[-2,[-3,-4]]] = [1,[2,[3,4]]] 21 | 22 | # difficult transformer recursions from the past 23 | 24 | # first example supplied by Nils Jacobsen 25 | 26 | inn is tr f g op a b{ if valence a <= 2 then inner[f,g] a b else inn[inner[f,g],g] (rows a) b endif}; inn[+,*] (3 2 2 reshape count 12) (3 4) = 132 996 2628 27 | 28 | FORK1 is tr f g h op a(if f a then g a else h a endif); LF1 is tr f (FORK1 [atomic NIX f, ONCE f, EACH LF1 f]); LF1 tally 1 (2 3) = 1 (1 1) 29 | 30 | eachn is tr f op n a(if n = 0 then f a else n - 1 eachn each f a endif); eachn tally 1 (1 (2 3)) = 1 2 31 | 32 | twig1 is tr f op a(if simple a then f a else each twig1 f a endif);twig1 tally 1 (2 3) = 1 2 33 | 34 | dbl is tr f op a{ f1 is f f; if atomic A then f A else each dbl f1 a endif}; dbl 1+ 3 (4 5) = 5 (8 9) 35 | 36 | # The following example used to make the implementation go into 37 | # a loop. It was fixed by handling the closure of a curried 38 | # expression differently. 39 | 40 | curry1 is tr f op a { f1 is (f 5) f; if atomic a then f a else each curry1 f1 a endif}; curry1 1+ 3 (4 5) = (7 4) ((7 ( (8 7) 5))(7((8 7) 6))) 41 | 42 | curry2 is tr f op a{ if atomic a then f a else each curry2 ((f 5) f) a endif};curry2 1+ 3 (4 5) = (7 4) ((7 ( (8 7) 5))(7((8 7) 6))) 43 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/stack.ndf: -------------------------------------------------------------------------------- 1 | #This file tests the depth of Nial recursions that are possible 2 | in a given version. There are two tests: 3 | recur_n recurs until n is reached. 4 | deeprecur recurs until the system fails or recursion is stopped. 5 | 6 | recur_n is op i n { 7 | IF i=n THEN 8 | n 9 | ELSE 10 | recur_n [i + 1,n] 11 | ENDIF 12 | } 13 | 14 | deeprecur is op i { write i; deeprecur (i + 1) } 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/temp.ndf: -------------------------------------------------------------------------------- 1 | # CROSSOVER testing 2 | 3 | foo is OP N M{ 4 | X gets floor (10000 * random N); 5 | Y gets count M * 5 Max N; 6 | res1 := X except Y; 7 | res2 := X oldexcept Y; 8 | res1 = res2 9 | } 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/testid.ndf: -------------------------------------------------------------------------------- 1 | testid is op Idstr _Args_ { 2 | NONLOCAL spacelost; 3 | IDstr := string Idstr; 4 | write link 'starting ' Idstr ; 5 | freespace := first status; 6 | FOR Arg WITH _Args_ DO 7 | { % put in a block so that locals will be freed; 8 | % write link 'trying ' Idstr ' on ' Arg; 9 | Vals gets execute Arg; 10 | if isfault Vals THEN 11 | Msg := link Arg ' evaluated to fault ' (string Vals); 12 | write Msg; 13 | appendfile "ids.out Msg; 14 | else 15 | fn := parse scan Idstr; 16 | for Val with Vals DO 17 | Resa := fn apply Val; 18 | If not Resa THEN 19 | write link Idstr ' failed on arg:'; 20 | write Val; 21 | Msg := link Idstr ' failed on arg:'; 22 | appendfile "ids.out Msg; 23 | appendfile "ids.out (display Val); 24 | endif; 25 | endfor; 26 | endif; 27 | % write link 'completed ' Arg; 28 | }; 29 | ENDFOR; 30 | write link 'finished ' Idstr; 31 | } 32 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/timeit.ndf: -------------------------------------------------------------------------------- 1 | timed is tr f op a{ t gets time;f a;time - t} 2 | 3 | btimed is tr f op a b{ t gets time;a f b;time - t} 4 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/trloop.ndf: -------------------------------------------------------------------------------- 1 | # Specific tests of the transformer mechanisms in the interpreter 2 | 3 | # example supplied by Nils Jacobsen 4 | 5 | inn is tr f g op a b{ 6 | if valence a <= 2 then 7 | inner[f,g] a b 8 | else 9 | inn[inner[f,g],g] (rows a) b 10 | endif} 11 | 12 | a gets 3 2 2 reshape count 12; 13 | 14 | b gets 3 4; 15 | 16 | inn[+,*] a b = 132 996 2628 17 | 18 | 19 | # some tests Mike Jenkins dreamed up to make the 20 | transformer mechanism work hard. 21 | 22 | NIX is tr f (0 FOLD f) 23 | 24 | ONCE IS tr f (1 FOLD f) 25 | 26 | LF is tr f(FORK [atomic NIX f, ONCE f, EACH LF f]) 27 | 28 | LF tally 1 (2 3) = 1 (1 1) 29 | 30 | lftally is FORK [atomic, tally, EACH lftally] 31 | 32 | lftally 1 (2 3) = 1 (1 1) 33 | 34 | FORK1 is tr f g h op a(if f a then g a else h a endif) 35 | 36 | LF1 is tr f(FORK1 [atomic NIX f, ONCE f, EACH LF1 f]) 37 | 38 | LF1 tally 1 (2 3) = 1 (1 1) 39 | 40 | lftally1 is FORK1 [atomic, tally, EACH lftally1] 41 | 42 | lftally1 1 (2 3) = 1 (1 1) 43 | 44 | eachn is tr f op n a(if n = 0 then f a else n - 1 eachn each f a endif) 45 | 46 | eachn tally 1 (1 (2 3)) = 1 2 47 | 48 | twig1 is tr f op a(if simple a then f a else each twig1 f a endif) 49 | 50 | twig1 tally 1 (2 3) = 1 2 51 | 52 | dbl is tr f op a{ f1 is f f; 53 | if atomic A then f A else each dbl f1 a endif} 54 | 55 | dbl 1+ 3 (4 5) = 5 (8 9) 56 | 57 | # The following example used to make the implementation go into 58 | a loop. It was fixed by handling the closure of a curried 59 | expression differently. 60 | 61 | curry1 is tr f op a { f1 is (f 5) f; 62 | if atomic a then f a else each curry1 f1 a endif} 63 | 64 | curry1 1+ 3 (4 5) = (7 4) ((7 ( (8 7) 5))(7((8 7) 6))) 65 | 66 | curry2 is tr f op a{ 67 | if atomic a then f a else each curry2 ((f 5) f) a endif} 68 | 69 | curry2 1+ 3 (4 5) = (7 4) ((7 ( (8 7) 5))(7((8 7) 6))) 70 | 71 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/trs: -------------------------------------------------------------------------------- 1 | accumulate 2 | bycols 3 | byrows 4 | converse 5 | eachboth 6 | eachall 7 | each 8 | eachleft 9 | eachright 10 | fold 11 | fork 12 | grade 13 | inner 14 | iterate 15 | leaf 16 | no_tr 17 | outer 18 | partition 19 | reduce 20 | reducerows 21 | reducecols 22 | sort 23 | team 24 | twig 25 | -------------------------------------------------------------------------------- /BuildNial/testing/v7testing/uniops: -------------------------------------------------------------------------------- 1 | abs 2 | and 3 | arccos 4 | arcsin 5 | arctan 6 | atomic 7 | axes 8 | cart 9 | catenate 10 | ceiling 11 | char 12 | charrep 13 | cols 14 | content 15 | cos 16 | cosh 17 | count 18 | cull 19 | diverse 20 | empty 21 | equal 22 | exp 23 | fault 24 | first 25 | flip 26 | floor 27 | front 28 | grid 29 | inverse 30 | isboolean 31 | ischar 32 | isfault 33 | isinteger 34 | isphrase 35 | isreal 36 | isstring 37 | laminate 38 | last 39 | link 40 | list 41 | ln 42 | log 43 | max 44 | min 45 | mix 46 | not 47 | opposite 48 | or 49 | pack 50 | pass 51 | phrase 52 | post 53 | product 54 | random 55 | reciprocal 56 | rest 57 | reverse 58 | rows 59 | second 60 | shape 61 | simple 62 | sin 63 | single 64 | sinh 65 | solitary 66 | sqrt 67 | string 68 | sum 69 | tally 70 | tan 71 | tanh 72 | tell 73 | third 74 | tolower 75 | tonumber 76 | toupper 77 | transpose 78 | type 79 | unequal 80 | valence 81 | cull 82 | diverse 83 | sortup 84 | gradeup 85 | -------------------------------------------------------------------------------- /BuildNial/tools/CmakeTools/Toolchain-mingw64-Win32.cmake: -------------------------------------------------------------------------------- 1 | # Set the system name for the target operating system 2 | SET(CMAKE_SYSTEM_NAME "Windows") 3 | 4 | # Compilers etc 5 | SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc) 6 | SET(CMAKE_CXX_COMPILER i686-w64-mingw32-gcc) 7 | SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) 8 | 9 | SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /home/johng/mingw/install) 10 | 11 | # Change default behaviour of FIND_XXX() commands 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 14 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 15 | 16 | -------------------------------------------------------------------------------- /BuildNial/tools/CmakeTools/Toolchain-mingw64-Win64.cmake: -------------------------------------------------------------------------------- 1 | # Set the system name for the target operating system 2 | SET(CMAKE_SYSTEM_NAME "Windows") 3 | 4 | # Compilers etc 5 | SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) 6 | SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-gcc) 7 | SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) 8 | 9 | SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /home/johng/mingw/install) 10 | 11 | # Change default behaviour of FIND_XXX() commands 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 14 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 15 | 16 | -------------------------------------------------------------------------------- /NialLogo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/NialLogo.jpg -------------------------------------------------------------------------------- /Nialroot/niallib/add&count.ndf: -------------------------------------------------------------------------------- 1 | # add&count.ndf 2 | 3 | # two versions of a routine to count and add the values one per line in a file. 4 | The first uses a loop and reads one line of the file at a time. 5 | The second uses the power of arrays to read all the data and do the computation. 6 | 7 | add_and_count1 IS OPERATION Filename { 8 | Total Counter := 0. 0 ; 9 | File_num := open Filename "r ; 10 | Record := readfile File_num ; 11 | % As long as the record is not the fault ?eof do the loop expressions ; 12 | WHILE Record ~= ??eof DO 13 | % Add the number obtained by executing string Record to the total; 14 | Total := Total + (execute Record) ; 15 | % Add one to the counter ; 16 | Counter := Counter + 1 ; 17 | % Read the next record ; 18 | Record := readfile File_num ; 19 | ENDWHILE ; 20 | close File_num ; 21 | Counter Total} 22 | 23 | # An alternative way of doing this is as follows: 24 | 25 | add_and_count2 IS OPERATION Filename { 26 | % Read the records of the file and convert each to a number ; 27 | Records := EACH tonumber getfile Filename ; 28 | % Return the tally and the sum of the records ; 29 | [tally,sum] Records } 30 | -------------------------------------------------------------------------------- /Nialroot/niallib/average.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: average A 3 | File: average.ndf 4 | 5 | # This operation calculates the average of the numbers given in an array. 6 | 7 | average IS OPERATION A { 8 | sum A / tally A } 9 | 10 | # Example: 11 | 12 | # average 3 4 5 13 | 4. 14 | -------------------------------------------------------------------------------- /Nialroot/niallib/between.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: between Value Range 3 | File: between.ndf 4 | 5 | # This operation tests whether or not an atomic value is in the interval given 6 | by a pair of values. It can be used on numbers, characters or phrases. If 7 | the argument on the left is an array of values, the result has the same shape 8 | as the argument on the left. 9 | 10 | between IS OPERATION Item Range { 11 | ( Item >= first Range ) and ( Item <= second Range ) } 12 | 13 | # Example: 14 | 15 | # 2 between 0 9 16 | l 17 | -------------------------------------------------------------------------------- /Nialroot/niallib/border.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: border Table Border_item 3 | File: border.ndf 4 | 5 | # This operation constructs a border around a table using a specified value. 6 | 7 | border IS OPERATION Table Value { 8 | Bordrow := second shape Table reshape Value ; 9 | Tblcols := pack link [ Bordrow ] ( rows Table ) [ Bordrow ] ; 10 | Bordcol := shape first Tblcols reshape Value ; 11 | mix pack link [ Bordcol ] Tblcols [ Bordcol ] } 12 | 13 | # Example: 14 | 15 | # border (2 3 reshape 'abcdef') `+ 16 | +++++ 17 | +abc+ 18 | +def+ 19 | +++++ 20 | -------------------------------------------------------------------------------- /Nialroot/niallib/btdiffs: -------------------------------------------------------------------------------- 1 | 208c208 2 | < latent is { 3 | --- 4 | > shortestpath is { 5 | 225a226,229 6 | > Latent is { 7 | > writescreen 'type shortestpath to run a back tracking solution for shortest path' ; 8 | > } 9 | > 10 | -------------------------------------------------------------------------------- /Nialroot/niallib/centertext.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: centertext String Field_width 3 | File: centertext.ndf 4 | 5 | # This operation centers a string of characters within a field of specified 6 | width. 7 | 8 | centertext IS OPERATION Text Width { 9 | Text := string Text ; 10 | Left := Width minus tally Text quotient 2 ; 11 | Width take ( Left reshape ' ' link Text ) } 12 | 13 | # Example: 14 | 15 | # centertext 'TITLE' 80 16 | TITLE 17 | -------------------------------------------------------------------------------- /Nialroot/niallib/count_all.ndf: -------------------------------------------------------------------------------- 1 | # count_all.ndf 2 | 3 | # Count the number of characters, words and line in a file. 4 | 5 | count_all IS OPERATION Filename { 6 | Records := getfile Filename ; 7 | Lines Characters := [tally, sum EACH tally] Records ; 8 | Words := sum (EACH tally ((Records EACHLEFT match ` ) EACHBOTH cut Records)); 9 | Characters Words Lines } 10 | 11 | #Example: 12 | count_all (Nialroot link '/niallib/average.ndf') 13 | 189 38 13 14 | 15 | -------------------------------------------------------------------------------- /Nialroot/niallib/cuttext.ndf: -------------------------------------------------------------------------------- 1 | # cuttext.ndf 2 | 3 | # a routine to cut text into lines of equal length broken on word boundaries. 4 | 5 | cuttext IS OPERATION Text Width { 6 | T := '' ; 7 | WHILE tally Text > Width DO 8 | Where := findall ` Text ; 9 | IF not empty Where THEN 10 | Last_blank := Where@(o find (Width > Where) - 1 max 0); 11 | T := T append ( Width take (Last_blank take Text) ) ; 12 | Text := Last_blank + 1 drop Text ; 13 | ELSE 14 | T := fault '?Width too small'; 15 | Text := ''; 16 | ENDIF; 17 | ENDWHILE ; 18 | IF tally Text > 0 THEN 19 | T := T append ( Width take Text ) ; 20 | ENDIF ; 21 | T } 22 | 23 | # Example 24 | 25 | # 26 | Txt := 'Now is the time for all good men to come to the aid of the party.' ; 27 | 28 | # 29 | cuttext txt 18 30 | +------------------+------------------+------------------+------------------+ 31 | |Now is the time |for all good men |to come to the |aid of the party. | 32 | +------------------+------------------+------------------+------------------+ 33 | 34 | -------------------------------------------------------------------------------- /Nialroot/niallib/deleteby.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: deleteall Array Value 3 | Transformer: DELETEBY Predicate Array 4 | File: deleteby.ndf 5 | 6 | # DELETEBY deletes all items from the given array that satisfy the predicate. 7 | The result is a list. 8 | deleteall uses DELETEBY to delete all occurrences 9 | of a value in an array. It also returns a list. 10 | 11 | DELETEBY IS TRANSFORMER f ( sublist [ not EACH f , pass ] ) 12 | 13 | deleteall IS OPERATION Array Value { 14 | DELETEBY Value = Array } 15 | 16 | # Examples: 17 | 18 | # DELETEBY (2=) (3 2 1 4 2) 19 | 3 1 4 20 | DELETEBY (`a=) 'a fat cat sat' 21 | ft ct st 22 | DELETEBY empty 'abc' '' (2 3 4) Null 5 23 | +---+-----+-+ 24 | |abc|2 3 4|5| 25 | +---+-----+-+ 26 | DELETEBY (3 >) count 5 27 | 3 4 5 28 | deleteall (30 reshape count 5) 3 29 | 1 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 30 | 31 | # When the predicate is (3 >), for example, the items from count 5 that are 32 | deleted are the ones less than 3. Thus, "DELETEBY (3 >) count 5" returns 3 4 5. 33 | -------------------------------------------------------------------------------- /Nialroot/niallib/diagonal.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: diagonal Array 3 | File: diagonal.ndf 4 | 5 | # This operation returns the diagonal of its array argument. 6 | 7 | diagonal IS OPERATION Array { 8 | solitary tell valence Array fuse Array } 9 | 10 | # Examples: 11 | 12 | # diagonal (2 2 reshape tell 4) 13 | 0 3 14 | 15 | # A := 3 3 3 reshape tell 27 16 | 0 1 2 9 10 11 18 19 20 17 | 3 4 5 12 13 14 21 22 23 18 | 6 7 8 15 16 17 24 25 26 19 | 20 | # diagonal A 21 | 0 13 26 22 | -------------------------------------------------------------------------------- /Nialroot/niallib/diffs.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: diffs Number_list 3 | File: diffs.ndf 4 | 5 | # Diffs returns the differences between adjacent items of a number list. 6 | 7 | diffs IS OPERATION Numbers { 8 | rest Numbers - front Numbers } 9 | 10 | # Example: 11 | 12 | # diffs 1 3 8 13 | 2 5 14 | -------------------------------------------------------------------------------- /Nialroot/niallib/dropfront.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: dropfront Item A 3 | Operation: dropback Item A 4 | Operation: dropboth Item A 5 | File: dropfront.ndf 6 | 7 | # dropfront drops leading occurrences of an item from an array. 8 | If the array is a multivalent one, the result is a list. 9 | dropback drops all trailing occurrences of an item from an array. 10 | dropboth comines the actions to drop leading and trailing items. 11 | 12 | dropfront IS OPERATION Item A { 13 | A := list A; 14 | False find (Item EACHRIGHT = A) drop A } 15 | 16 | dropback IS OPERATION Item A { 17 | reverse (Item dropfront reverse A ) } 18 | 19 | dropboth IS OPERATION Item A { 20 | dropback Item (dropfront Item A) } 21 | 22 | # Examples: 23 | 24 | # dropfront `. '... and so on ...' 25 | and so on ... 26 | dropback `. '... and so on ...' 27 | ... and so on 28 | dropboth `. '... and so on ...' 29 | and so on 30 | -------------------------------------------------------------------------------- /Nialroot/niallib/dropindex.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: dropindex A Indices 3 | File: dropinde.ndf 4 | 5 | # This operation drops items with the specified indices from the given 6 | array A. 7 | 8 | dropindex IS OPERATION A Indices { 9 | grid A except Indices choose A } 10 | 11 | # Example: 12 | 13 | # 'abcdef' dropindex 0 2 4 14 | bdf 15 | 16 | # tell 3 4 dropindex [0 0,1 1,2 2] 17 | +---+---+---+---+---+---+---+---+---+ 18 | |0 1|0 2|0 3|1 0|1 2|1 3|2 0|2 1|2 3| 19 | +---+---+---+---+---+---+---+---+---+ 20 | -------------------------------------------------------------------------------- /Nialroot/niallib/filelist.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operations: filelist Path Pattern 3 | filelist1 Patttern 4 | 5 | # 6 | File: filelist.ndf 7 | 8 | # Two utility operations to return a list of files given a pattern. 9 | 10 | # fileist Path Pattern 11 | The Path gives path from the user's home directory to 12 | the directory containing the files to be selected. 13 | The Pattern must be an appropriate pattern for 'ls'. 14 | The result is the list of filenames as strings. 15 | 16 | # filelist Pattern 17 | THe files are selected from the current directory unless the Pattern itself 18 | includes a path. 19 | The result is a list of strings with the filenames preceded by the path 20 | provided in the Pattern. 21 | 22 | library "newhost 23 | 24 | filelist IS OPERATION Path Pattern { 25 | Cmd := link '\ls -da ' Path Os_Path_Separator ( string Pattern ); 26 | Nms := newhost Cmd; 27 | IF not empty Nms THEN 28 | last (first OS_Path_Separator findall (first Nms)+1) EACHRIGHT drop Nms 29 | ELSE 30 | Nms 31 | ENDIF 32 | } 33 | 34 | filelist1 IS OPERATION Pattern { 35 | newhost ( link '\ls -da ' ( string Pattern ) ) 36 | } 37 | 38 | 39 | #Examples 40 | 41 | # 42 | 'QNial7/niallib' filelist '*.ndf' 43 | 44 | # 45 | filelist1 '*' 46 | 47 | # 48 | filelist1 'QNial7/niallib/*.ndf' 49 | -------------------------------------------------------------------------------- /Nialroot/niallib/findby.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Transformer: findby Predicate Array 3 | File: findby.ndf 4 | 5 | # Findby is a transformer that returns the addresses of items of a given array 6 | which satisfy the predicate. 7 | 8 | FINDBY IS TRANSFORMER f ( sublist [ EACH f , grid ] ) 9 | 10 | # Examples: 11 | 12 | # FINDBY atomic (2 (3 4) 5) 13 | 0 2 14 | FINDBY ("dog =) ("cat "dog "horse) 15 | 1 16 | -------------------------------------------------------------------------------- /Nialroot/niallib/finddefs.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: finddefs Directory Report 3 | File: finddefs.ndf 4 | 5 | 6 | # 7 | Finddefs looks for definition files (*.ndf) and documents the defined names 8 | in each such file in a given directory. Only the top level definitions are found. 9 | Local definitions within a block are not documented. The operation returns a list 10 | of pairs: the first item of each pair is a definition file name, the second is the 11 | list of the defined names within that file. 12 | 13 | 14 | 15 | library "filelist 16 | 17 | 18 | finddefs IS OPERATION Dir { 19 | Dir := string Dir ; 20 | Names := filelist1 link Dir Os_Path_Separator '*.ndf'; 21 | Entries := Null; 22 | FOR File WITH Names DO 23 | % Get the lines of the file; 24 | Lines := getfile File ; 25 | % Find the records that contain IS as the second item ; 26 | Defn_names := Null ; 27 | For Line WITH Lines DO 28 | Words := ` match Line cut Line ; 29 | IF tally Words >= 2 THEN 30 | IF toupper second Words = 'IS' THEN 31 | Defn_names := Defn_names append first Words ; 32 | ENDIF ; 33 | ENDIF ; 34 | ENDFOR ; 35 | Entries := Entries append File Defn_names ; 36 | ENDFOR ; 37 | Entries } 38 | 39 | 40 | 41 | # Example: 42 | 43 | # finddefs './niallib' 44 | -------------------------------------------------------------------------------- /Nialroot/niallib/findpath.ndf: -------------------------------------------------------------------------------- 1 | # 2 | File: findpath.ndf 3 | Operation: findpaths Item Array 4 | 5 | # This operation returns a list of the paths to an item in the given array. 6 | 7 | findpaths IS OPERATION Item Array { 8 | findpath2 IS OPERATION Item Array Pathsofar { 9 | IF Array = Item THEN 10 | solitary Pathsofar 11 | ELSEIF atomic Array THEN 12 | Null 13 | ELSE 14 | link EACHALL findpath2 ( single Item ) Array ( Pathsofar EACHRIGHT 15 | append grid Array ) 16 | ENDIF } ; 17 | findpath2 Item Array Null } 18 | 19 | findpath IS first findpaths 20 | 21 | 22 | # EXAMPLES: 23 | A := 0 2 ( 1 2 ( 2 2 ) ) 24 | +-+-+---------+ 25 | |0|2|+-+-+---+| 26 | | | ||1|2|2 2|| 27 | | | |+-+-+---+| 28 | +-+-+---------+ 29 | findpaths 2 A 30 | +-+---+-----+-----+ 31 | |1|2 1|2 2 0|2 2 1| 32 | +-+---+-----+-----+ 33 | B := 2 3 reshape EACH tell 6 34 | +-----------+-----------+-----------+ 35 | |0 1 2 3 4 5|0 1 2 3 4 5|0 1 2 3 4 5| 36 | +-----------+-----------+-----------+ 37 | |0 1 2 3 4 5|0 1 2 3 4 5|0 1 2 3 4 5| 38 | +-----------+-----------+-----------+ 39 | findpaths 0 B 40 | +-------+-------+-------+-------+-------+-------+ 41 | |+---+-+|+---+-+|+---+-+|+---+-+|+---+-+|+---+-+| 42 | ||0 0|0|||0 1|0|||0 2|0|||1 0|0|||1 1|0|||1 2|0|| 43 | |+---+-+|+---+-+|+---+-+|+---+-+|+---+-+|+---+-+| 44 | +-------+-------+-------+-------+-------+-------+ 45 | -------------------------------------------------------------------------------- /Nialroot/niallib/findstring.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operations: findstring Substr Str 3 | findstrings Substr Str 4 | File: findstring.ndf 5 | 6 | # Findstring is an operation that compares two strings to see if one is 7 | contained in the other. Substr is a string. If Substr is in Str, True 8 | is returned. 9 | 10 | findstring IS OPERATION Substr Str { 11 | Position := first Substr findall Str ; 12 | Substr in ( tally Substr EACHRIGHT take ( Position EACHLEFT drop Str ) ) } 13 | 14 | # Findstrings is an operation that compares a group of strings to see if any 15 | of them is contained in another string. Substrs is a list of strings. If any 16 | string in Substrs is in Str, True is returned. 17 | 18 | findstrings IS OPERATION Substrs Str { 19 | or (Substrs EACHLEFT findstring Str) } 20 | 21 | 22 | # Example: 23 | # 'the' findstring 'Is that their cat?' 24 | l 25 | 26 | 27 | # ['the','and'] EACHRIGHT findstrings ['There is a way','and you have','it'] 28 | olo 29 | 30 | -------------------------------------------------------------------------------- /Nialroot/niallib/frequency.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: frequency Values A 3 | File: frequenc.ndf 4 | 5 | # This operation counts the number of occurrences in A of each value in 6 | Values. 7 | 8 | frequency IS OPERATION Values A { 9 | EACH sum ( Values EACHLEFT EACHRIGHT = A ) } 10 | 11 | # Example: 12 | 13 | # frequency 'abc' 'The cat sat on the baseball bat' 14 | 5 3 1 15 | -------------------------------------------------------------------------------- /Nialroot/niallib/fuzzyeq.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: fuzzyeq A B 3 | File: fuzzyeq.ndf 4 | 5 | # Fuzzyeq tests the equality of two arrays. It is useful for testing the 6 | equality of real numbers that differ by a small amount in their internal 7 | representations. 8 | 9 | fuzzyeq IS OPERATION A B { 10 | numeric IS OPERATION N { 11 | type N in o 0 0. } ; 12 | Fuzz := 1.e-13 ; 13 | % Test for exact equality; 14 | IF A = B THEN 15 | True 16 | ELSEIF atomic A and atomic B THEN 17 | % if both are numeric atoms then do the fuzzy test; 18 | IF numeric A and numeric B THEN 19 | % Return true if difference <= 1.e-13 in relative absolute value ; 20 | abs ( A - B ) <= ( Fuzz * abs A ) 21 | ELSE 22 | % Must be different atoms; 23 | False 24 | ENDIF 25 | ELSEIF shape A = shape B THEN 26 | % If A and B are non-atomic and have the same shape; 27 | and EACHBOTH fuzzyeq A B 28 | ELSE 29 | False 30 | ENDIF } 31 | 32 | # Example: 33 | 34 | # sqrt 2. power 2 fuzzyeq 2. 35 | l 36 | -------------------------------------------------------------------------------- /Nialroot/niallib/gcd.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: gcd M N 3 | File: gcd.ndf 4 | 5 | # This operation finds the greatest common divisor of two integers. 6 | 7 | gcd IS OPERATION M N { 8 | % M and N must be positive integers ; 9 | IF or ( type M N ~= 0 0 ) ( M <= 0 ) ( N <= 0 ) THEN 10 | fault '?invalid argument to gcd. Must be a positive integer.' 11 | ELSE 12 | WHILE M ~= 0 DO 13 | G := M ; 14 | M := N mod M ; 15 | N := G ; 16 | ENDWHILE ; 17 | G 18 | ENDIF } 19 | 20 | # Example: 21 | 22 | # gcd 48 72 23 | 24 24 | -------------------------------------------------------------------------------- /Nialroot/niallib/insert.ndf: -------------------------------------------------------------------------------- 1 | # 2 | File: insert.ndf 3 | Operation: inbefore Values List Index 4 | Operation: inafter Values List Index 5 | Operation: inserthere Values List Indices 6 | Operation: ininterval Values List Interval_width 7 | 8 | # This file contains insertion operations. 9 | Inbefore places the list of values before the item with a specified index in 10 | the given list. 11 | . 12 | Inafter places the list of values after the item with a specified index in 13 | the given list. 14 | . 15 | Inserthere places the list of values after each of the items of List having 16 | the indices specified in Indexlist. 17 | . 18 | Ininterval places the list of values after each interval of a list of a given 19 | width. 20 | 21 | inafter IS OPERATION Values Lst Index { 22 | link ( Index + 1 take Lst ) Values ( Index + 1 drop Lst ) } 23 | 24 | inbefore IS OPERATION Values Lst Index { 25 | link ( Index take Lst ) Values ( Index drop Lst ) } 26 | 27 | inserthere IS OPERATION Values Lst Indexlist { 28 | Frontparts := 0 hitch front Indexlist EACHBOTH drop ( Indexlist EACHLEFT 29 | take Lst ) ; 30 | Lastpart := last Indexlist drop Lst ; 31 | link ( link ( Frontparts EACHLEFT link Values ) ) Lastpart } 32 | 33 | ininterval IS OPERATION Values Lst Interval { 34 | Indexlist := Interval * count floor ( tally Lst / Interval ) ; 35 | inserthere Values Lst Indexlist } 36 | 37 | # Examples: 38 | 39 | # inbefore (2 3) (1 4 5) 1 40 | 1 2 3 4 5 41 | 42 | # inafter 'bad ' 'The cat.' 3 43 | The bad cat. 44 | 45 | # inserthere ' - ' 'hellooutthere' (5 8) 46 | hello - out - there 47 | 48 | # ininterval ' - ' 'aabbccddee' 2 49 | aa - bb - cc - dd - ee - 50 | -------------------------------------------------------------------------------- /Nialroot/niallib/intersect.ndf: -------------------------------------------------------------------------------- 1 | # intersect.ndf 2 | 3 | 4 | intersect IS OPERATION A { 5 | IF empty A THEN 6 | Null 7 | ELSE 8 | EACH and ( first A EACHLEFT EACHRIGHT in A ) sublist first A 9 | ENDIF } 10 | 11 | #Example: 12 | Friends := "Mary "Ludwig "Hercule "Tom "Sarah ; 13 | Pals:= "Jack "Tony "Rick "Tom "Kalev; 14 | intersect Friends Pals 15 | Tom -------------------------------------------------------------------------------- /Nialroot/niallib/labeltable.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: labeltable Corner Rowlabels Collabels Table 3 | Operation: totaltable Corner Rowlabels Collabels Table 4 | File: labeltab.ndf 5 | 6 | # Labeltable labels Table with the corner label in the upper left corner, the 7 | column labels at the top, and the row labels on the left side. Totaltable 8 | adds an extra row and column showing totals of each column and row. 9 | 10 | labeltable IS OPERATION Corner Rowlabel Columnlabel Table { 11 | % Combine the corner label with the column labels for first line ; 12 | Firstrow := Corner hitch Columnlabel ; 13 | % Hitch the row labels to the rows of the table ; 14 | Labelledrows := Rowlabel EACHBOTH hitch rows Table ; 15 | % Hitch the first row of labels to the labelled rows and mix them ; 16 | mix ( Firstrow hitch Labelledrows ) } 17 | 18 | totaltable IS OPERATION Corner Rowlabel Columnlabel Table { 19 | mix ( link Corner Columnlabel "Total hitch ( Rowlabel EACHBOTH link 20 | ( rows Table EACHBOTH link ( EACH sum rows Table ) ) ) append ( link "Total 21 | ( sum rows Table ) ( sum Table ) ) ) } 22 | 23 | # Examples: 24 | 25 | # X := count 3 ; 26 | labeltable "TIMES X X (X OUTER times X) 27 | TIMES 1 2 3 28 | 1 1 2 3 29 | 2 2 4 6 30 | 3 3 6 9 31 | 32 | # Y gets 3 3 reshape 15 3 27 -4 56 27 18 24 -3; 33 | totaltable "Y X X Y 34 | Y 1 2 3 Total 35 | 1 15 3 27 45 36 | 2 -4 56 27 79 37 | 3 18 24 -3 39 38 | Total 29 83 51 163 39 | -------------------------------------------------------------------------------- /Nialroot/niallib/median.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: median Numbers 3 | File: median.ndf 4 | 5 | # Median returns the median in a given list of numbers. 6 | 7 | median IS OPERATION Numbers { 8 | tally Numbers quotient 2 pick ( SORT <= Numbers ) } 9 | 10 | # Example: 11 | 12 | # median 5 3 1 4 2 13 | 3 14 | -------------------------------------------------------------------------------- /Nialroot/niallib/memspaces.ndf: -------------------------------------------------------------------------------- 1 | # memory spaces 2 | # ------------- 3 | # 4 | # Nial memory spaces are a way to connect two Nial processes 5 | # via shared memory or connect Nial to another system. 6 | # 7 | 8 | # Types of Nial objects 9 | 10 | msp_inttype := 1; 11 | msp_booltype := 2; 12 | msp_chartype := 3; 13 | msp_realtype := 4; 14 | 15 | 16 | # The following are used to control how the memory 17 | # space is accessed. By default the access is 18 | # shared and read/write. The value is a sum of the 19 | # following 20 | 21 | msp_private := 1; 22 | msp_prot_read := 2; 23 | 24 | 25 | # The following values are for flags in msp_shm_open 26 | 27 | msp_shm_readonly := 1; 28 | msp_shm_create := 2; 29 | msp_shm_excl := 4; 30 | 31 | # The following are mode bits as per file open 32 | 33 | msp_other_exec := 1; 34 | msp_other_write := 2; 35 | msp_other_read := 4; 36 | msp_other_all := msp_other_read+msp_other_write+msp_other_exec; 37 | 38 | msp_group_exec := 1*8; 39 | msp_group_write := 2*8; 40 | msp_group_read := 4*8; 41 | msp_group_all := msp_group_read+msp_group_write+msp_group_exec; 42 | 43 | msp_user_exec := 1*64; 44 | msp_user_write := 2*64; 45 | msp_user_read := 4*64; 46 | msp_user_all := msp_user_read+msp_user_write+msp_user_exec; 47 | 48 | 49 | 50 | # Sizes of basic types 51 | 52 | msp_intsize := msp_msize msp_inttype 1; 53 | msp_realsize := msp_msize msp_realtype 1; 54 | 55 | 56 | # Calculate the word size of the number 57 | 58 | msp_wsize is op num { 59 | floor num/msp_intsize} 60 | 61 | 62 | -------------------------------------------------------------------------------- /Nialroot/niallib/money.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: money Number [Minimum field width] 3 | File: money.ndf 4 | 5 | # Money returns a string with the input number formatted into dollars and cents. 6 | The optional second argument specifies the minimum length of the string. 7 | Negative numbers are returned with enclosing parenthesis. An invalid 8 | argument, or one with absolute value greater than 1,000,000,000,000 returns 9 | the fault ?money. 10 | 11 | money IS OPERATION Amount { 12 | Moneysign Moneydecimal Moneyseparator := '$.,' ; 13 | IF tally Amount = 2 THEN 14 | Amt Size := Amount ; 15 | ELSE 16 | Amt Size := Amount 0 ; 17 | ENDIF ; 18 | IF ( isinteger Amt or isreal Amt ) and ( abs Amt < 1.e13 ) THEN 19 | Mode := setformat '%15.2f' ; 20 | Digits := link sketch ( abs Amt * 1. ) ; 21 | Result := Moneydecimal hitch ( -2 take Digits ) ; 22 | Dollars := -3 drop Digits ; 23 | Dollars := not ( Dollars match ` ) sublist Dollars ; 24 | WHILE tally Dollars > 3 DO 25 | Result := link Moneyseparator ( -3 take Dollars ) Result ; 26 | Dollars := -3 drop Dollars ; 27 | ENDWHILE ; 28 | Result := link Moneysign Dollars Result ; 29 | IF Amt < 0. THEN 30 | Result := link '(' Result ')' ; 31 | ENDIF ; 32 | IF ( tally Result < Size ) THEN 33 | Result := Size - tally Result reshape ' ' link Result ; 34 | ENDIF ; 35 | setformat Mode ; 36 | Result 37 | ELSE 38 | fault '?money' 39 | ENDIF } 40 | 41 | # Examples: 42 | 43 | # (4 dollars, minimum field width of 10) 44 | money 4 10 45 | $4.00 46 | 47 | # money -49999.98 48 | ($49,999.98) 49 | -------------------------------------------------------------------------------- /Nialroot/niallib/moving_average.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation moving_average N Data 3 | 4 | # 5 | The moving average of length N for an array of data is computed by the 6 | following operation: 7 | 8 | moving_average IS OPERATION N Data { 9 | Indicies := tell (tally Data - N + 1) EACHLEFT + tell N; 10 | Groups := Indicies EACHLEFT choose Data; 11 | EACH sum Groups / N } 12 | 13 | # Examples 14 | 2 moving_average 3 4 5 6 7 8 15 | 3.5 4.5 5.5 6.5 7.5 16 | 17 | # 18 | moving_average [2,3 4 5 6 7 8] 19 | 3.5 4.5 5.5 6.5 7.5 20 | 21 | -------------------------------------------------------------------------------- /Nialroot/niallib/newhost.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: newhost Command 3 | File: newhost.ndf 4 | 5 | # This is an alternative for the operation host. 6 | # The difference is that the 7 | # results of the command are returned as an array of 8 | # strings. It uses pipes and is efficient. 9 | 10 | # The result is a list of the lines produced by the command. 11 | If you wish them to be displayed use: 12 | ITERATE write newhost Cmd 13 | 14 | 15 | newhost IS OPERATION Cmd { 16 | Svt := settrigger o; 17 | Fh := open Cmd 'pr' ; 18 | IF not isfault Fh THEN 19 | Res := Null ; 20 | WHILE not isfault ( Line := readfile Fh ) DO 21 | Res := Res append Line ; 22 | ENDWHILE ; 23 | close Fh ; 24 | settrigger Svt ; 25 | Res 26 | ELSE 27 | settrigger Svt ; 28 | fault ( link '?Failed to open pipe to: ' Cmd ) 29 | ENDIF 30 | } 31 | 32 | # example that displays the Nial definition files in the current directory 33 | newhost 'ls *.ndf' 34 | 35 | -------------------------------------------------------------------------------- /Nialroot/niallib/nstreams.ndf: -------------------------------------------------------------------------------- 1 | # 2 | # Nial streams module 3 | # 4 | # Nial streams are an extensible binary buffering mechanism that can 5 | # be used for encoding and decoding Nial data. They can also be connected 6 | # to file descriptors belonging to pipes, sockets and files etc. 7 | # 8 | 9 | # 10 | # Types of streams 11 | # 12 | 13 | NIO_INTERNAL := 0; 14 | NIO_EXTERNAL := 1; 15 | 16 | 17 | # 18 | # Status values for streams 19 | # 20 | 21 | NIO_NORMAL := 0; 22 | NIO_EOF := -1; 23 | 24 | 25 | # When specifying the limit values for reading 26 | 27 | IOS_NOLIMIT := -1; 28 | 29 | 30 | # 31 | # Special waiting time values. 32 | # 33 | 34 | IOS_NO_WAIT := 0; 35 | IOS_WAIT_INDEFINITELY := -1; 36 | 37 | 38 | # ----------------- Extensions --------------- 39 | 40 | nio_flush IS OPERATION S { 41 | Count := nio_count S ; 42 | WHILE 0 ~= nio_count S DO 43 | nio_write_stream S Ios_wait_indefinitely ; 44 | ENDWHILE ; 45 | Count } 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Nialroot/niallib/reflect.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: reflect Array 3 | File: reflect.ndf 4 | 5 | # Reflect a given table along the vertical axis. 6 | 7 | reflect IS mix ( EACH reverse rows ) 8 | 9 | # Example: 10 | 11 | # A := 2 3 reshape 'abcdef' 12 | abc 13 | def 14 | 15 | # A (reflect A) 16 | +---+---+ 17 | |abc|cba| 18 | |def|fed| 19 | +---+---+ 20 | -------------------------------------------------------------------------------- /Nialroot/niallib/replace.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Transformer: replace Predicate Array Value 3 | File: replace.ndf 4 | 5 | # The replace transformer replaces the items in the given array that satisfy 6 | the predicate by the given value. 7 | 8 | REPLACE IS TRANSFORMER test 9 | OPERATION Array Value { 10 | ( single Value ) ( EACH test Array sublist grid Array ) placeall Array } 11 | 12 | # Examples: 13 | 14 | # REPLACE (` =) 'The cat and the mouse' `* 15 | The*cat*and*the*mouse 16 | 17 | # REPLACE isfault (3 ??error 4) "**** 18 | 3 **** 4 19 | -------------------------------------------------------------------------------- /Nialroot/niallib/reverse_polish.ndf: -------------------------------------------------------------------------------- 1 | # reverse_polish.ndf 2 | 3 | # Simulates a calculator which takes input in reverse polish notation. 4 | 5 | Stack IS EXTERNAL VARIABLE 6 | 7 | push IS OPERATION Item { 8 | NONLOCAL Stack ; 9 | Stack := link Item Stack ; } 10 | 11 | pop IS { 12 | NONLOCAL Stack ; 13 | Item Stack := [first,rest] Stack ; 14 | Item } 15 | 16 | reverse_polish IS OPERATION Line { 17 | NONLOCAL Stack ; 18 | Svtrigger := settrigger o; 19 | Stack := Null ; 20 | Items := ` match Line cut Line ; 21 | FOR Item WITH Items DO 22 | IF first Item in '+-*/' THEN 23 | write link 'Operation: ' Item ; 24 | ENDIF ; 25 | CASE first Item FROM 26 | `+ : push sum Pop Pop ; END 27 | `- : push sum ( opp Pop ) Pop ; END 28 | `* : push prod Pop Pop ; END 29 | `/ : push prod ( recip Pop ) Pop ; END 30 | ELSE 31 | push ( execute Item ) ; 32 | ENDCASE ; 33 | write link ( phrase ' Stack: ' ) Stack ; 34 | ENDFOR ; 35 | settrigger Svtrigger; 36 | first Stack } 37 | 38 | #Examples: 39 | setformat '%6.2f' ; 40 | reverse_polish '3.14 2. * 7.6 3.2 - - 6.1 2.2 - *' 41 | Stack: 3.14 42 | Stack: 2.00 3.14 43 | Operation: * 44 | Stack: 6.28 45 | Stack: 7.60 6.28 46 | Stack: 3.20 7.60 6.28 47 | Operation: - 48 | Stack: 4.40 6.28 49 | Operation: - 50 | Stack: 1.88 51 | Stack: 6.10 1.88 52 | Stack: 2.20 6.10 1.88 53 | Operation: - 54 | Stack: 3.90 1.88 55 | Operation: * 56 | Stack: 7.33 57 | 7.33 58 | 59 | # 60 | reverse_polish '32.5 0. / 7. 9. * +' 61 | Stack: 32.50 62 | Stack: 0.00 32.50 63 | Operation: / 64 | Stack: ?div 65 | Stack: 7.00 ?div 66 | Stack: 9.00 7.00 ?div 67 | Operation: * 68 | Stack: 63.00 ?div 69 | Operation: + 70 | Stack: ?div 71 | ?div 72 | 73 | # 74 | reverse_polish '32.5 0.1 / 7. 9. / +' 75 | Stack: 32.50 76 | Stack: 0.10 32.50 77 | Operation: / 78 | Stack: 325.00 79 | Stack: 7.00 325.00 80 | Stack: 9.00 7.00 325.00 81 | Operation: / 82 | Stack: 0.78 325.00 83 | Operation: + 84 | Stack: 325.78 85 | 325.78 86 | -------------------------------------------------------------------------------- /Nialroot/niallib/romberg.ndf: -------------------------------------------------------------------------------- 1 | # INTEGRATE f A B Eps 2 | 3 | # Find the integral of the function f over the interval A B using the 4 | technique known as Romberg Integration. 5 | 6 | # The stopping criteria Eps guarantees the relative accuracy of the 7 | answer. Normally the result is considerably more accurate. The 8 | suggested value for Eps is 1e-6. 9 | 10 | # The function can be edited to change the internal comments to 11 | write statements that will display the intermediate results. 12 | This version of Integrate works well on smooth functions. 13 | 14 | # EXAMPLE: INTEGRATE sin 0 Pi 1e-6 15 | 16 | INTEGRATE IS TRANSFORMER f 17 | OPERATION A B Eps { 18 | N := 4 ; 19 | Endpoints := A B ; 20 | Endpointsum := sum EACH f Endpoints ; 21 | H := B - A / N ; 22 | Internalpoints := A + H times count ( N - 1 ) ; 23 | Internalsum := 2 * sum EACH f Internalpoints ; 24 | Trap := sum Internalsum Endpointsum * H / 2.0 ; 25 | K := 0 ; 26 | R_table := 10 10 reshape 0. ; 27 | R_table @ [ 0 , 0 ] := Trap ; 28 | FOR K WITH count 9 DO 29 | H := H / 2.0 ; 30 | Newpoints := A + ( H times ( 1 + ( 2 * tell N ) ) ) ; 31 | N := N * 2 ; 32 | Internalsum := Internalsum + ( 2 * sum EACH f Newpoints ) ; 33 | Trap := sum Internalsum Endpointsum * H / 2.0 ; 34 | R_table @ [ K , 0 ] := Trap ; 35 | FOR J WITH count K DO 36 | P := 4.0 power J - 1.0 ; 37 | R_table @ [ K - J , J ] := R_table @ [ K - J + 1 , J - 1 38 | ] + ( R_table @ [ K - J + 1 , J - 1 ] - R_table @ [ K - 39 | J , J - 1 ] / P ) ; 40 | ENDFOR ; 41 | %writescreen ' Romberg table '; 42 | %write ((K+1)(K+1)take R_table); 43 | T1 := R_table @ [ 1 , K - 1 ] ; 44 | T2 := R_table @ [ 0 , K ] ; 45 | IF abs ( T2 - T1 ) <= ( abs ( T2 ) * Eps ) THEN 46 | EXIT T2 ; 47 | ENDIF ; 48 | ENDFOR ; 49 | T2 } 50 | 51 |  -------------------------------------------------------------------------------- /Nialroot/niallib/round.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: round Number 3 | File: round.ndf 4 | 5 | # This operation rounds a real to an integer. 6 | 7 | round IS OPERATION A { 8 | floor ( A + .5 ) } 9 | 10 | # Examples: 11 | 12 | # 13 | round 3.6 14 | 4 15 | round -1.66667 16 | -2 17 | round 3.3 3.4 3.49 3.5 3.51 3.99 18 | 3 3 3 4 4 4 -------------------------------------------------------------------------------- /Nialroot/niallib/select.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: select Paths A 3 | File: select.ndf 4 | 5 | # This operation selects arrays nested within A using the paths given by Paths. 6 | The result has the same shape as Paths. 7 | 8 | select IS OPERATION Paths A { 9 | Paths EACHLEFT reach A } 10 | 11 | # Example: 12 | 13 | # [1 2,1] [1 1] select count 4 5 14 | +-+---+ 15 | |3|2 2| 16 | +-+---+ 17 | -------------------------------------------------------------------------------- /Nialroot/niallib/shiftpad.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: shiftpad Position Array Pad_item 3 | File: shiftpad.ndf 4 | 5 | # Rotate items a specified number of positions to the left, replacing emptied 6 | positions with a specified item. The result is the shape of Array. 7 | 8 | shiftpad IS OPERATION Position Array Pad { 9 | shape Array reshape ( opposite tally Array take 10 | ( Array link ( Position reshape single Pad ) ) ) } 11 | 12 | # Examples: 13 | 14 | # shiftpad 3 'abcdef' `* 15 | def*** 16 | 17 | # shiftpad 1 (1 2 3) 0 18 | 2 3 0 19 | 20 | # 21 | shiftpad 3 (count 4 5) (0 0) 22 | +---+---+---+---+---+ 23 | |1 4|1 5|2 1|2 2|2 3| 24 | +---+---+---+---+---+ 25 | |2 4|2 5|3 1|3 2|3 3| 26 | +---+---+---+---+---+ 27 | |3 4|3 5|4 1|4 2|4 3| 28 | +---+---+---+---+---+ 29 | |4 4|4 5|0 0|0 0|0 0| 30 | +---+---+---+---+---+ -------------------------------------------------------------------------------- /Nialroot/niallib/simpson.ndf: -------------------------------------------------------------------------------- 1 | # INTEGRATE f A B Eps 2 | 3 | # Find the integral of the function f over the interval A to B using 4 | Adapative Simpson's Integration. Eps is the relative accuracy sought 5 | in the answer. This technique works well on functions that are not 6 | smooth throughout the region. It adapts the amount of subdivision to 7 | the requirements of the area of the curve. See "romberg.ndf" for 8 | an alternative integration routine. 9 | 10 | SIMPSON IS TRANSFORMER f 11 | OPERATION A C B Fa Fc Fb S Eps { 12 | X := ( A + C ) / 2 ; 13 | Fx := f X ; 14 | H := X - A ; 15 | Left_s := H / 3 * ( Fa + ( 4 * Fx ) + Fc ) ; 16 | Y := ( C + B ) / 2 ; 17 | Fy := f Y ; 18 | Right_s := H / 3 * ( Fc + ( 4 * Fy ) + Fb ) ; 19 | New_s := Left_s + Right_s ; 20 | IF abs ( New_s - S ) <= ( Eps * New_s ) THEN 21 | New_s 22 | ELSE 23 | sum ( SIMPSON f A X C Fa Fx Fc Left_s Eps ) ( SIMPSON f C Y 24 | B Fc Fy Fb Right_s Eps ) 25 | ENDIF } 26 | 27 | INTEGRATE IS TRANSFORMER f 28 | OPERATION A B Eps { 29 | C := ( A + B ) / 2 ; 30 | H := C - A ; 31 | Fa Fb Fc := EACH f A B C ; 32 | S := H / 3 * ( Fa + ( 4 * Fc ) + Fb ) ; 33 | SIMPSON f A C B Fa Fc Fb S Eps } 34 | 35 | # EXAMPLES: 36 | INTEGRATE exp -1 1 1e-6 37 | 2.3504 38 | INTEGRATE sin 0 pi 1e-6 39 | 2. 40 | -------------------------------------------------------------------------------- /Nialroot/niallib/solve.ndf: -------------------------------------------------------------------------------- 1 | # solve_linear_eqns A B 2 | 3 | # Routines associated with solving linear equations 4 | The linear algebra primitives are: 5 | solve 6 | inverse (inv) 7 | innerproduct (ip) 8 | 9 | 10 | # The operation solve uses Gaussian Elimination for 11 | solving the system of linear equations 12 | Ax = b 13 | 14 | 15 | # Examples: 16 | 17 | # A gets 2 2 reshape 1. 0. 0. 1.; 18 | B gets 3. 4.; 19 | A solve B 20 | 21 | matrixmult IS innerproduct 22 | 23 | hilbert IS OPERATION N { 24 | recip (tell N OUTER + tell N + 1) } 25 | 26 | vnorm IS OPERATION X { 27 | max abs X } 28 | 29 | mnorm IS OPERATION A { 30 | max EACH sum rows abs A } 31 | 32 | reldiff IS OPERATION X Y { 33 | vnorm (X - Y) / vnorm X } 34 | 35 | residuals IS OPERATION A B X { 36 | vnorm (A matrixmult X - B) } 37 | 38 | # M is a series of integers, eg. count 10. Test runs solve on a random 39 | N by N matrix with N taking on the values of (abs M). It returns a list 40 | of pairs where the first item of each pair is abs N and the second is 41 | the elapsed CPU time spent in solving the set of equations. 42 | 43 | # 44 | test is op M { 45 | Fmt := setformat '%5.2f' ; 46 | Res := Null ; 47 | FOR N WITH abs M DO 48 | a gets random n n ; 49 | b gets a inner[+,*] count n; 50 | T1 := Time ; 51 | a solve b ; 52 | T2 := Time ; 53 | Res := Res append ( N (T2 - T1) ); 54 | ENDFOR ; 55 | write mix Res ; 56 | setformat Fmt ; 57 | Res } 58 | 59 | # Test1 displays the results of the other functions. 60 | 61 | # 62 | test1 is op N { 63 | Fmt := setformat '%g' ; 64 | A := random N N ; 65 | B gets A inner[+,*] count N ; 66 | X := A solve B ; 67 | H := ((hilbert N) ) ; 68 | V := ((EACH vnorm cols A) ) ; 69 | M := ((mnorm A) ) ; 70 | D := ((reldiff X (count N) ) ) ; 71 | R := ((residuals A B X ) ) ; 72 | ITERATE write 73 | ('hilbert ') H 74 | ('vnorm ') V 75 | ('mnorm ') M 76 | ('solve AX=B ') X 77 | ('reldiff ') D 78 | ('residuals ') R ; 79 | setformat Fmt ; } 80 | 81 | -------------------------------------------------------------------------------- /Nialroot/niallib/stripblanks.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: stripblanks Str 3 | File: stripblanks.ndf 4 | 5 | # This operation removes all leading and trailing blanks from a string. 6 | 7 | stripblanks IS OPERATION Str { 8 | Nonblanksat := EACH first (o findall (` match list Str)) ; 9 | IF empty Nonblanksat THEN 10 | '' 11 | ELSE 12 | first Nonblanksat drop (last Nonblanksat + 1 take list Str) 13 | ENDIF } 14 | 15 | # Example: 16 | 17 | # stripblanks ' This is a string. ' 18 | This is a string. 19 | 20 | -------------------------------------------------------------------------------- /Nialroot/niallib/tostring.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: tostring Array_list 3 | File: tostring.ndf 4 | 5 | # Tostring converts a list of items to a string with each item separated by one 6 | blank. 7 | 8 | tostring IS OPERATION A { 9 | front link ( EACH string ( list A ) EACHLEFT link ' ' ) } 10 | 11 | # Examples: 12 | 13 | # 14 | set "decor ; tostring "See "Spot "Run 15 | 'See Spot Run' 16 | 17 | # 18 | tostring "See "the 3 "Dogs 19 | 'See the 3 Dogs' 20 | -------------------------------------------------------------------------------- /Nialroot/niallib/towords.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: towords Str 3 | File: towords.ndf 4 | 5 | # This operation returns the list of phrases of the words in the string. 6 | Words in the string are character sequences separated by one or more blanks. 7 | For example, the string 'See Spot run.' has 3 words: "See", "Spot" and 8 | "run.". 9 | 10 | towords IS OPERATION Str { 11 | Strings := EACH phrase ( ` match Str cut Str ) } 12 | 13 | # Examples: 14 | 15 | # 16 | set "decor ; towords 'See Spot run.' 17 | "See "Spot "run. 18 | 19 | # 20 | towords '3 + 2 * 4' 21 | "3 "+ "2 "* "4 22 | -------------------------------------------------------------------------------- /Nialroot/niallib/unitarray.ndf: -------------------------------------------------------------------------------- 1 | # 2 | Operation: unitarray Sh 3 | File: unitarra.ndf 4 | 5 | # Unitarray builds the unit array for a given shape. If the shape is of length 6 | two and both items of the shape are the same, then the result is the 7 | identity matrix of that shape. 8 | 9 | unitarray IS OPERATION Sh { abs OUTER = EACH tell Sh } 10 | 11 | # Examples: 12 | 13 | # 14 | unitarray 3 3 15 | 1 0 0 16 | 0 1 0 17 | 0 0 1 18 | 19 | # 20 | unitarray 4 4 4 21 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22 | 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 23 | 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 24 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 25 | -------------------------------------------------------------------------------- /Nialroot/tutorial/lisp.dat: -------------------------------------------------------------------------------- 1 | Many of the operations and ideas of Lisp have a counterpart in Q'Nial. 2 | 3 | "car", "cdr" and "cons" in Lisp are the Q'Nial operations "first", "rest" 4 | and "hitch". To use Lisp terminology, they are defined for us as follows: 5 | 6 | .n car is first 7 | .n cdr is rest 8 | .n cons is hitch 9 | 10 | .n a gets "sum ("prod "x 1) 3 11 | 12 | .n (car a) 13 | 14 | .n (cdr a) 15 | .p 16 | A list can be built back using the Lisp terms or Nial ones. 17 | 18 | .n a 19 | 20 | .n (cons (car a) (cdr a)) 21 | 22 | .n (first a hitch rest a) 23 | 24 | Two other Lisp words can be defined, nul and eq 25 | 26 | .n nul is empty 27 | 28 | .n eq is = 29 | .p 30 | The concept of membership can be written in terms of Lisp operations: 31 | 32 | .b member is op a b( 33 | if (nul b) then o 34 | elseif (eq a (car b)) then l 35 | else (member a (cdr b)) 36 | .e endif) 37 | 38 | Is X a member of Y X Z AA? The response is l for True, indicating 39 | that X is a member of the list. 40 | 41 | .n "X member "Y "X "Z "AA 42 | 43 | Is X a member of Y Z? The response is o for False, indicating 44 | that X is not a member of Y Z. 45 | 46 | .n "X member "Y "Z 47 | .p 48 | The corresponding Q'Nial primitive operation for membership is "in". 49 | 50 | .n "X in "Y "X "Z "AA 51 | 52 | The operation "member" could be written in the functional style. 53 | Its definition as written above is: 54 | .n see "member 55 | 56 | In functional style it is: 57 | .n member IS OPERATION A B (or ( A EACHRIGHT = B ) ) 58 | 59 | .n "X member "Y "X "Z "AA 60 | .p 61 | Some of the Lisp ideas are implemented succinctly in Q'Nial 62 | The operation "push" pushes item onto a stack; "pop" takes it off 63 | 64 | .n Stack is external variable 65 | .b push is op Item { 66 | NONLOCAL Stack ; 67 | .e Stack := link Item Stack } 68 | 69 | .b pop is { 70 | NONLOCAL Stack ; 71 | Item Stack := [first,rest] Stack ; 72 | .e Item } 73 | 74 | .n Stack := 2 3 5 8 11 19 ; 75 | .n pop 76 | .n Stack 77 | .n push 30 78 | .n pop pop pop pop ; Stack 79 | .p 80 | -------------------------------------------------------------------------------- /Nialroot/tutorial/moretext: -------------------------------------------------------------------------------- 1 | The dog's name was Spot. He was a golden retriever. Spot 2 | lived on a farm near the haunted house. Spot liked to chase 3 | Charlie. One day Spot chased Charlie into the house. 4 | -------------------------------------------------------------------------------- /Nialroot/tutorial/system.dat: -------------------------------------------------------------------------------- 1 | System operations for keyboard input in interactive mode: 2 | 3 | The operation "readscreen" displays the string argument as a prompt 4 | and stops, awaiting an entry. It accepts all text typed until the 5 | as the input and assigns it to "Name" as a string. 6 | 7 | .n Name gets readscreen 'Please type your name: '; 8 | 9 | .n Name 10 | 11 | The operation "read" displays the string argument as a prompt 12 | and stops, awaiting an entry. The text entered is executed, which 13 | causes a string representing numbers to be converted to numbers 14 | or a string representing a Q'Nial expression to be evaluated. 15 | 16 | .n X Y gets read 'X Y coordinates (Type 2 numbers): ' ; 17 | 18 | .n X Y 19 | .p 20 | System operations to write to the screen in interactive mode: 21 | 22 | The operation "writescreen" writes a string to the screen. 23 | 24 | .n writescreen 'Correct answer'; 25 | 26 | The operation "write" formats its argument as a character table and displays 27 | the result on one or more lines. 28 | 29 | .n write "Coordinates: X Y ; 30 | .n write "Coordinates: X Y (3 4 5) 31 | 32 | The operation "writechars" writes a string to the screen without a newline: 33 | 34 | .n writechars 'abc'; writescreen ' more text'; 35 | 36 | 37 | .p 38 | The operation "edit" is used to edit a text file. It's argument is the name of 39 | a file in the current directory as a phrase or string. For example: 40 | 41 | edit "test.ndf 42 | 43 | would open the file test.ndf using the designated editor on the host 44 | operating system. If the file did not exist it is created as an empty 45 | file for the ditor. 46 | 47 | Alternatively the argument can be a string that forms a path to file to be edited. 48 | edit "~/test1.ndf" 49 | .p 50 | 51 |  -------------------------------------------------------------------------------- /Nialroot/tutorial/test.dat: -------------------------------------------------------------------------------- 1 | 2 | .s set "sketch; set "nodecor; 3 | To insert an apostrophe in a string, use two apostrophes, side by side 4 | 5 | .n Company Software := 'Nial Systems Limited' 'Q''Nial' 6 | 7 | To insert an apostrophe in a phrase, just use one apostrophe. 8 | 9 | .n Company Software := (phrase 'Nial Systems Limited ') "Q'Nial 10 | .p -------------------------------------------------------------------------------- /Nialroot/tutorial/textfile: -------------------------------------------------------------------------------- 1 | This is a short story about a cat and a dog. The 2 | cat was named Charlie. He was a black cat who 3 | lived in a haunted house. 4 | -------------------------------------------------------------------------------- /binaries/FreeBSD/nial64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/FreeBSD/nial64 -------------------------------------------------------------------------------- /binaries/Linux/nial64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Linux/nial64 -------------------------------------------------------------------------------- /binaries/OSX/Basic/nial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/OSX/Basic/nial -------------------------------------------------------------------------------- /binaries/Old/Linux/nial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Linux/nial -------------------------------------------------------------------------------- /binaries/Old/Linux/nial32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Linux/nial32 -------------------------------------------------------------------------------- /binaries/Old/Linux/nial64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Linux/nial64 -------------------------------------------------------------------------------- /binaries/Old/OSX/nial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/OSX/nial -------------------------------------------------------------------------------- /binaries/Old/OSX/nial64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/OSX/nial64 -------------------------------------------------------------------------------- /binaries/Old/Raspbian/nial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Raspbian/nial -------------------------------------------------------------------------------- /binaries/Old/Raspbian/nial64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Raspbian/nial64 -------------------------------------------------------------------------------- /binaries/Old/Windows/nial32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Windows/nial32.exe -------------------------------------------------------------------------------- /binaries/Old/Windows/nial64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Old/Windows/nial64.exe -------------------------------------------------------------------------------- /binaries/Readme.md: -------------------------------------------------------------------------------- 1 | This directory contains current and old copies of the QNial7 2 | binaries for different operating systems. 3 | 4 | When the source code changes the current binaries are moved to the ***Old*** 5 | directory. 6 | 7 | There may be a lag between changes to the source code and new binaries. 8 | 9 | -------------------------------------------------------------------------------- /binaries/Windows/Old/nial64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Windows/Old/nial64.exe -------------------------------------------------------------------------------- /binaries/Windows/README.md: -------------------------------------------------------------------------------- 1 | # Windows 10 Binaries 2 | 3 | This folder contains two versions of Nial as ZIP files 4 | 5 | 1. **Win64Basic** - a version of Nial which does not need external libraries 6 | 2. **Win64All** - a version of Nial which uses the CSFML libraries and the FFTW3 libraries. The DLLs for these libraries are contained in the dll subfolder. This folder also contains a DLL for OpenAL32 if you don't already have that on your machine. 7 | 8 | The Win64All version be can be used with the sound library created by Stuart Smith. 9 | 10 | -------------------------------------------------------------------------------- /binaries/Windows/Win64All.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Windows/Win64All.zip -------------------------------------------------------------------------------- /binaries/Windows/Win64Basic.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/binaries/Windows/Win64Basic.zip -------------------------------------------------------------------------------- /docs/Array Theory and the Design of Nial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Array Theory and the Design of Nial.pdf -------------------------------------------------------------------------------- /docs/Design of QNial V7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Design of QNial V7.pdf -------------------------------------------------------------------------------- /docs/Manuals/Introduction/NialIntroduction.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/Introduction/NialIntroduction.epub -------------------------------------------------------------------------------- /docs/Manuals/Introduction/NialIntroduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/Introduction/NialIntroduction.pdf -------------------------------------------------------------------------------- /docs/Manuals/Language Definition/Styles.css: -------------------------------------------------------------------------------- 1 | /* This defines styles and classes used in the book */ 2 | body { 3 | margin: 5%; 4 | text-align: justify; 5 | font-size: medium; 6 | } 7 | code { 8 | font-family: monospace; 9 | font-size: smaller; 10 | color: Black; 11 | display: block; 12 | border: solid; 13 | border-width: 1px; 14 | margin: 5px; 15 | padding: 5px; 16 | background-color: #FFFFCC; 17 | } 18 | h1 { 19 | text-align: left; 20 | color: Blue; 21 | } 22 | h2 { 23 | text-align: left; 24 | color: Blue; 25 | } 26 | h3 { 27 | text-align: left; 28 | color: Blue; 29 | } 30 | h4 { 31 | text-align: left; 32 | color: Blue; 33 | } 34 | h5 { 35 | text-align: left; 36 | color: Blue; 37 | } 38 | h6 { 39 | text-align: left; 40 | color: Blue; 41 | } 42 | ol.toc { 43 | padding: 0; 44 | margin-left: 1em; 45 | } 46 | ol.toc li { 47 | list-style-type: none; 48 | margin: 0; 49 | padding: 0; 50 | } 51 | -------------------------------------------------------------------------------- /docs/Manuals/Language Definition/V6LanguageDefinition.css: -------------------------------------------------------------------------------- 1 | /* This defines styles and classes used in the book */ 2 | body { 3 | margin: 5%; 4 | text-align: justify; 5 | font-size: medium; 6 | } 7 | code { 8 | font-family: monospace; 9 | font-size: smaller; 10 | color: Black; 11 | display: block; 12 | border: solid; 13 | border-width: 1px; 14 | margin-left: auto; 15 | margin-right: auto; 16 | padding: 5px; 17 | background-color: #EAEAEA; 18 | width: auto; 19 | 20 | } 21 | 22 | h1 { 23 | text-align: left; 24 | color: Blue; 25 | } 26 | h2 { 27 | text-align: left; 28 | color: Blue; 29 | } 30 | h3 { 31 | text-align: left; 32 | color: Blue; 33 | } 34 | h4 { 35 | text-align: left; 36 | color: Blue; 37 | } 38 | h5 { 39 | text-align: left; 40 | color: Blue; 41 | } 42 | h6 { 43 | text-align: left; 44 | color: Blue; 45 | } 46 | ol.toc { 47 | padding: 0; 48 | margin-left: 1em; 49 | } 50 | ol.toc li { 51 | list-style-type: none; 52 | margin: 0; 53 | padding: 0; 54 | } 55 | 56 | table { 57 | margin-left: auto; 58 | margin-right: auto; 59 | border-collapse: collapse; 60 | } 61 | 62 | th, td { 63 | padding: 5px; 64 | } 65 | 66 | table, th, td { 67 | border: 1px solid black; 68 | } 69 | 70 | img { 71 | margin-left: auto; 72 | margin-right: auto; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /docs/Manuals/Language Definition/V6LanguageDefinition.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/Language Definition/V6LanguageDefinition.epub -------------------------------------------------------------------------------- /docs/Manuals/Language Definition/V6LanguageDefinition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/Language Definition/V6LanguageDefinition.pdf -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/EpubHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: An Introduction to Nial 3 | author: Michael Jenkins 4 | stylesheet: Styles.css 5 | date: 2015-08-01 6 | copyright: Nial Systems Limited 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/HtmlHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: An Introduction to Nial 3 | author: Michael Jenkins 4 | date: 2015-08-01 5 | copyright: Nial Systems Limited 6 | --- 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/NialIntroduction.epub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/pandoc tools/NialIntroduction/NialIntroduction.epub -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/NialIntroduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/pandoc tools/NialIntroduction/NialIntroduction.pdf -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/PdfHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: An Introduction to Nial 3 | author: Michael Jenkins 4 | stylesheet: Styles.css 5 | date: 2015-08-01 6 | copyright: Nial Systems Limited 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/Styles.css: -------------------------------------------------------------------------------- 1 | /* This defines styles and classes used in the book */ 2 | body { 3 | margin: 5%; 4 | text-align: justify; 5 | font-size: medium; 6 | } 7 | code { 8 | font-family: monospace; 9 | font-size: smaller; 10 | color: Black; 11 | display: block; 12 | border: solid; 13 | border-width: 1px; 14 | margin: 5px; 15 | padding: 5px; 16 | background-color: #FFFFCC; 17 | } 18 | h1 { 19 | text-align: left; 20 | color: Blue; 21 | } 22 | h2 { 23 | text-align: left; 24 | color: Blue; 25 | } 26 | h3 { 27 | text-align: left; 28 | color: Blue; 29 | } 30 | h4 { 31 | text-align: left; 32 | color: Blue; 33 | } 34 | h5 { 35 | text-align: left; 36 | color: Blue; 37 | } 38 | h6 { 39 | text-align: left; 40 | color: Blue; 41 | } 42 | ol.toc { 43 | padding: 0; 44 | margin-left: 1em; 45 | } 46 | ol.toc li { 47 | list-style-type: none; 48 | margin: 0; 49 | padding: 0; 50 | } 51 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/make_epub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #!/bin/sh 3 | cat EpubHeader.md NialIntroduction.md > NI.md 4 | pandoc NI.md -o NialIntroduction.epub 5 | cp NialIntroduction.epub ../../epub 6 | rm NI.md 7 | exit 0 8 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/make_html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat HtmlHeader.md NialIntroduction.md > NI.md 3 | pandoc -s --toc -c Styles.css -o NialIntroduction.html NI.md 4 | cp NialIntroduction.html Styles.css ../../html 5 | rm NI.md 6 | exit 0 7 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/NialIntroduction/make_pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #!/bin/sh 3 | cat PdfHeader.md NialIntroduction.md > NI.md 4 | pandoc NI.md -o NialIntroduction.pdf 5 | cp NialIntroduction.pdf ../../pdf 6 | rm NI.md 7 | exit 0 8 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/EpubHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: QNial the Language Definition 3 | author: Michael Jenkins 4 | stylesheet: LanguageDefinition.css 5 | date: '01 August 2015' 6 | copyright: Nial Systems Limited 7 | cover-image: cover.png 8 | 9 | --- 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/HtmlHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: QNial the Language Definition 3 | author: Michael Jenkins 4 | date: '01 August 2015' 5 | copyright: Nial Systems Limited 6 | 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/PdfHeader.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: QNial the Language Definition 3 | author: Michael Jenkins 4 | date: '01 August 2015' 5 | copyright: Nial Systems Limited 6 | 7 | --- 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/V6LanguageDefinition.css: -------------------------------------------------------------------------------- 1 | /* This defines styles and classes used in the book */ 2 | body { 3 | margin: 5%; 4 | text-align: justify; 5 | font-size: medium; 6 | } 7 | code { 8 | font-family: monospace; 9 | font-size: smaller; 10 | color: Black; 11 | display: block; 12 | border: solid; 13 | border-width: 1px; 14 | margin-left: auto; 15 | margin-right: auto; 16 | padding: 5px; 17 | background-color: #EAEAEA; 18 | width: auto; 19 | 20 | } 21 | 22 | h1 { 23 | text-align: left; 24 | color: Blue; 25 | } 26 | h2 { 27 | text-align: left; 28 | color: Blue; 29 | } 30 | h3 { 31 | text-align: left; 32 | color: Blue; 33 | } 34 | h4 { 35 | text-align: left; 36 | color: Blue; 37 | } 38 | h5 { 39 | text-align: left; 40 | color: Blue; 41 | } 42 | h6 { 43 | text-align: left; 44 | color: Blue; 45 | } 46 | ol.toc { 47 | padding: 0; 48 | margin-left: 1em; 49 | } 50 | ol.toc li { 51 | list-style-type: none; 52 | margin: 0; 53 | padding: 0; 54 | } 55 | 56 | table { 57 | margin-left: auto; 58 | margin-right: auto; 59 | border-collapse: collapse; 60 | } 61 | 62 | th, td { 63 | padding: 5px; 64 | } 65 | 66 | table, th, td { 67 | border: 1px solid black; 68 | } 69 | 70 | img { 71 | margin-left: auto; 72 | margin-right: auto; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/V6LanguageDefinition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/pandoc tools/V6LanguageDefinition/V6LanguageDefinition.pdf -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/Manuals/pandoc tools/V6LanguageDefinition/cover.png -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/make_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sh make_epub.sh 3 | sh make_pdf.sh 4 | sh make_html.sh 5 | exit 0 6 | 7 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/make_epub.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #!/bin/sh 3 | cat EpubHeader.md V6LanguageDefinition.md > LD.md 4 | pandoc LD.md -o V6LanguageDefinition.epub 5 | cp V6LanguageDefinition.epub ../../epub 6 | rm LD.md 7 | exit 0 8 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/make_html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat HtmlHeader.md V6LanguageDefinition.md > LD.md 3 | pandoc -s --toc -c V6LanguageDefinition.css -o V6LanguageDefinition.html LD.md 4 | cp V6LanguageDefinition.html V6LanguageDefinition.css ../../html 5 | rm LD.md 6 | exit 0 7 | -------------------------------------------------------------------------------- /docs/Manuals/pandoc tools/V6LanguageDefinition/make_pdf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #!/bin/sh 3 | cat PdfHeader.md V6LanguageDefinition.md > LD.md 4 | pandoc LD.md -o V6LanguageDefinition.pdf 5 | cp V6LanguageDefinition.pdf ../../pdf 6 | rm LD.md 7 | exit 0 8 | 9 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # The Nial Documentation 2 | 3 | This directory contains documentation for the V6 and V7 versions of Q'Nial. 4 | 5 | The documentation is organised in a simple directory structure 6 | 7 | Entry | Contents 8 | ------------------------ | ---------------------------------- 9 | Design of Q'Nial V7.pdf | Description of Q'Nial V7 implementation 10 | README.md | The file you are currently reading 11 | Manuals/Introduction | Nial Introduction in epub, pdf and html formats 12 | Manuals/Language Definition | Nial Language Definition in epub, pdf and html formats 13 | Manuals/pandoc tools | tools to create Manuals in various formats 14 | V7 Nial Extensions | Documentation of extensions added to Nial in V7 15 | V7 QNial Dictionary.html | Dictionary describing concepts, syntax, definitions with hyperlinks for easy navigation 16 | old NSL website files | documentation from www.nial.com website 17 | Array Theory and the Design of Nial | a PDF file of a book that provides background on many decisions made in the development of Nial and its interpreter Q'Nial. It is also available in electronic book form from Apple's Bookstore for free. 18 | -------------------------------------------------------------------------------- /docs/V7 Nial Extensions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/V7 Nial Extensions.pdf -------------------------------------------------------------------------------- /docs/old NSL website files/ArrayTheory.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/old NSL website files/ArrayTheory.html -------------------------------------------------------------------------------- /docs/old NSL website files/NialSaga.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nial Systems Limited - Name of the Language 6 | 7 | 8 | 10 | 11 | 12 |
13 | 14 | 15 | 51 | 52 |
16 | 17 | 18 | 19 | 20 | 48 | 49 |
21 | 22 | 23 | 24 | 25 |
26 | The Name of the Language 27 |
28 | 29 |

The Viking ship is used as the logo for Q'Nial to reflect the Nordic origin 30 | of the name Nial. On the suggestion of Prof. Ole Franksen of the Technical University 31 | of Denmark, the acronym NIAL was chosen to describe the features of the language: 32 | an interactive language with nested arrays and nested control structures, and 33 | to be suggestive of the motivations behind the language. 34 |

A strong motivation in the design of Nial was to use "laws" or "identities" 35 | that hold universally so that consistent properties hold and can be explained 36 | easily. 37 |

The oldest Nordic saga, Njal's Saga, is the story of the coming of the rule 38 | of law to the Viking settlements on Iceland around the year 1000 AD. Since Njal 39 | is also sometimes spelled "Nial", the name was chosen for the language to remind 40 | users of the importance of the universal laws of data incorporated into the 41 | design of the language. 42 |
43 | 44 | 45 |
46 | 47 |

50 |
53 | 54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/old NSL website files/small_bullet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/niallang/Nial_Development/cdd6e8158814e96d063b921715de91e038191ead/docs/old NSL website files/small_bullet.gif -------------------------------------------------------------------------------- /examples/Basic/data_trans.ndf: -------------------------------------------------------------------------------- 1 | # Create an array of vectors of random numbers 2 | # For each vector compute its mean and standard 3 | # deviation and adjust the entries of the vector 4 | # to be number of standard deviations from the mean 5 | 6 | 7 | # Set the size values for our testing 8 | 9 | nentries := 60000; 10 | narrays := 1024; 11 | 12 | # Create the array of vectors. 13 | # Note that we could also do this as 14 | # a := rows random (narrays nentries) 15 | 16 | a := each random (narrays take nentries); 17 | 18 | # Define the function to perform the computation for 19 | # one vector 20 | 21 | one_row is op x { 22 | m := (sum x)/(tally x); 23 | ax := x - m; 24 | s := sqrt ((sum (ax*ax))/(tally x)); 25 | ax/s 26 | } 27 | 28 | # Time Nial running this code. There are implementations in 29 | # other systems in the comparison directory. 30 | 31 | write 'Starting time test'; 32 | 33 | n_iter := 20; 34 | i := 0; 35 | 36 | start_time := time; 37 | while i < n_iter do 38 | res := each one_row a; 39 | i := i + 1; 40 | endwhile; 41 | end_time := time; 42 | 43 | write 'Duration' ((end_time-start_time)/n_iter); 44 | bye; 45 | 46 | -------------------------------------------------------------------------------- /examples/Basic/primes.ndf: -------------------------------------------------------------------------------- 1 | # Generating primes in the old fashioned way 2 | 3 | 4 | # Test if a number is a prime by examining the residue of division 5 | # by all numbers less than or equal to the square root of the number. 6 | # If no residue is 0 the number is a prime. 7 | 8 | isp is operation X { 9 | (X > 1) and (and (0 < (X eachright mod (2 drop tell (1 + floor sqrt X))))) } 10 | 11 | 12 | # Find all primes up to the supplied number by testing each to see if it 13 | # is a prime and then selecting the sublist of numbers that are primes. 14 | 15 | isp_list is op N { 16 | r := each isp (count N); 17 | r sublist (count N) 18 | } 19 | 20 | # Find the primes up to 1000. If you want to run this interactively 21 | # then remove the 'bye' line and use 22 | # 23 | # Nial -i 24 | # loaddefs "primes 25 | 26 | write ('Primes to 1000' (isp_list 1000)); 27 | 28 | # That's all folks 29 | 30 | bye; 31 | -------------------------------------------------------------------------------- /examples/Basic/tables.ndf: -------------------------------------------------------------------------------- 1 | # Simple example of using tables/asscoiative-arrays 2 | 3 | # Add an item to the table both as the key and the value 4 | # and return the number of probes to perform the insert 5 | 6 | probe_add2 is OP T M { 7 | T _tset M; 8 | tprobes T 9 | } 10 | 11 | 12 | # Add the integers from 1 to N to the table and 13 | # print some statistics. The second argument M is the 14 | # initial table size 15 | # 16 | 17 | ntables_test1 is OP N M { 18 | write 'trying' N M; 19 | % Create a table of the nominated size; 20 | t := _tcreate M; 21 | % Build the name/value pairs for insertion using an atlas; 22 | entries := (each [(phrase string), pass] (count N)); 23 | st := time; 24 | p := t eachright probe_add2 entries; 25 | durn := time - st; 26 | if durn > 0 then 27 | write ('Insertions/sec: ' link string (N/durn)); 28 | endif; 29 | avg_p := (sum p)/(tally p); 30 | write ('Entries in table: ' link string (tcount t)); 31 | write ('Size of table: ' link string (tsize t)); 32 | write ('Average probes per insertion: ' link string avg_p); 33 | write ('Maximum probes per insertion: ' link string (max p)); 34 | "ok 35 | } 36 | 37 | 38 | # Test inserting entries with different initial table sizes. 39 | # The table will increase in size automatically whenever it 40 | # is more than 70% full. 41 | # 42 | # First choose minimum table size and allow to grow by insertion 43 | # and the table will be rehashed every time it expands. 44 | # 45 | # Secondly choose size so that no increases will occur. 46 | 47 | ntables_test1 100000 1; 48 | ntables_test1 100000 200000; 49 | 50 | bye 51 | 52 | -------------------------------------------------------------------------------- /examples/Plotting/README.md: -------------------------------------------------------------------------------- 1 | A simple example of running GNUPot from Nial to perform 2 | 2D and 3D plotting. 3 | 4 | For a 2D plot use 5 | 6 | demo1 1000 7 | 8 | and for a 3D plot use 9 | 10 | demo2 100 100 11 | 12 | -------------------------------------------------------------------------------- /examples/Plotting/demo.ndf: -------------------------------------------------------------------------------- 1 | # Some simple examples of 2d and 3d plotting fro Nial using 2 | # GNUPlot. 3 | 4 | loaddefs "gplot; 5 | 6 | # A simple 2D plot 7 | 8 | demo2d is op n { 9 | gplot 'set title "DEMONSTRATION PLOT"' ; 10 | gplot 'set xlabel "time"' ; 11 | gplot 'set ylabel "amplitude"' ; 12 | gplot 'set style data lines' ; 13 | x := tell n / n ; 14 | y := sin ( 17 * pi * x ) + ( 0.3 * sin ( 23 * pi * x ) ) ; 15 | gplot_xy x y 16 | } 17 | 18 | # A simple surface plot 19 | 20 | demo3d is op nx ny { 21 | gplot 'set title "DEMONSTRATION SURFACE PLOT"' ; 22 | gplot 'set xlabel "cosine squared"' ; 23 | gplot 'set ylabel "sine squared"' ; 24 | gplot 'set style data lines' ; 25 | x := tell nx / nx ; 26 | y := tell ny / ny ; 27 | z := ( sin ( 4 * pi * x ) power 2 ) outer + ( cos( 3 * pi * y ) power 2 ) ; 28 | mat := gplot_fmt3d x y z ; 29 | gplot_writedata mat "DEMO3D.dat ; 30 | gplot 'splot "DEMO3D.dat" nonuniform matrix u 1:2:3 w l' ; 31 | "DEMO3D.dat 32 | } 33 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a number of simple examples of Nial code that use 2 | either core features of Nial or those of extensions. 3 | 4 | -------------------------------------------------------------------------------- /examples/Simulated Annealing/sa_queens.ndf: -------------------------------------------------------------------------------- 1 | # Solving the nqueens problem with simulated annealing 2 | # 3 | 4 | loaddefs "sim_anneal; 5 | 6 | # Set the initial configuration and parameters 7 | 8 | init_temp := 30.0; 9 | fin_temp := 0.05; 10 | niter := 100; 11 | 12 | nq_cool is (0.99 sa_cool); 13 | 14 | 15 | # nq_tweak 16 | # -------- 17 | # 18 | # permute two entries in the array 19 | # 20 | 21 | nq_tweak is op soln { 22 | n := tally soln; 23 | % Get two distinct random indices; 24 | i j := floor (n * random 2); 25 | if i = j then j := (j+1) mod n; endif; 26 | x y := (i j) choose soln; 27 | % swap the values; 28 | (y x) (i j) placeall soln} 29 | 30 | 31 | # nq_cost 32 | # ------- 33 | # 34 | # Use the number of conflicting queen positions as the 35 | # energy/cost for the problem 36 | # 37 | 38 | nq_cost is op soln { 39 | p := tell tally soln; 40 | v1 := abs link (p eachright minus p); 41 | v2 := abs link (soln eachright minus soln); 42 | (sum ((not (0 match v1)) sublist (v1 match v2)))/2.0} 43 | 44 | 45 | # nq_finished 46 | # ----------- 47 | # 48 | # finished if no conflicts 49 | # 50 | 51 | nq_finished is op cost soln model { 52 | cost <= 0.00001} 53 | 54 | 55 | 56 | # Test run 57 | 58 | nq_test is op n { 59 | t_start := time; 60 | model := [count n, init_temp, fin_temp, niter]; 61 | res := sa_run [nq_tweak, nq_cost, nq_cool, nq_finished] model; 62 | durn := time - t_start; 63 | [durn, res]} 64 | 65 | 66 | duration result := nq_test 20; 67 | num_pass best_cost best_soln := result; 68 | 69 | write 'Number of queens: 20'; 70 | write link 'Duration: ' (string duration); 71 | write link 'Passes: ' (string num_pass); 72 | write link 'Conflicts: ' (string best_cost); 73 | write link 'Solution: ' (display best_soln); -------------------------------------------------------------------------------- /examples/Streams and Processes/tcp_worker_client.ndf: -------------------------------------------------------------------------------- 1 | # Example of running an echo interaction over a TCP/IP 2 | # connection. This is the client process to test the server. 3 | # It opens a connection to a remote server and runs an 4 | # echo client. 5 | # 6 | 7 | # Load routines in 'sprocess' module 8 | 9 | library "sprocess; 10 | write 'Starting client'; 11 | 12 | # Open a socket to the server. 13 | 14 | sock := socket_connect 'localhost' 5000; 15 | write ['connected', sock]; 16 | 17 | # Create a pair of streams to handle the interaction 18 | 19 | chan := [nio_open sock 0, nio_open sock 0]; 20 | 21 | # Set the parameters of the interaction 22 | 23 | n_success := 0; 24 | 25 | # Use one of the following pairs for testing 26 | 27 | %ntries := 5000; 28 | %ndata := 2 3 4 5 reshape count 120; 29 | 30 | ntries := 500; 31 | ndata := 2 3 4 5 6 reshape count 720; 32 | 33 | # Start the data transmission 34 | 35 | iter := 0; 36 | t_start := time; 37 | while iter < ntries do 38 | % Send the array; 39 | ipc_write_array chan ndata; 40 | % Read the response; 41 | res := ipc_read_array chan; 42 | % Check the response; 43 | if res = ndata then 44 | n_success := n_success + 1; 45 | else 46 | write 'failed'; 47 | write res; 48 | bye; 49 | endif; 50 | iter := iter + 1; 51 | endwhile; 52 | t_end := time; 53 | 54 | % disconnect; 55 | ipc_write_array chan "done; 56 | write (ipc_read_array chan); 57 | 58 | # Determine the number of bytes in each send by 59 | # writing to an internal stream 60 | 61 | s := nio_open -1 0; 62 | nio_block_array s ndata; 63 | e_bytes := nio_count s; 64 | 65 | # Write out the results. Note that we have transferred 66 | # each message in two directions. 67 | 68 | write ['Success count ', n_success]; 69 | write 'Messages/sec ' ((2*ntries)/(t_end - t_start)); 70 | write 'Bytes/sec ' ((2*ntries*e_bytes)/(t_end - t_start)); 71 | 72 | write 'Thats all folks'; 73 | 74 | bye; 75 | 76 | -------------------------------------------------------------------------------- /examples/Streams and Processes/tcp_worker_server.ndf: -------------------------------------------------------------------------------- 1 | # Example of a TCP/IP server process that accepts connections and 2 | # spawns a child process to handle the connection. 3 | # 4 | # 5 | 6 | # Load the support functions 7 | 8 | library "sprocess; 9 | 10 | 11 | # echo actor is a simple Nial function that echoes what it receives 12 | # on a stream 13 | # 14 | 15 | echo_actor is op chan { 16 | running := l; 17 | while running do 18 | res := ipc_read_array chan; 19 | ipc_write_array chan res; 20 | if res = "done then 21 | running := o; 22 | endif; 23 | endwhile; 24 | "done 25 | } 26 | 27 | 28 | # 29 | # Start child spawns a Nial child process to handle the connection. 30 | # It receives two arguments, the connection and a function to 31 | # perform the work 32 | # 33 | 34 | start_child is op con actor { 35 | % Create a reader/write pair; 36 | chan := [nio_open con 0, nio_open con 0]; 37 | child := spawn_child PRC_MANAGED; 38 | if child = Null then 39 | % Actions in child; 40 | res := catch apply actor chan; 41 | ipc_write_array chan res; 42 | bye; 43 | else 44 | % actions in parent; 45 | res := child; 46 | endif; 47 | child 48 | } 49 | 50 | 51 | # 52 | # Start a socket server to accept incoming connections 53 | # on a nominated host/port combination. 54 | # 55 | # When a connection is accepted a child process is created to 56 | # handle the interaction through a nominated function/actor 57 | # 58 | 59 | start_controller is op host port actor { 60 | write ['starting controller', host, port]; 61 | sock aport := socket_bind host port; 62 | write ['bind', sock, aport]; 63 | socket_listen sock 5; 64 | while l do 65 | con := socket_accept sock; 66 | write ['accepting', con]; 67 | child := start_child con actor; 68 | socket_close con; 69 | endwhile; 70 | "done 71 | } 72 | 73 | 74 | 75 | # Simple test code, start a controller on this machine with an 76 | # echo actor to do the work. Use a host of '0.0.0.0' to accept 77 | # connections on all network addresses for this host. 78 | 79 | start_controller '0.0.0.0' 5000 "echo_actor; 80 | 81 | 82 | -------------------------------------------------------------------------------- /examples/Streams and Processes/worker_test1.ndf: -------------------------------------------------------------------------------- 1 | # Example of interaction between a parent and child process using 2 | # transmission of arrays over pipes. The behaviour is an echo 3 | # process. 4 | 5 | # Load the basic routines from the 'sprocess.ndf' module in the 6 | # Nial library 7 | 8 | library "sprocess; 9 | 10 | # Very simple worker process that just echoes back anything 11 | # read on its comms channel 12 | 13 | echo_worker is operation chan args { 14 | while l do 15 | data := ipc_read_array chan; 16 | cnt := ipc_write_array chan data; 17 | endwhile; 18 | l 19 | } 20 | 21 | # Set the number of messages and the data 22 | 23 | try_count := 100000; 24 | tries := try_count; 25 | n_success := 0; 26 | test_data := 2 3 4 5 6 reshape count 720; 27 | 28 | # Create a worker process to implement the echo_worker function 29 | # defined above. Save the comms channel, the process i/o channel 30 | # and the process id. Use a cast to pass the function so that we 31 | # can use apply. 32 | 33 | chan io_chan proc := create_worker !echo_worker 1; 34 | 35 | # loop sending the test data to the child process and reading what 36 | # is sent back. Count the number of correct responses. 37 | 38 | write 'Starting echo worker'; 39 | 40 | start_time := time; 41 | while (tries > 0) do 42 | % Send array; 43 | ipc_write_array chan test_data; 44 | % Read response array; 45 | res := ipc_read_array chan; 46 | % Check validity of response; 47 | if (res = test_data) then 48 | n_success := n_success + 1; 49 | else 50 | write 'Echo failed' res; 51 | bye; 52 | endif; 53 | tries := tries - 1; 54 | endwhile; 55 | end_time := time; 56 | 57 | # Write the count of successes 58 | 59 | write 'Ending test'; 60 | write ('Success count:' n_success); 61 | 62 | # Determine performance. Note that we have serialised, sent and 63 | # deserialised the message in each process 64 | 65 | write ('Performance in messages/sec' ((2*try_count)/(end_time - start_time))); 66 | 67 | # Terminate the child process to avoid zombies 68 | 69 | interrupt_child proc -1; 70 | bye 71 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | .ONESHELL: 2 | 3 | all: nialbasic 4 | 5 | setup: 6 | make clean 7 | mkdir BuildCore/build 8 | mkdir BuildNial/build 9 | mkdir BuildNial/src 10 | 11 | nialcore: setup 12 | cd BuildCore/build 13 | cmake ../src 14 | make 15 | mv nialcore ../../ 16 | 17 | # bootstraps nial, assuming you have a `nialcore` in the nial development dir 18 | # useful if you're too lazy to wait for it to build twice, and already have a copy of `nialcore` 19 | bootstrap: 20 | cd BuildNial/pkgblder 21 | ./../../nialcore -defs buildfromcore 22 | cd ../build 23 | cmake ../src 24 | make 25 | mv nial ../../nialbasic 26 | 27 | nialbasic: nialcore bootstrap 28 | 29 | clean: 30 | rm -rf BuildCore/build 31 | rm -rf BuildNial/build 32 | rm -rf BuildNial/src 33 | --------------------------------------------------------------------------------