Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

21 May, 2024: Computers section is temporarily disabled for maintenance. It will take several days before it's back.


devel / comp.lang.tcl / missing feature in TCL → advanced array

SubjectAuthor
* missing feature in TCL → advanced arrayaotto1968
+- Re: missing feature in TCL → advanced arrayet99
`* Re: missing feature in TCL → advanced arrayGerald Lester
 `* Re: missing feature in TCL → advanced arrayaotto1968
  +* Re: missing feature in TCL → advanced arrayChristian Gollwitzer
  |`- Re: missing feature in TCL → advanced arrayaotto1968
  `- Re: missing feature in TCL → advanced arrayRich

1
missing feature in TCL → advanced array

<tvnj1i$2ajt9$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21593&group=comp.lang.tcl#21593

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: missing_feature_in_TCL_→_advanced_array
Date: Sat, 25 Mar 2023 20:45:54 +0100
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <tvnj1i$2ajt9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 25 Mar 2023 19:45:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1b8aadb0eddbb2441791993372ad0d94";
logging-data="2445225"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BxPVD+i/Fk3mv1tE7U3QwKNJdZ20CsEQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:RBpTHh61r2kLyck4HfBynzFmHvE=
Content-Language: en-US
 by: aotto1968 - Sat, 25 Mar 2023 19:45 UTC

Hi,

one of my TCL projects using an ARRAY to match a source-key to a target, example:

array set map_M2S_local {
ME_NB1_MK_BOL Byte

ME_NI1_MK_BYT SByte
ME_NI2_MK_SRT Int16
ME_NI4_MK_INT Int32
ME_NI8_MK_WID Int64
ME_NF4_MK_FLT Single
ME_NF8_MK_DBL Double

ME_NI4_MK_DBG Int32
ME_NI4_MQ_HDL Int32
ME_NI4_MK_NUM Int32
ME_NI4_MQ_SLAVE_ID Int32
ME_NI4_MQ_SOCK_HDL Int32
ME_NI4_MQ_LTR Int32
ME_NI4_MQ_ROU Int32

ME_PVO_MK_PTR IntPtr
ME_PBI_MK_BIN IntPtr
ME_PBN_MK_BINN IntPtr
ME_PSN_MQ_TOKEN IntPtr
ME_PSS_MK_STR IntPtr
ME_PSN_MK_STRN IntPtr
ME_PFS_MK_FST IntPtr
ME_PLI_MK_LST IntPtr
ME_PVO_IDNT IntPtr

ME_REF_MkBinaryR IntPtr
....
}

as you see there are many items which hast *multiple* keys BUT a *unique* target.

example ME_NI4_* is always mapping to *Int32*

Problem: for a *new* key this array have *always* been updated even if the *new* follow
the already known ME_NI4_* → Int32 syntax.

NEW

It would be nice to have an ARRAY which is able to use a key with pattern or regexp matching

array set ?-glob? map_M2S_local {
ME_NB1_MK_BOL Byte

ME_NI1_MK_BYT SByte
ME_NI2_MK_SRT Int16
ME_NI4_MK_INT Int32
ME_NI8_MK_WID Int64
ME_NF4_MK_FLT Single
ME_NF8_MK_DBL Double

ME_NI4_* Int32

ME_P* IntPtr

ME_REF_MkBinaryR IntPtr
....
}

and '$map_M2S_local(ME_NI4_something)' would return *Int32*

I know that it is possible to implement this as *switch* with a lot of "writing" in a 'proc' as wrapper

mfg AO

Re: missing feature in TCL → advanced array

