Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
Artist
If we have an array of data items, for example :
Array <:: ("woo", "yay", "squee", "foo", "bar");
then we can select one or more of them by use of the indexing or subscripting operation :
ttyout ( Array [3] );
will display "squee" on the screen. Note that as in APL, we may make multiple selections :
ttyout ( Array [5, 5, 1, 1, 2] );
prints "bar bar woo woo squee" (or actually "barbarwoowoosquee", I added the spaces for clarity). As well as the standard C++ square bracket syntax, the BCPL bang (!) syntax can be used :
ttyout ( Array!2);
for example prints "yay". Note that ::SHE+ILA:: uses origin 1 indexing, like Fortran, as opposed to Origin 0 indexing like C++. This is because element 0 is automatically allocated to the symbol table of the array, for example :
Record <:: (firstname="Squishy", surname="Plushie", age=71, gender="Enby", pronoun="they");
allowing named rather than numbered access to each element of an array or record. We then use the dot (.) operator to select the desired element :
ttyout ( Record.firstname, " ", Record.surname, " is ", Record.age, " and " Record.pronoun, " are ", Record.gender);
This is like Pascal's record or C++'s class or struct.
Finally, ::SHE+ILA:: has a wealth of array operations, inspired by APL. For example, we can make an array of consecutive integers with the Range operator (_), as in
X <:: 1_9;
which work just like the APL "iota" operator, and reverse or rotate it with the "$~" operator :
ttyout ( $~X ); prints 9 8 7 6 5 4 3 2 1
and ttyout ( 3 $~ X ); prints 4 5 6 7 8 9 1 2 3
Finally for now, "#" like the APL rho operator, or the Basic LEN() operator, and gives the number of elements in an array :
ttyout (#X); prints 9.