update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -0,0 +1,66 @@
|
|||
void
|
||||
show_sublist(list l)
|
||||
{
|
||||
integer i;
|
||||
|
||||
i = 0;
|
||||
while (i < l_length(l)) {
|
||||
if (i) {
|
||||
o_space(1);
|
||||
}
|
||||
o_integer(l_q_integer(l, i));
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
show_list(list l)
|
||||
{
|
||||
integer i;
|
||||
|
||||
i = 0;
|
||||
while (i < l_length(l)) {
|
||||
o_text(" [");
|
||||
show_sublist(l_q_list(l, i));
|
||||
o_text("]");
|
||||
i += 1;
|
||||
}
|
||||
|
||||
o_byte('\n');
|
||||
}
|
||||
|
||||
list
|
||||
multiple_distinct(integer n, object o)
|
||||
{
|
||||
list l;
|
||||
|
||||
while (n) {
|
||||
l_append(l, o);
|
||||
n -= 1;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
integer
|
||||
main(void)
|
||||
{
|
||||
list l, z;
|
||||
|
||||
# create a list of integers - `3' will serve as initializer
|
||||
l = multiple_distinct(8, 3);
|
||||
|
||||
l_clear(l);
|
||||
|
||||
# create a list of distinct lists - `z' will serve as initializer
|
||||
l_append(z, 4);
|
||||
l = multiple_distinct(8, z);
|
||||
|
||||
# modify one of the sublists
|
||||
l_r_integer(l_q_list(l, 3), 0, 7);
|
||||
|
||||
# display the list of lists
|
||||
show_list(l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const func array file: openFiles (in array string: fileNames) is func
|
||||
result
|
||||
var array file: fileArray is 0 times STD_NULL; # Define array variable
|
||||
local
|
||||
var integer: i is 0;
|
||||
begin
|
||||
fileArray := length(fileNames) times STD_NULL; # Array size computed at run-time
|
||||
for key i range fileArray do
|
||||
fileArray[i] := open(fileNames[i], "r"); # Assign multiple distinct objects
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var array file: files is 0 times STD_NULL;
|
||||
begin
|
||||
files := openFiles([] ("abc.txt", "def.txt", "ghi.txt", "jkl.txt"));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue