PDLs are the wrong tool for storing and manipulating collections of variable
length strings. There is a very nice tool for that, called "Perl". If the
desire is to make collections of strings that, syntactically, act like like
PDLs, a nice strategy might be to start with thread_define and thereby
implement threading in Perl itself. That would further blur the distinction
between perl lists and PDLs.
Cheers,
Craig
On Jan 20, 2012, at 8:02 AM, Bryan Jurish wrote:
> moin Kare,
>
> I've done something like what I think you're suggesting using PDL, but
> it amounted in my case to mapping all the text symbols to integer
> identifiers (and back) using perl hashes (and arrays), so I could do
> something like:
>
> ##-- setup symbol table for strings in @STRINGS
> $prev = 'NOT_A_SYMBOL';
> @id2sym = map {$prev eq $_ ? qw() : ($prev=$_)} @STRINGS;
> %sym2id = map {($id2sym[$_]=>$_)} (0..$#id2sym);
>
> ##-- encode @STRINGS as a piddle
> $sp = pdl(long, @sym2id{@STRINGS});
>
> ##-- do something interesting
> $which = which($sp==$id2sym{"some symbol"});
>
> ... it would be really nice to have a better way to deal with large
> symbol tables than perl hashes, but this strategy works for me most of
> the time...
>
> marmosets,
> Bryan
>
> On 2012-01-20 14:32, Kåre Edvardsen wrote:
>> I've been away from programming a couple of years now, but got to get
>> back. Are there any news on indexing text arrays in perl/PDL?
>>
>> Something like:
>> which(@txtarr) == "some text";
>>
>> Cheers,
>> Kare
>
>
> --
> Bryan Jurish "There is *always* one more bug."
> [email protected] -Lubarsky's Law of Cybernetic Entomology
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl