+ All Categories
Home > Documents > NIAL Nested Interactive Array Language Dennis Brown Northern Kentucky University CSC 507 –...

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

Date post: 29-Jan-2016
Category:
Upload: barnaby-king
View: 218 times
Download: 0 times
Share this document with a friend
Popular Tags:
22
NIAL Nested Interactive Array Language Dennis Brown Northern Kentucky University CSC 507 – November 2005
Transcript
Page 1: NIAL Nested Interactive Array Language Dennis Brown Northern Kentucky University CSC 507 – November 2005.

NIAL

Nested Interactive Array Language

Dennis Brown

Northern Kentucky University

CSC 507 – November 2005

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

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)

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

APL vs. NIAL

• APL was invented in 1962

• Very efficient for some types of calculation, but required a special character set:

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

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

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

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)

• Strings– ‘abc’

– `a `b `c

• Phrases– “dog

– phrase ‘dog’

• Faults– ‘?conform’

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

Strings vs. Phrases

A string is a list:first ‘abc’ `a last ‘abc’ `c

A phrase is atomic:first “abc “abc last “abc “abc

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

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

• 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]

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

Lisp vs. NIAL

• (car 1 2 3)1

• (cdr 1 2 3)(2 3)

• (cons 1 (2 3))(1 2 3)

• first 1 2 31

• rest 1 2 32 3

• hitch 1 (2 3)1 2 3

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

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 34 5 6

• 2 3 reshape 1 2 3 41 2 34 1 2

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

Tables – Continued

• x := 3 3 reshape count 91 2 34 5 67 8 9

• x | [2,] (row slice)7 8 9

• x | [,2] (col. slice)3 6 9

• x @ (1 2)6

• post 1 2 31

2

3

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

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 ) }

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

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

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

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

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

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)

• 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]

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

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

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

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 FROM1: value := ‘one’ END2: value := ‘two’ ENDELSE value := ‘unknown’

ENDCASE

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

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

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

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

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

Q’Nial in Action

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

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

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

References

• Nial Systems Limitedhttp://www.nial.com

• Q’nial Research Projecthttp://www.qnial.net

• “A Quick Look at Nial,” Journal of J/APLhttp://www.apl.demon.co.uk/aplandj/qnial.html

• Comparison of array languages, Keith Smilliehttp://www.cs.ualberta.ca/~smillie/ComputerAndMe/Part23.html

• “APL programming language,” Wikipediahttp://en.wikipedia.org/wiki/APL_programming_language

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

Questions?


Recommended