Print a sequence (Phix)
- Posted by lib9 in February
- 474 views
Hi,
This would be more suitable for a IRC chat, but I couldn't find any Euphoria channel.
At printf documentation it's said that If args is a sequence, then formats in fmt are applied to successive elements. and the definition is:
printf(integer fn, string fmt, object args={})
Please, consider this:
sequence s = {"line 1", "line 2", "line 3", "line 4"} printf(1, "s: %V\n", s) sequence buffer = {} for i = 1 to length(s) do printf(1, "l: %s\n", s[i]) buffer = append(buffer, s[i]) end for printf(1, "buffer1: %s\n", buffer) printf(1, "buffer2: %s\n\n", string(buffer))
The output is:
- s: "line 1"
l: line 1
l: line 2
l: line 3
l: line 4
buffer1: line 1
buffer2:
- #
- s: "line 1"
But I was expecting that the line buffer1:... would print all the sequence s, but only prints the first element.
To print a sequence, one has to make use of a for or while loop?
Am I interpreting the above instructions in a wrong way?