<tvnm6m$2b2s2$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21595&group=comp.lang.tcl#21595

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re:_missing_feature_in_TCL_→_advanced_array
Date: Sat, 25 Mar 2023 13:39:50 -0700
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <tvnm6m$2b2s2$1@dont-email.me>
References: <tvnj1i$2ajt9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 25 Mar 2023 20:39:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="42898c68fd6f65ecdb4ebb33be4ed882";
logging-data="2460546"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hR0B/Qtnh0TLMcu9ktisG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:NCYHT3J2yO4hKwk3ub7P4kAiHWc=
Content-Language: en-US
In-Reply-To: <tvnj1i$2ajt9$1@dont-email.me>
 by: et99 - Sat, 25 Mar 2023 20:39 UTC

On 3/25/2023 12:45 PM, aotto1968 wrote:
>
> Hi,
>
>  one of my TCL projects using an ARRAY to match a source-key to a target, example:
>
> array set map_M2S_local {
>     ME_NB1_MK_BOL             Byte
>
>     ME_NI1_MK_BYT             SByte
>     ME_NI2_MK_SRT             Int16
>     ME_NI4_MK_INT             Int32
>     ME_NI8_MK_WID             Int64
>     ME_NF4_MK_FLT             Single
>     ME_NF8_MK_DBL             Double
>
>     ME_NI4_MK_DBG             Int32
>     ME_NI4_MQ_HDL             Int32
>     ME_NI4_MK_NUM             Int32
>     ME_NI4_MQ_SLAVE_ID        Int32
>     ME_NI4_MQ_SOCK_HDL        Int32
>     ME_NI4_MQ_LTR             Int32
>     ME_NI4_MQ_ROU             Int32
>
>     ME_PVO_MK_PTR             IntPtr
>     ME_PBI_MK_BIN             IntPtr
>     ME_PBN_MK_BINN            IntPtr
>     ME_PSN_MQ_TOKEN           IntPtr
>     ME_PSS_MK_STR             IntPtr
>     ME_PSN_MK_STRN            IntPtr
>     ME_PFS_MK_FST             IntPtr
>     ME_PLI_MK_LST             IntPtr
>     ME_PVO_IDNT               IntPtr
>
>     ME_REF_MkBinaryR          IntPtr
> ...
> }
>
> as you see there are many items which hast *multiple* keys BUT a *unique* target.
>
> example ME_NI4_* is always mapping to *Int32*
>
> Problem: for a *new* key this array have *always* been updated even if the *new* follow
> the already known ME_NI4_* → Int32 syntax.
>
> NEW
>
> It would be nice to have an ARRAY which is able to use a key with pattern or regexp matching
>
> array set ?-glob? map_M2S_local {
>     ME_NB1_MK_BOL             Byte
>
>     ME_NI1_MK_BYT             SByte
>     ME_NI2_MK_SRT             Int16
>     ME_NI4_MK_INT             Int32
>     ME_NI8_MK_WID             Int64
>     ME_NF4_MK_FLT             Single
>     ME_NF8_MK_DBL             Double
>
>     ME_NI4_*                  Int32
>
>     ME_P*                     IntPtr
>
>     ME_REF_MkBinaryR          IntPtr
> ...
> }
>
> and '$map_M2S_local(ME_NI4_something)' would return *Int32*
>
> I know that it is possible to implement this as *switch* with a lot of "writing" in a 'proc' as wrapper
>
>
> mfg AO

I think you can accomplish this with a foreach loop and [array names]

# (untested code)
# lookup is the key you are interested in
set result "" ;# if not found
foreach key [array names map_M2S_local] {
if { [string match $key $lookup] } {
set result $map_M2S_local($key)
break
}
}

Re: missing feature in TCL → advanced array

<4HNTL.1176413$gGD7.339810@fx11.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21597&group=comp.lang.tcl#21597

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.7.1
Subject: Re:_missing_feature_in_TCL_→_advanced_array
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <tvnj1i$2ajt9$1@dont-email.me>
From: Gerald.Lester@gmail.com (Gerald Lester)
In-Reply-To: <tvnj1i$2ajt9$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 81
Message-ID: <4HNTL.1176413$gGD7.339810@fx11.iad>
X-Complaints-To: abuse@fastusenet.org
NNTP-Posting-Date: Sun, 26 Mar 2023 02:00:32 UTC
Organization: fastusenet - www.fastusenet.org
Date: Sat, 25 Mar 2023 21:00:32 -0500
X-Received-Bytes: 3602
 by: Gerald Lester - Sun, 26 Mar 2023 02:00 UTC

