Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Real Programmers don't eat quiche. They eat Twinkies and Szechwan food.


devel / comp.lang.tcl / proposal: lmap is missing the stride option

SubjectAuthor
* proposal: lmap is missing the stride optionaotto1968
+- Re: proposal: lmap is missing the stride optionaotto1968
`* Re: proposal: lmap is missing the stride optionChristian Gollwitzer
 +* Re: proposal: lmap is missing the stride optionChristian Gollwitzer
 |`- Re: proposal: lmap is missing the stride optionaotto1968
 `- Re: proposal: lmap is missing the stride optionaotto1968

1
proposal: lmap is missing the stride option

<t67pjp$72h$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: proposal: lmap is missing the stride option
Date: Fri, 20 May 2022 12:13:12 +0200
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <t67pjp$72h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 May 2022 10:13:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="263f0c79ab1fce794f1d05b0c1891ff8";
logging-data="7249"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+T3Xm0Z7GzdWLHvTipt17uKsQZqquf87E="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:Bx19ObW2AiLE2tJXtaHKOgAEBs0=
Content-Language: en-US
 by: aotto1968 - Fri, 20 May 2022 10:13 UTC

hi,

"lmap" is a new command to tcl able to filter lists BUT missing the
feature to work an "stride" lists.

a stride list is a list with a pattern of multiple items.
example: The "array get…" produce a flat list of stride of "2"

code: lmap {k v} $packageDEF {list $k [lindex $v 1]}

packageDEF is a stride-2 list (k v) with "v" is a list
and I want to filter from "v" the index=1 argument

the code above create a list of lists:

> {k1 v11} {k2 v21} …

but I want to have

> k1 v11 k2 v22 …

The problem is the "list" command used to return TWO values from
filer-code. The NEW syntax would be:

code: lmap -stride 2 {k v} $packageDEF {list $k [lindex $v 1]}

> k1 v11 k2 v22 …

mfg AO

Re: proposal: lmap is missing the stride option

<t67po9$72h$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: proposal: lmap is missing the stride option
Date: Fri, 20 May 2022 12:15:37 +0200
Organization: A noiseless patient Spider
Lines: 4
Message-ID: <t67po9$72h$2@dont-email.me>
References: <t67pjp$72h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 May 2022 10:15:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="263f0c79ab1fce794f1d05b0c1891ff8";
logging-data="7249"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/v5wWak1wxsfx2YbCvnECyRsZUO/oAAIo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:uFXC1blK6UbA7ntc6UEvm1/r0ik=
In-Reply-To: <t67pjp$72h$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Fri, 20 May 2022 10:15 UTC

On 20.05.22 12:13, aotto1968 wrote:
> > k1 v11 k2 v22 …

correct: I want to have: > k1 v11 k2 v21!! …

Re: proposal: lmap is missing the stride option

<t68ghu$p1j$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: proposal: lmap is missing the stride option
Date: Fri, 20 May 2022 18:44:46 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <t68ghu$p1j$1@dont-email.me>
References: <t67pjp$72h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 May 2022 16:44:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="45776d52b7e3a4ca1cd012b0851cae64";
logging-data="25651"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hpruMSXweaSZ79flOfNy2Xdwre8gy+a4="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.9.0
Cancel-Lock: sha1:CtozXW84xAMecd7pyNZrfKwQeOQ=
In-Reply-To: <t67pjp$72h$1@dont-email.me>
 by: Christian Gollwitzer - Fri, 20 May 2022 16:44 UTC

Am 20.05.22 um 12:13 schrieb aotto1968:
> hi,
>
> "lmap" is a new command to tcl able to filter lists BUT missing the
> feature to work an "stride" lists.
>
> a stride list is a list with a pattern of multiple items.
> example: The "array get…" produce a flat list of stride of "2"
>
> code: lmap {k v} $packageDEF {list $k [lindex $v 1]}
>
> packageDEF is a stride-2 list (k v) with "v" is a list
> and I want to filter from "v" the index=1 argument
>
> the code above create a list of lists:
>
> > {k1 v11} {k2 v21} …
>
> but I want to have
>
> > k1 v11 k2 v22 …
>
> The problem is the "list" command used to return TWO values from
> filer-code. The NEW syntax would be:
>
> code: lmap -stride 2 {k v} $packageDEF {list $k [lindex $v 1]}
>
> > k1 v11 k2 v22 …

And what would be returned if someone does:

lmap -stride 3 {k v} $packageDEF {list $k [lindex $v 1]}

?

Or even with vayrying list lengths in the "lmap kernel"?
What you're after can be achieved at the moment using:

concat {*}[lmap .... ]

Instead of "-stride" which would be hard to interpret for the case of
building a list (as opposed to reading/traversing), I'd much rather see
a "-flatten" switch which does concat the lists instead of appending
into a new list.

Christian

Re: proposal: lmap is missing the stride option

<t68gnm$qf9$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: proposal: lmap is missing the stride option
Date: Fri, 20 May 2022 18:47:50 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <t68gnm$qf9$1@dont-email.me>
References: <t67pjp$72h$1@dont-email.me> <t68ghu$p1j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 20 May 2022 16:47:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="45776d52b7e3a4ca1cd012b0851cae64";
logging-data="27113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fvK2OTY/2qvQsGY0NalK7hST37qRVzgI="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.9.0
Cancel-Lock: sha1:xbC+z9lG3J0MFUhe7iWLYrAHLDk=
In-Reply-To: <t68ghu$p1j$1@dont-email.me>
 by: Christian Gollwitzer - Fri, 20 May 2022 16:47 UTC

Am 20.05.22 um 18:44 schrieb Christian Gollwitzer:
>> The problem is the "list" command used to return TWO values from
>> filer-code. The NEW syntax would be:
>>
>> code: lmap -stride 2 {k v} $packageDEF {list $k [lindex $v 1]}
>>
>>  > k1 v11 k2 v22an…
>

ah, and for the special case of transforming a key-value list where only
the value is changed, there is "dict map" which does that. Your example
would be:

dict map {k v} $packageDEF {lindex $v 1}

Christian

Re: proposal: lmap is missing the stride option

<t6aj2q$sge$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: proposal: lmap is missing the stride option
Date: Sat, 21 May 2022 13:40:10 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t6aj2q$sge$1@dont-email.me>
References: <t67pjp$72h$1@dont-email.me> <t68ghu$p1j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 21 May 2022 11:40:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3a58d54953af5d232e20c341ff0a3fc1";
logging-data="29198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ik91ah4TKvSH6GgfkkGbgMXnx7Wv+OIA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:qxL56l1FXAX4KK6FurL2TIoVtXg=
In-Reply-To: <t68ghu$p1j$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Sat, 21 May 2022 11:40 UTC

On 20.05.22 18:44, Christian Gollwitzer wrote:
~~
>
> And what would be returned if someone does:
>
>
> lmap -stride 3 {k v} $packageDEF {list $k [lindex $v 1]}
>
> ?
>
> Or even with vayrying list lengths in the "lmap kernel"?
> What you're after can be achieved at the moment using:
>
>     concat {*}[lmap .... ]
>
> Instead of "-stride" which would be hard to interpret for the case of
> building a list (as opposed to reading/traversing), I'd much rather see
> a "-flatten" switch which does concat the lists instead of appending
> into a new list.
>
>     Christian

I thing the -stride 3 is not a problem because returning a
list-of-length-3 from the filter is an easy condition to test. If this
condition is NOT ok than raise an error.

mfg.

Re: proposal: lmap is missing the stride option

<t6aj7s$sge$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Re: proposal: lmap is missing the stride option
Date: Sat, 21 May 2022 13:42:52 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <t6aj7s$sge$2@dont-email.me>
References: <t67pjp$72h$1@dont-email.me> <t68ghu$p1j$1@dont-email.me>
<t68gnm$qf9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 21 May 2022 11:42:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3a58d54953af5d232e20c341ff0a3fc1";
logging-data="29198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PXFim3xjkeB6EdMSjs08zLqC/NFgryxE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:G+HswFThKrr+BLxlL3FYss37irU=
In-Reply-To: <t68gnm$qf9$1@dont-email.me>
Content-Language: en-US
 by: aotto1968 - Sat, 21 May 2022 11:42 UTC

On 20.05.22 18:47, Christian Gollwitzer wrote:
> Am 20.05.22 um 18:44 schrieb Christian Gollwitzer:
>>> The problem is the "list" command used to return TWO values from
>>> filer-code. The NEW syntax would be:
>>>
>>> code: lmap -stride 2 {k v} $packageDEF {list $k [lindex $v 1]}
>>>
>>>  > k1 v11 k2 v22an…
>>
>
> ah, and for the special case of transforming a key-value list where only
> the value is changed, there is "dict map" which does that. Your example
> would be:
>
>     dict map {k v} $packageDEF {lindex $v 1}
>
> Christian

ok, for stride-2 this is a possible solution but how expensive it is to
build a dict?

performance | dict : list → dict → filter → dict → list
performance | -stride 2 : list → filter → list

mfg AO


devel / comp.lang.tcl / proposal: lmap is missing the stride option

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor