Arrays: Difference between revisions

1,377 bytes added ,  4 years ago
Add LIL
m (→‎{{header|PL/I}}: Modified to conform to specification, viz., to retrieve a value from the array.)
(Add LIL)
Line 3,697:
 
</lang>
 
=={{header|LIL}}==
LIL, like Tcl, doesn't manage arrays as such. Indexed lists are used in LIL. The '''list''' command creates a list from the remaining arguments in the statement. The '''index LIST NUM''' command returns the NUM'th item in the list, starting from zero. Lists are copied on assignment. The array-ish functions and operators would be
 
- index LIST NUM, returning the NUM'th item
- count LIST, returning the number of items in the list
- indexof LIST VAL, returning the offset from zero position of where VAL is found in LIST, or an empty string
- filter VARNAME LIST EXPRESSION, returning a new list of filtered items matching EXPRESSION, with the value under test in VARNAME.
- list ..., creating a list from remaining word tokens in the statement.
- append LIST VAL (list VAL values are appended as single items to the given LIST)
- slice LIST FROM-NUM TO-NUM
- foreach VARNAME LIST CODE
- charat STRING NUM, indexing a string for characters
- codeat STRING NUM, indexing a string for the character byte code
- lmap LIST VARNAME..., maps the list items to the given variable names, in the order given.
 
<lang tcl># Not Arrays in LIL
set a [list abc def ghi]
set b [list 4 5 6]
print [index $a 0]
print [index $b 1]
print [count $a]
append b [list 7 8 9]
print [count $b]
print $b</lang>
 
{{out}}
<pre>prompt$ lil arrays.lil
abc
5
3
4
4 5 6 {7 8 9}</pre>
 
=={{header|Lingo}}==
Anonymous user