HP Forums

Full Version: Indexing into a string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm currently working with strings and something very inconsistent is going on.
Lets say I have a string, s, that is something like "This is a very nice day".

However, when I use s(3), it returns a number instead of "i".
I have to use CHAR(s(3)) to get the character.
Surely an index into a string should return a string.
Is there a faster way to index into a string to return a string? Anyone know?
Thanks
-Donald
I also discovered an at() and of() functions that seem to have something to do with strings, but for which there is no documentation. Can these be of use?
I think I've got it!
It's s(3,1) gets 1 character from s at position 3....returns "e" if s contains "The dog".
Quote:I also discovered an at() and of() functions that seem to have something to do with strings, but for which there is no documentation. Can these be of use?

The zero'th list index is also useful. It points to the tail of a list, where the last element can be returned, deleted, or a new element appended to the list.

Example:
L1:={4,9,16}; L1(0):=√(L1);
at(M,I) is a function to index a matrix or string, etc.. or M[I].
of(f,x) is the same as f(x).
Reference URL's