Raiiiiiaiaiii!iiiai;mii3ii3triaihiiij|jvii?tam, Applying a function recursively to a list, To execute a function on every element of a list – HP 48g Graphing Calculator User Manual
Page 203: Applying a function recursively to a list -5, Sku) 1 ded 2 ded 3 ded, C 1 z 3 4 5
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".
S t e p
Enter the function and execute it.
0
(±3 iENlWI ft^
;ST PROC
1.-
£ £9 4£ 5? }
To apply a procedyre seqyentiaiy to elements of a list:
1. Enter the list.
2. Enter the frame index. This is the number of elements affected by
each iteration of the function. For example, entering 3 would take 3
elements from the list and use them as arguments for the function.
3. Enter the function.
4. Execute DOSUE.
Example:
Find the 2-element moving average of { 1 2 3 4 5 }.
Step 1:
Enter the list, the frame index, and the function.
SKU) 1 dED 2 dED 3 dED
4 fSK:1 5 (ENTER) 2 (ENTER)
063
E
3
2
© dHHH)
I
HDHE }
4s
3:
£:
1
:
iiiiiiiiiflB338ai
C 1 Z 3 4 5 }
Z
« + £ / »
17
Step 2:
Execute DO SUB
(PRG)
P R O C D u S U B
l! { 1.5 Z.5 3.5 4.5 }
raiiiiiaiaiii!iiiai;Mii3ii3TriaiHiiij|jvii?Tam
When writing programs with DOSUB the frame number (the position
of the first object in the frame) is NSUB, and the number of frames is
ENDSUB.
Applying a Function Recursively to a List
The STREAM command lets you apply a function recursively to every
element of a list.
To execute a function on every
element
of
a
list:
1. Enter the list.
2. Enter a program or function. A program or function that takes two
arguments and returns one result is ideal.
Lists and Sequences 17-5