Re: slicing of sequences
James Powell wrote:
>
> -- Program Test.ex --
>
> sequence a, b
>
> a = {{1, 2, 3},
> {4, 5, 6},
> {7, 8, 9}}
> b = a[1..3][3]
>
> -- End Test.ex --
>
> When run, Euphoria responds with:
>
> b = a[1..3][3]
> ^Unknown Command
>
b = a[1..3] is the same as a, a = {{1,2,3},{4,5,6},{7,8,9}} and
the last index [3] doesn't exist so Euphoria complains.
So a[1] = {{1,2,3}}, a[2] = {{4,5,6}} etc.
You need to write b[1] = a[1][3]. Put it in a loop.
for i = 1 to length(a) do
b[i] = a[i][3]
end for
b = {3,6,9}
Marcel Kollenaar
|
Not Categorized, Please Help
|
|