Anonymous user
Apply a callback to an array: Difference between revisions
→TI-89 BASIC: new example
(add m4) |
(→TI-89 BASIC: new example) |
||
Line 1,063:
% map square {1 2 3 4 5}
1 4 9 16 25</lang>
=={{header|TI-89 BASIC}}==
<pre style="font-family:'TI Uni'">© For no return value
Define foreach(fe_cname,fe_list) = Prgm
Local fe_i
For fe_i,1,dim(fe_list)
#fe_cname(fe_list[fe_i])
EndFor
EndPrgm
© For a list of results
Define map(map_cnam,map_list) = seq(#map_cnam(map_list[map_i]),map_i,1,dim(map_list))
Define callback(elem) = Prgm
Disp elem
EndPrgm
foreach("callback", {1,2,3,4,5})
Disp map("√", {1,2,3,4,5})</pre>
Output:
<math>1</math><br>
<math>2</math><br>
<math>3</math><br>
<math>4</math><br>
<math>5</math><br>
<math>\begin{Bmatrix}1 & \sqrt{2} & \sqrt{3} & 2 & \sqrt{5}\end{Bmatrix}</math>
=={{header|Toka}}==
|