Nial
# Nial

Nial (from "Nested Interactive Array Language") is a high-level array programming language developed from about 1981 by Mike Jenkins of Queen's University, Kingston, Ontario, Canada. Jenkins co-created the Jenkins–Traub algorithm.

Nial combines a functional programming notation for arrays based on an array theory developed by Trenchard More with structured programming concepts for numeric, character, and symbolic data.

It is most often used for prototyping and artificial intelligence.

## Q'Nial

In 1982, Jenkins formed a company (Nial Systems Ltd) to market the language and the Q'Nial implementation of Nial. As of 2014, the company website supports an Open Source project for the Q'Nial software with the binary and source available for download. Its license is derived from Artistic License 1.0, the only differences being the preamble, the definition of "Copyright Holder" (which is changed from "whoever is named in the copyright or copyrights for the package" to "NIAL Systems Limited"), and an instance of "whoever" (which is changed to "whomever").

## Nial concepts

Nial uses a generalized and expressive Array Theory in its Version 4, but sacrificed some of the generality of functional model, and modified the Array Theory in the Version 6. Only Version 6 is available now.

Nial defines all its data types as nested rectangular arrays. ints, booleans, chars etc. are considered as a solitary array or an array containing a single member. Arrays themselves can contain other arrays to form arbitrarily deep structures. Nial also provides Records. They are defined as non-homogenous array structure.

Functions in Nial are called Operations. From Nial manual: "An operation is a functional object that is given an argument array and returns a result array. The process of executing an operation by giving it an argument value is called an operation call or an operation application."

## Application of operations

Nial like other APL-derived languages allows the unification of binary operators and operations. Thus the below notations have the same meaning. Note: sum is same as +

Binary operation:

Array notation:

Strand notation:

Grouped notation:

Nial also uses transformers which are higher order functions. They use the argument operation to construct a new modified operation.

## Atlas

An atlas in Nial is an operation made up of an array of component operations. When an atlas is applied to a value, each element of the atlas is applied in turn to the value to provide an result. This is used to provide point free (without-variables) style of definitions. It is also used by the transformers. In the below examples 'inner [+,*]' the list '[+,*]' is an atlas.

## Examples

### Creating arrays

Arrays can also be literal

Shape gives the array dimensions and reshape can be used to reshape the dimensions.

### Computing an average

Definitions are of the form '<name> is <expression>'

### Generating primes

Contrast with APL

**Explanation**

Defining is_prime filter

Count generates an array [1..N] and pass is N (identity operation). eachright applies is_divisible (pass, element) in each element of count-generated array. Thus this transforms the count-generated array into an array where numbers that can divide N are replaced by '1' and others by '0'. Hence if the number N is prime, sum [transformed array] must be 2 (itself and 1).

Now all that remains is to generate another array using count N, and filter all that are not prime.

### QuickSort

* link joins its argument arrays
* sublist [A,B] returns a list of items of B chosen according to the list of booleans given in A, selecting those items of B where the corresponding item of A is true.
* In a Fork [A,B,C] X the first A is a predicate, and if A(X) is true, then B(X) is returned else C(X) is returned.
* Pass is an identity operation for arrays.

Using it:

