1 / 22

NIAL

Nested Interactive Array Language Dennis Brown Northern Kentucky University CSC 507 – November 2005. NIAL. Origins of NIAL. Based on nested array theory developed by Dr. Trenchard More, Jr. Invented in 1981 by Michael Jenkins of Queen’s University in Kingston, Ontario

amarcotte
Download Presentation

NIAL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Nested Interactive Array Language Dennis Brown Northern Kentucky University CSC 507 – November 2005 NIAL

  2. Origins of NIAL • Based on nested array theory developed by Dr. Trenchard More, Jr. • Invented in 1981 by Michael Jenkins of Queen’s University in Kingston, Ontario • Influenced by APL and Lisp • NIAL is an acronym for Nested Interactive Array Language, but is also a reference to Njal’s Saga (a Nordic legend)

  3. APL vs. NIAL • APL was invented in 1962 • Very efficient for some types of calculation, but required a special character set:

  4. APL vs. NIAL (cont.) • NIAL uses keywords instead of symbols, so no custom keyboard is required • For example, ρ (rho) in APL becomes “reshape” in NIAL • NIAL also adds control structures (from imperative languages) that APL did not have • The original version of APL did not support nested arrays

  5. Strings ‘abc’ `a `b `c Phrases “dog phrase ‘dog’ Faults ‘?conform’ NIAL Data Types • Numbers • integers • floating points • booleans (l, o, True, False) • Characters • `X, `v, `3 • Lists • 3 `C 5 (strand notation) • [3 `C 5] • [] (empty list)

  6. Strings vs. Phrases A string is a list: first ‘abc’  `a last ‘abc’  `c A phrase is atomic: first “abc  “abc last “abc  “abc

  7. x y z := 5 6 7 assigns 5 to x, 6 to y, 7 to z [1 2 3] * 2 [2 4 6] [1 2 3] * [3 2 1] [3 4 3] [1 2 3] * 3 2 1 [3 6 9] [2 4 6] [1 2 3] Lists – Examples • sum 2 3 4 • 9 • sum [2 3 4] • [2 3 4] • sum (2 3 4) (1 2 3) • 3 5 7 • each sum (2 3 4) (1 2 3) • 9 6

  8. first 1 2 3 1 rest 1 2 3 2 3 hitch 1 (2 3) 1 2 3 Lisp vs. NIAL • (car 1 2 3) 1 • (cdr 1 2 3) (2 3) • (cons 1 (2 3)) (1 2 3)

  9. Tables • A table is a multi-dimensional list • The reshape function can be used to create a table with a specified number of rows and columns • 2 3 reshape 1 2 3 4 5 6 7 8 1 2 3 4 5 6 • 2 3 reshape 1 2 3 4 1 2 3 4 1 2

  10. post 1 2 3 1 2 3 Tables – Continued • x := 3 3 reshape count 9 1 2 3 4 5 6 7 8 9 • x | [2,] (row slice) 7 8 9 • x | [,2] (col. slice) 3 6 9 • x @ (1 2) 6

  11. Functions • Functions are defined using the syntax “is operation,” followed by the formal parameters, and then the function body enclosed in braces • Functions are evaluated using right associativity Examples: • factorial IS OPERATION x { * count x } • nthroot IS OPERATION x n { power x ( reciprocal n ) }

  12. Transformers • A transformer changes how functions are applied • “each” is a built-in transformer that applies a function to each value of a list • each first (“abc “def) (3 7 8) (`z `x `q) • “abc 3 `z • New transformers can be created using IS TRANSFORMER • Transformers were a novel feature in NIAL, and allow the language to support parallel architectures efficiently

  13. Atlases • An atlas is a list of functions that can be applied to a data item, producing a list of results • [first, last, reverse] `a `b `c • [`a `c ‘cba’] brackets are used because ‘cba’ is a list! • [+, -, *, /, quotient] 12 7 • 19 5 84 1.71 1

  14. x := `a `e `i `o `u x := l x gets 3 plus 4 x gets plus 3 4 x := 3 times prod 4 5 [0 3] choose x x | [0, 3] Different Ways of Saying the Same Thing • x := ‘aeiou’ • x := True • x := 3 + 4 • x := 3 + 4 • x gets 3 * 4 * 5 • x @ (0 3) • x @ (0 3)

  15. IF Statements • IF, ELSE, ELSEIF, and ENDIF are supported • Comparison operators and boolean operations are available IF (x >= 3.4) and (y < 7) THEN out_of_range := True ELSE out_of_range := False ENDIF

  16. CASE Statements • CASE statements allow selection based on a value (not necessarily an integer) • An optional ELSE clause handles the default case • Each non-default case must end with END – there is no fall-through like in C and Java CASE n FROM 1: value := ‘one’ END 2: value := ‘two’ END ELSE value := ‘unknown’ ENDCASE

  17. Loops • NIAL supports the three usual types of loops: • WHILE {condition} DO {expressions} ENDWHILE • REPEAT {expressions} UNTIL {condition} ENDREPEAT • FOR {variable} WITH {range} DO {expressions} ENDFOR • The count function is useful with FOR loops • FOR i WITH count 10 DO write(i) ENDFOR • It is better to use the EACH transformer, however • The EXIT statement can be used to force a loop to terminate

  18. Q’Nial Interpreter • Q’Nial allows NIAL statements to be entered and interpreted dynamically • Windows version is now available free from NIAL Systems (www.nial.com) • C++ source code for Q’Nial is also available free of charge

  19. Q’Nial in Action

  20. The Future of NIAL • NIAL has been used in academic research (particularly in AI) and at some insurance companies, but has declined in popularity since the 1980s • Newer languages in its niche can do the same tasks just as well or better • APL version 2 • J and its successors • J is available for free; NIAL was very expensive until recently • NIAL is not easy to integrate with native C libraries • Best use of NIAL is as a prototyping language

  21. References • Nial Systems Limited http://www.nial.com • Q’nial Research Project http://www.qnial.net • “A Quick Look at Nial,” Journal of J/APL http://www.apl.demon.co.uk/aplandj/qnial.html • Comparison of array languages, Keith Smillie http://www.cs.ualberta.ca/~smillie/ComputerAndMe/Part23.html • “APL programming language,” Wikipedia http://en.wikipedia.org/wiki/APL_programming_language

  22. Questions?

More Related