Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Computer programmers never die, they just get lost in the processing.


programming / comp.lang.tcl / Command instead of dict for

SubjectAuthor
* Command instead of dict forCecil Westerhof
`- Re: Command instead of dict forheinrichmartin

1
Subject: Command instead of dict for
From: Cecil Westerhof
Newsgroups: comp.lang.tcl
Organization: Decebal Computing
Date: Sat, 7 May 2022 04:39 UTC
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Command instead of dict for
Date: Sat, 07 May 2022 06:39:23 +0200
Organization: Decebal Computing
Lines: 14
Message-ID: <8735hmhs78.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="0bb501fec4c7843ba82d15083014ff3d";
logging-data="13262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19O6wdq022nVZfc0RVNNBBRDlHy8hClx7k="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:PzwmcFMkCSOYHmvCet+LdphK6Rw=
sha1:f+be49neOZEnOrlSKbiU/TW9pRI=
View all headers
To transform a dict to a list of list I use:
    set swapList {}
    dict for {name swap} ${swapDict} {
        lappend swapList [list $name $swap]
    }

But I seem to remember that there is a command that does this, but I
do not remember the command.
Am I mistaken? If not: what is the command?

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


Subject: Re: Command instead of dict for
From: heinrichmartin
Newsgroups: comp.lang.tcl
Date: Sat, 7 May 2022 21:19 UTC
References: 1
X-Received: by 2002:a05:620a:28c7:b0:6a0:5de3:e6 with SMTP id l7-20020a05620a28c700b006a05de300e6mr2475330qkp.464.1651958383858;
Sat, 07 May 2022 14:19:43 -0700 (PDT)
X-Received: by 2002:a05:6808:ed0:b0:2f9:c6f8:8b38 with SMTP id
q16-20020a0568080ed000b002f9c6f88b38mr4433405oiv.215.1651958383676; Sat, 07
May 2022 14:19:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 7 May 2022 14:19:43 -0700 (PDT)
In-Reply-To: <8735hmhs78.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=213.225.34.69; posting-account=Od2xOAoAAACEyRX3Iu5rYt4oevuoeYUG
NNTP-Posting-Host: 213.225.34.69
References: <8735hmhs78.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e6f0d1b5-3cf3-4fd0-89f7-a65c3d752c67n@googlegroups.com>
Subject: Re: Command instead of dict for
From: martin.h...@frequentis.com (heinrichmartin)
Injection-Date: Sat, 07 May 2022 21:19:43 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2163
View all headers
On Saturday, May 7, 2022 at 6:44:06 AM UTC+2, Cecil Westerhof wrote:
To transform a dict to a list of list I use:
set swapList {}
dict for {name swap} ${swapDict} {
lappend swapList [list $name $swap]
}

But I seem to remember that there is a command that does this, but I
do not remember the command.
Am I mistaken? If not: what is the command?

Are you looking for [lmap {k v} {a b c d e f} {list $k $v}]? Note that this shimmers from dict to list:

expect:~$ set d [dict create a b c d e f]
a b c d e f
expect:~$ ::tcl::unsupported::representation $d
value is a dict with a refcount of 4, object pointer at 0xcaf7d0, internal representation 0xcf4570:(nil), string representation "a b c d e f"
expect:~$ lmap {k v} $d {list $k $v}
{a b} {c d} {e f}
expect:~$ ::tcl::unsupported::representation $d
value is a list with a refcount of 4, object pointer at 0xcaf7d0, internal representation 0xd343d0:(nil), string representation "a b c d e f"


1
rocksolid light 0.7.2
clearneti2ptor