GetWiki
Nial
ARTICLE SUBJECTS
being →
database →
ethics →
fiction →
history →
internet →
language →
linux →
logic →
method →
news →
policy →
purpose →
religion →
science →
software →
truth →
unix →
wiki →
ARTICLE TYPES
essay →
feed →
help →
system →
wiki →
ARTICLE ORIGINS
critical →
forked →
imported →
original →
Nial
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{Short description|Programming language}}{{for|the village in Iran|Nial, Iran}}{{more citations needed|date=January 2022}}- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
factoids | |
---|---|
Q'Nial
WEB,weblink The Nial Language, GitHub, 17 December 2021, 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:
2 + 3
2 sum 3
Array notation:
2 sum 3
+ [2,3]
sum [2,3]
Strand notation:
sum [2,3]
+ 2 3
sum 2 3
Grouped notation:
sum 2 3
+ (2 3)
sum (2 3)
Nial also uses transformers which are higher order functions. They use the argument operation to construct a new modified operation.
sum (2 3)
twice is transformer f (f f)
twice rest [4, 5, 6, 7, 8]
|6 7 8
twice rest [4, 5, 6, 7, 8]
|6 7 8
Atlas
WEB,weblink Q'Nial Dictionary V7, 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
count 6
|1 2 3 4 5 6
Arrays can also be literal
|1 2 3 4 5 6
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.
|5 6 7 8 9
shape Arr
|5
|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
# 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
|5 6
|7 8
|9 5
{{not a typo|a}} inner[+,*] b
|130 113
|148 145
|130 113
|148 145
Computing an average
Definitions are of the form '
average is / [sum, tally]
average Arr
|7.
average Arr
|7.
Computing a factorial
fact is recur [ 0 =, 1 first, pass, product, -1 +]
fact 4
|24
fact 4
|24
Reversing an array
rev is reshape [ shape, across [pass, pass, converse append ] ]
rev [1, 2, 3, 4]
|4 3 2 1
rev [1, 2, 3, 4]
|4 3 2 1
Generating primes
Contrast with APL
primes is sublist [ each (2 = sum eachright (0 = mod) [pass,count]), pass ] rest count
primes 10
|2 3 5 7
primes 10
|2 3 5 7
Explanation
Checking the divisibility of A by B
is_divisible is 0 = mod [A,B]
Defining is_prime filter
is_divisible is 0 = mod [A,B]
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
- 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.
quicksort is fork [ >= [1 first,tally],
pass,
link [
quicksort sublist [ < [pass, first], pass ],
sublist [ match [pass,first],pass ],
quicksort sublist [ > [pass,first], pass ]
]
]
Using it:
pass,
link [
quicksort sublist [ < [pass, first], pass ],
sublist [ match [pass,first],pass ],
quicksort sublist [ > [pass,first], pass ]
]
]
quicksort [5, 8, 7, 4, 3]
|3 4 5 7 8
|3 4 5 7 8
References
{{Reflist}}- content above as imported from Wikipedia
- "Nial" does not exist on GetWiki (yet)
- time: 1:45am EDT - Sun, May 05 2024
- "Nial" does not exist on GetWiki (yet)
- time: 1:45am EDT - Sun, May 05 2024
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
GETWIKI 23 MAY 2022
The Illusion of Choice
Culture
Culture
GETWIKI 09 JUL 2019
Eastern Philosophy
History of Philosophy
History of Philosophy
GETWIKI 09 MAY 2016
GetMeta:About
GetWiki
GetWiki
GETWIKI 18 OCT 2015
M.R.M. Parrott
Biographies
Biographies
GETWIKI 20 AUG 2014
GetMeta:News
GetWiki
GetWiki
© 2024 M.R.M. PARROTT | ALL RIGHTS RESERVED