On Mon, 2 Nov 2020, Sven Schreiber wrote:
Am 02.11.2020 um 13:39 schrieb Allin Cottrell:
> On Mon, 2 Nov 2020, Artur Tarassow wrote:
>
>> works only for very special case which may confuse the user. True, it
>> is convenient but can be realized by a two-liner:
>> <>
>> series s = {1; 2; 3}
>> stringify(s, defarray("hey", "ho", "aha"))
>> </>
> ...
>
> On your two-liner: Yes, that's fine in the simple case, but here's the
> sort of thing I had in mind (converted to Sven's style):
>
> nulldata 8
> strings S = defarray("A", "B", "B", "A",
"D", "D", "C", "B")
> series sx = S
>
> That is, your primary data take the form of a sequence of strings, and
> the proposed syntax allows you to create a series without the need to
> compute the numerically encoded counterpart yourself.
Exactly - BTW in this context it might in principle also be useful to
have a function that constructs a mapping from the strings array to a
vector of numerical (integer) codes. Doesn't have to be C, could be
hansl, and I personally haven't needed it so far. Still I could give it
a try with hansl if that's wanted.
It would help for that task if values() and uniq() could be applied
to strings arrays as well as vectors, which wouldn't be too
difficult to arrange.
Allin