On 3/25/23 14:45, aotto1968 wrote:
>
> Hi,
>
>  one of my TCL projects using an ARRAY to match a source-key to a
> target, example:
>
> array set map_M2S_local {
>     ME_NB1_MK_BOL             Byte
>
>     ME_NI1_MK_BYT             SByte
>     ME_NI2_MK_SRT             Int16
>     ME_NI4_MK_INT             Int32
>     ME_NI8_MK_WID             Int64
>     ME_NF4_MK_FLT             Single
>     ME_NF8_MK_DBL             Double
>
>     ME_NI4_MK_DBG             Int32
>     ME_NI4_MQ_HDL             Int32
>     ME_NI4_MK_NUM             Int32
>     ME_NI4_MQ_SLAVE_ID        Int32
>     ME_NI4_MQ_SOCK_HDL        Int32
>     ME_NI4_MQ_LTR             Int32
>     ME_NI4_MQ_ROU             Int32
>
>     ME_PVO_MK_PTR             IntPtr
>     ME_PBI_MK_BIN             IntPtr
>     ME_PBN_MK_BINN            IntPtr
>     ME_PSN_MQ_TOKEN           IntPtr
>     ME_PSS_MK_STR             IntPtr
>     ME_PSN_MK_STRN            IntPtr
>     ME_PFS_MK_FST             IntPtr
>     ME_PLI_MK_LST             IntPtr
>     ME_PVO_IDNT               IntPtr
>
>     ME_REF_MkBinaryR          IntPtr
> ...
> }
>
> as you see there are many items which hast *multiple* keys BUT a
> *unique* target.
>
> example ME_NI4_* is always mapping to *Int32*
>
> Problem: for a *new* key this array have *always* been updated even if
> the *new* follow
> the already known ME_NI4_* → Int32 syntax.
>
> NEW
>
> It would be nice to have an ARRAY which is able to use a key with
> pattern or regexp matching
>
> array set ?-glob? map_M2S_local {
>     ME_NB1_MK_BOL             Byte
>
>     ME_NI1_MK_BYT             SByte
>     ME_NI2_MK_SRT             Int16
>     ME_NI4_MK_INT             Int32
>     ME_NI8_MK_WID             Int64
>     ME_NF4_MK_FLT             Single
>     ME_NF8_MK_DBL             Double
>
>     ME_NI4_*                  Int32
>
>     ME_P*                     IntPtr
>
>     ME_REF_MkBinaryR          IntPtr
> ...
> }
>
> and '$map_M2S_local(ME_NI4_something)' would return *Int32*
>
> I know that it is possible to implement this as *switch* with a lot of
> "writing" in a 'proc' as wrapper
>

Read the man/doc page for the array command, pay particular attention to
the name subcommand.

Re: missing feature in TCL → advanced array

<tvopth$2jb9q$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21599&group=comp.lang.tcl#21599

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re:_missing_feature_in_TCL_→_advanced_array
Date: Sun, 26 Mar 2023 08:49:21 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <tvopth$2jb9q$2@dont-email.me>
References: <tvnj1i$2ajt9$1@dont-email.me>
<4HNTL.1176413$gGD7.339810@fx11.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 26 Mar 2023 06:49:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6d429f7773f85aa54332d842973517fa";
logging-data="2731322"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19N8kCz7LyfisERY8Oy9wNCwlx8dNu2o4M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:KVY/CIFYNvRb/kJ1v2h5detB3JI=
Content-Language: en-US
In-Reply-To: <4HNTL.1176413$gGD7.339810@fx11.iad>
 by: aotto1968 - Sun, 26 Mar 2023 06:49 UTC

