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.

Uses your system voice; voice and rate in settings.

Snapshot

≈ 2 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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.

Arr := [5, 6, 7, 8, 9] |5 6 7 8 9 Shape gives the array dimensions and reshape can be used to reshape the dimensions. shape Arr |5 a := 2 3 reshape Arr # reshape is a binary operation with two arguments. It can also be written in prefix as # a := reshape [[2,3], Arr] |5 6 7 |8 9 5 b := 3 2 reshape Arr |5 6 |7 8 |9 5 inner[+,*] b |130 113 |148 145 fact is recur [ 0 =, 1 first, pass, product, -1 +] fact 4 |24 primes is sublist [ each (2 = sum eachright (0 = mod) [pass,count]), pass ] rest count primes 10 |2 3 5 7 is_divisible is 0 = mod [A,B] Defining is_prime filter is_prime is 2 = sum eachright is_divisible [pass,count] 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. primes is sublist [each is_prime, pass] rest count quicksort is fork [ >= [1 first,tally], pass, link [ quicksort sublist [ [pass,first], pass ] ] ] Using it: quicksort [5, 8, 7, 4, 3] |3 4 5 7 8

Text derived from https://en.wikipedia.org/w/index.php?oldid=1369367559 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

2 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.