Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,38 @@
pr. = /*define a default for all elements for the array*/
pr.1 = 2 /*note that this array starts at 1 (one). */
pr.2 = 3
pr.3 = 5
pr.4 = 7
pr.5 = 11
pr.6 = 13
pr.7 = 17
pr.8 = 19
pr.9 = 23
pr.10 = 29
pr.11 = 31
pr.12 = 37
pr.13 = 41
pr.14 = 43
pr.15 = 47
y. = 0 /*define a default for all years (Y) to be zero*/
y.1985 = 6020
y.1986 = 7791
y.1987 = 8244
y.1988 = 10075
x = y.2012 /*the variable X will have a value of zero (0).*/
fib.0 = 0 /*this stemmed arrays will start with zero (0). */
fib.1 = 1
fib.2 = 1
fib.3 = 2
fib.4 = 3
fib.5 = 5
fib.6 = 8
fib.7 = 17
do n=-5 to 5 /*define a stemmed array from -5 to 5 */
sawtooth.n = n /*the sawtooth array is, well, a sawtooth curve*/
end /*n*/ /*note that eleven elements will be defined. */

View file

@ -0,0 +1 @@
pr.0= 15 /*number of (data) entries in the stemmed array. */

View file

@ -0,0 +1,6 @@
do j=1 while pr.j\==''
say 'prime' j "is" pr.j
end /*j*/
/*at this point, J=16 (because of the DO */
/*loop incrementing the index. */
j= j-1 /*J now has the count of primes stored. */

View file

@ -0,0 +1,15 @@
primeList = '2 3 5 7 11 13 17 19 23 29 31 37 41 43' /* or ··· */
primeList = 2 3 5 7 11 13 17 19 23 29 31 37 41 43
/*in this case, the quotes (') can be elided.*/
primes= words(primeList) /*the WORDS BIF counts the number of blank─ */
/*separated words (in this case, prime numbers)*/
/*in the value of the variable "primeList".*/
do j=1 for primes /*can also be coded as: do j=1 to primes */
say 'prime' j "is" word(primeList, j)
/*this method (using the WORD BIF) isn't */
/*very efficient for very large arrays (those */
/*with many many thousands of elements). */
end /*j*/

View file

@ -0,0 +1,50 @@
pr. = 0 /*define a default for all elements for the array.*/
pr.2 = 1
pr.3 = 1
pr.5 = 1
pr.7 = 1
pr.11 = 1
pr.13 = 1
pr.17 = 1
pr.19 = 1
pr.23 = 1
pr.29 = 1
pr.31 = 1
pr.37 = 1
pr.41 = 1
pr.43 = 1
pr.47 = 1
/*──────────────────────────────────────────────────────────────────────────────────────*/
primes=0
do j=1 for 10000 /*this method isn't very efficient. */
if \pr.j then iterate /*Not prime? Then skip this element. */
primes = primes + 1 /*bump the number of primes (counter).*/
end /*j*/
/*note that the 10000 is a small "∞".*/
say '# of primes in list:' primes
/*──────────────────────────────────────────────────────────────────────────────────────*/
#primes=0
do j=1 for 10000 /*this method is not very efficient. */
if pr.j\==0 then #primes = #primes + 1 /*Not zero? Bump the number of primes.*/
end /*j*/ /* [↑] not as idiomatic as 1st program*/
say '# of primes in the list:' #primes
/*──────────────────────────────────────────────────────────────────────────────────────*/
Ps=0
do k=1 for 10000 /*and yet another inefficient method. */
if pr.k==0 then iterate /*Not a prime? Then skip this element.*/
Ps = Ps + 1 /*bump the counter for the # of primes.*/
say 'prime' Ps "is:" k /*might as well echo this prime number.*/
end /*k*/
say 'The number of primes found in the list is ' Ps
/*──────────────────────────────────────────────────────────────────────────────────────*/
pr.0 = 47 /*hardcode the highest prime in array. */
# = 0
do k=2 to pr.0 /*and much more efficient method. */
if \pr.k then iterate /*Not a prime? Then skip this element.*/
# = # + 1 /*bump the counter for the # of primes.*/
say 'prime' Ps "is:" k /*might as well echo this prime number.*/
end /*k*/
say 'The number of primes found in the list is: ' #