On 26.03.23 04:00, Gerald Lester wrote:
> On 3/25/23 14:45, aotto1968 wrote:
>>
>> Hi,
>>

>>
>
> Read the man/doc page for the array command, pay particular attention to the name subcommand.
>
>

It is clear that the pattern is the KEY and not the LOOKUP.

array set test {
key??next* myValueToSearchFor
}

set test(key12nextSomething) -> myValueToSearchFor

I already know that it is possible to transform an array into a list (array names ..., array get ...) and process
each entry (one by one) BUT you loose all speed advantages of an array. just assume that the array has 1 million entries
and you will understand that loop over oneBYone is not the best choice.

I know it is NOT trivial to use a PATTERN as key in an array

-ao

Re: missing feature in TCL → advanced array

<tvov2b$2k9mo$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21600&group=comp.lang.tcl#21600

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re:_missing_feature_in_TCL_→_advanced_array
Date: Sun, 26 Mar 2023 10:17:15 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <tvov2b$2k9mo$1@dont-email.me>
References: <tvnj1i$2ajt9$1@dont-email.me>
<4HNTL.1176413$gGD7.339810@fx11.iad> <tvopth$2jb9q$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 26 Mar 2023 08:17:15 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9179f39a5015e44fb8e09afc5635760a";
logging-data="2762456"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wWsteMx8qk+WDmI973NGmhQFlC1FGkcs="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.9.0
Cancel-Lock: sha1:YX0iumFnZZ53L3ch8xe8P1sjKyA=
In-Reply-To: <tvopth$2jb9q$2@dont-email.me>
 by: Christian Gollwitzer - Sun, 26 Mar 2023 08:17 UTC

Am 26.03.23 um 08:49 schrieb aotto1968:
> On 26.03.23 04:00, Gerald Lester wrote:
>
> It is clear that the pattern is the KEY and not the LOOKUP.
>
> array set test {
>   key??next*    myValueToSearchFor
> }
>
> set test(key12nextSomething) -> myValueToSearchFor
>
> I already know that it is possible to transform an array into a list
> (array names ..., array get ...) and process
> each entry (one by one) BUT you loose all speed advantages of an array.
> just assume that the array has 1 million entries
> and you will understand that loop over oneBYone is not the best choice. >
> I know it is NOT trivial to use a PATTERN as key in an array

And how would you think it is possible to implement such a feature, if
not by looping over the entries one by one? It would help of course when
the lookup goes to the C level instead of a Tcl level loop, but you
would still spend most of the time matching the patterns one by one.

There is one (half-theoretical) other way to get faster lookups, that is
by transforming the patterns into a giant state machine where the end
points correspond to the patterns. Basically this is what "lex" does. As
you can imagine, transforming 1 million patterns into a single state
machine is going to take a very long time and consume lots of memory. It
can be done once for a static array and then applied multiple times, but
it is not suitable for a dynamic construct like an array.
Christian

Re: missing feature in TCL → advanced array

<tvp05n$2kfog$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21601&group=comp.lang.tcl#21601

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re:_missing_feature_in_TCL_→_advanced_array
Date: Sun, 26 Mar 2023 10:36:07 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <tvp05n$2kfog$1@dont-email.me>
References: <tvnj1i$2ajt9$1@dont-email.me>
<4HNTL.1176413$gGD7.339810@fx11.iad> <tvopth$2jb9q$2@dont-email.me>
<tvov2b$2k9mo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 26 Mar 2023 08:36:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6d429f7773f85aa54332d842973517fa";
logging-data="2768656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TtfaK90m13cQvMVRTrMnFreOGfj1rUVs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:k/WdComJpNwI5MYB8YnVrWIM0/w=
In-Reply-To: <tvov2b$2k9mo$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Sun, 26 Mar 2023 08:36 UTC

