Re: [Phix Tutorial] Basic Sequence Actions
- Posted by archeopteryx_08 Jan 28, 2019
- 1401 views
The idea of "gap" only came to me a few days ago. But it seems to help visualize how sequence works.
_tom
When using the elastic frame/billiard ball imagery as a beginner to visualise how sequences look and how they work, i distinguished between the structure of a sequence and its syntax, because sometimes the two don't correspond.
For example, i saw something like this somewhere in the docs:
sequence s = { object1, object2, object3, $ }
... and i kept wondering how to visualise the $ as part of the structure of the sequence. In the end i realised i couldn't! I had to visualise the structure of the sequence as ||object1|object2|object3||, and its syntactical representation as written above (where $ just meant the index of the last element). From then on I was free to imagine elements of sequences barging their way between other elements (eg as insertions or splices), or at the head of the line (eg prepend) or at the end of the line (eg append), etc. I didn't imagine any gaps between elements of sequences, or between the elastic frame and the first or last element; I'm still getting used to thinking in terms of gaps in the structure of sequences - it isn't intuitive for me yet, but who knows...
The syntax s[ n...n-1 ] to produce an empty sequence, is another example of sequence syntax not necessarily corresponding to sequence structure.
_Arch