Iterators: Difference between revisions

Iterators en FreeBASIC
(Realize in F#)
(Iterators en FreeBASIC)
Line 111:
Purple Orange Red
</pre>
=={{header|J}}==
 
 
=={{header|FreeBASIC}}==
<lang freebasic>Dim As Integer n, m
Dim As String list(1 To 2, 1 To 7) = {_
{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}, _
{"Red","Orange","Yellow","Green","Blue","Purple"}}
Dim As Integer ind(1 To 3) = {1,4,5}
 
Print "All elements:"
For n = 1 To Ubound(list)
For m = 1 To Ubound(list, 2)
Print list(n, m); " ";
Next m
Print
Next n
 
Print !"\nFirst, fourth, and fifth elements:"
For n = 1 To Ubound(list)
For m = 1 To Ubound(ind)
Print list(n, ind(m)); " ";
Next m
Print
Next n
 
Print !"\nReverse first, fourth, and fifth elements:"
For m = 1 To Ubound(ind)
Print list(1, Ubound(list,2)+1-ind(m)); " ";
Next m
Print
For m = 1 To Ubound(ind)
Print list(2, Ubound(list,2)-ind(m)); " ";
Next m
Sleep</lang>
{{out}}
<pre>
Same as C++ input, Julia, Phix or Wren.
</pre>
 
 
=={{header|J}}==
J's operations are designed to be applied to the data structure as a whole, and this explicitly includes mapping between representations. Also, all data in J is array-like, and type is data. And this necessarily includes linked lists (though we can introduce arbitrarily complex mechanisms to obfuscate a linked list structure).
 
2,123

edits