Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Radioactive cats have 18 half-lives.


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

SubjectAuthor
o proposal: lmap is missing the stride optionclt.to.davebr

1
proposal: lmap is missing the stride option

<9571653057319@dlp>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: clt.to.davebr@dfgh.net
Newsgroups: comp.lang.tcl
Subject: proposal: lmap is missing the stride option
Date: Fri, 20 May 22 14:35:19 GMT
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <9571653057319@dlp>
Injection-Info: reader02.eternal-september.org; posting-host="d11c965d647e69b91e71fd887dc5cba3";
logging-data="28309"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DpyTKQesC5WXIKCpxlYLN"
Cancel-Lock: sha1:Io1OGPMh25EhHPubgSmH7qeKURo=
 by: clt.to.davebr@dfgh.net - Fri, 20 May 2022 14:35 UTC

>From: aotto1968 <aotto1968@t-online.de>
>Date: Fri May 20 10:13:12 GMT 2022
>Subject: proposal: lmap is missing the stride option

>
>"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]}

>the code above create a list of lists:
>
> > {k1 v11} {k2 v21} …
>
>but I want to have
>
> > k1 v11 k2 v22 …

[concat {*}[lmap {k v} $packageDEF {list $k [lindex $v 1]}]

will get the result you want.

I end up using this a lot, and would like a cleaner way to have the script argument to lmap generate multiple items in the lmap result.

However I do not think -stride is the proper name for this option, and do not see why a number of items is necessary or even useful. Why not just append as many items as appear in the script result treated as a list?

Perhaps adding a option (-concat ?) to lmap which concatenates the result of the script to the [lmap] result. Something like:

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

Dave B


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

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor