Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,52 +1,38 @@
|
|||
-- 8 Sep 2025
|
||||
-- 31 Mar 2026
|
||||
include Setting
|
||||
numeric digits 4
|
||||
|
||||
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)'
|
||||
say 'Generate...'
|
||||
call Struct2stem 'stem.','1 2 3 4 5 6 7 8 9 10'
|
||||
call ShowSt 'stem.','1 to 10 ascending',,7
|
||||
call CopySt 'stem.','copy.'
|
||||
|
||||
say 'Single function Square'
|
||||
call MapSt 'stem.','square'
|
||||
call ShowSt 'stem.','after square',,7
|
||||
|
||||
say 'Your own function Cubic...'
|
||||
call CopySt 'copy.','stem.'
|
||||
call MapSt 'stem.','cube'
|
||||
call ShowSt 'stem.','after cube',,7
|
||||
|
||||
say 'Expression x^2+2x+3...'
|
||||
call CopySt 'copy.','stem.'
|
||||
call MapSt 'stem.','x**2+2*x+3'
|
||||
call ShowSt 'stem.','after simple formula',,7
|
||||
|
||||
say 'Expression Sin(x)+Square(x)...'
|
||||
call CopySt 'copy.','stem.'
|
||||
call MapSt 'stem.','sin(x)+square(x)'
|
||||
call ShowSt 'stem.','after more involved formula',,7
|
||||
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:
|
||||
Cubic:
|
||||
arg xx
|
||||
return xx**2
|
||||
return xx**3
|
||||
|
||||
-- MapSt; Struct2stem; ShowSt; CopySt; Square; Sin
|
||||
include Math
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue