RosettaCodeData/Task/Apply-a-callback-to-an-array/SIL/apply-a-callback-to-an-array.sil
2026-04-30 12:34:36 -04:00

32 lines
581 B
Text

// avoid executing function definitions
GOTO body
// our function to apply
funcsquare
x * x
return
lblbody
// add some values to the memory buffer
set 256 1
set 257 2
set 258 3
set 259 4
set 260 5
// i is our array pointer
// in sil it's customary to place data in cells > 255
// to avoid interference with ascii variables
i = 256
lblloop
// place value at i where square function expects it
x = get i
// call square function
GOSUB square
printInt x
// increment pointer; this is like i += 1 in C
i + 1
a = 261 - i
// start another iteration if we are below cell 261
if a loop