Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,23 +1,52 @@
/*REXX program applies a callback to an array (using factorials for a demonstration).*/
numeric digits 100 /*be able to display some huge numbers.*/
parse arg # . /*obtain an optional value from the CL.*/
a.= /*initialize the array A to all nulls*/
if #=='' | #=="," then #= 12 /*Not assigned? Then use default value*/
do j=0 to #; a.j= j /*assign the integer J ───► A.j */
end /*j*/ /*array A will have N values: 0 ──► #*/
-- 8 Sep 2025
include Setting
call listA 'before callback' /*display A array before the callback*/
say /*display a blank line for readability.*/
say ' ··· applying callback to array A ···' /*display what is about to happen to B.*/
say /*display a blank line for readability.*/
call bangit 'a' /*factorialize (the values) of A array.*/
/* store the results ───► array B.*/
call listA ' after callback' /*display A array after the callback.*/
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
bangit: do v=0; $= value(arg(1)'.'v); if $=='' then return /*No value? Then return*/
call value arg(1)'.'v, fact($) /*assign a value (a factorial) to array*/
end /*i*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
fact: procedure; arg x; != 1; do f=2 to x; != !*f; end; /*f*/; return !
listA: do k=0 while a.k\==''; say arg(1) 'a.'k"=" a.k; end /*k*/; return
say 'APPLY A CALLBACK TO AN ARRAY'
say version
say
call Task 'x'
call Task ''
call Task 'Sqrt(x)'
call Task 'Sin(x)'
call Task 'Exp(x)'
exit
Task:
-- Get function to apply
parse arg function
-- Example array with x-values
array.=0; n=10
do i = 1 to n
array.i=i
end
array.0 = n
if function = '' then do
-- Apply fixed function to each element
do i = 1 to array.0
array.i=Square(array.i)
end
function='Square(x)'
end
else do
-- Apply dynamic function to each element
do i = 1 to array.0
array.i=Std(Eval(function,array.i)/1)
end
end
-- Show after callback
call Show
return
Show:
say ' x' function
do i = 1 to n
say Right(i,2) array.i
end
say
return
Square:
arg xx
return xx**2
include Math