On 26.03.23 10:17, Christian Gollwitzer wrote:
> Am 26.03.23 um 08:49 schrieb aotto1968:
>> On 26.03.23 04:00, Gerald Lester wrote:
>>
>> It is clear that the pattern is the KEY and not the LOOKUP.
>>
>> array set test {
>>    key??next*    myValueToSearchFor
>> }
>>
>> set test(key12nextSomething) -> myValueToSearchFor
>>
>> I already know that it is possible to transform an array into a list (array names ..., array get ...) and process
>> each entry (one by one) BUT you loose all speed advantages of an array. just assume that the array has 1 million entries
>> and you will understand that loop over oneBYone is not the best choice. >
>> I know it is NOT trivial to use a PATTERN as key in an array
>
> And how would you think it is possible to implement such a feature, if not by looping over the entries one by one? It would help
> of course when the lookup goes to the C level instead of a Tcl level loop, but you would still spend most of the time matching
> the patterns one by one.
>
> There is one (half-theoretical) other way to get faster lookups, that is by transforming the patterns into a giant state machine
> where the end points correspond to the patterns. Basically this is what "lex" does. As you can imagine, transforming 1 million
> patterns into a single state machine is going to take a very long time and consume lots of memory. It can be done once for a
> static array and then applied multiple times, but it is not suitable for a dynamic construct like an array.
>
>     Christian
>
>

read the key from LEFT to RIGHT

start: myValueToSearchFor
loop until ONE or NOTHING {
-> step one: get all keys match m*
-> -> from solution of step one: get all keys match my* ... etc
}

The GOAL is to intelligent select the KEYS to just a SINGLE one using a B-TREE like key.

-ao

Re: missing feature in TCL → advanced array

<tvpoh8$2oflm$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=21612&group=comp.lang.tcl#21612

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: missing feature in TCL → advanced array
Date: Sun, 26 Mar 2023 15:31:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <tvpoh8$2oflm$2@dont-email.me>
References: <tvnj1i$2ajt9$1@dont-email.me> <4HNTL.1176413$gGD7.339810@fx11.iad> <tvopth$2jb9q$2@dont-email.me>
Injection-Date: Sun, 26 Mar 2023 15:31:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c9f82d72910fc473ea44df25d95f7d12";
logging-data="2899638"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193/uqAf3TpJZz6RyAYcNqb"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:I3P1XnSVQCgONooG4Pnmxsz+dSg=
 by: Rich - Sun, 26 Mar 2023 15:31 UTC

aotto1968 <aotto1968@t-online.de> wrote:
> On 26.03.23 04:00, Gerald Lester wrote:
>> Read the man/doc page for the array command, pay particular
>> attention to the name subcommand.
>
> It is clear that the pattern is the KEY and not the LOOKUP.
>
> array set test {
> key??next* myValueToSearchFor
> }
>
> set test(key12nextSomething) -> myValueToSearchFor
>
> I already know that it is possible to transform an array into a list
> (array names ..., array get ...) and process each entry (one by one)
> BUT you loose all speed advantages of an array. just assume that the
> array has 1 million entries and you will understand that loop over
> oneBYone is not the best choice.
>
> I know it is NOT trivial to use a PATTERN as key in an array

With 'pre-processing' of the array contents, you can somewhat
simulate a "pattern" as a key.

Preprocess your groups of strings belonging to the same output to find
the shortest common prefix of each set (note, be careful of overlapping
prefixes for different sets). Then for each 'shortest common prefix"
append your own 'custom' pattern suffix, and store that as the key:

array set map {PLE_1% something
XYX_P23_% something}

Then, for a string PLE_145, you look for:
PLE_145
PLE_145%
PLE_14%
PLE_1%

until you find a match.

You will have, at most, a number of lookups equal to the character
length of the removed suffix string. Which will be shorter than the
fully duplicative array. But the compacted array will be much smaller,
reducing memory usage. You will have to decide which you want to trade
off, speed of lookup or consumption of memory.


devel / comp.lang.tcl / missing feature in TCL → advanced array

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor