Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"The following is not for the weak of heart or Fundamentalists." -- Dave Barry


devel / comp.lang.tcl / Re: Distinguishing list elements: strings and sublists

SubjectAuthor
* Distinguishing list elements: strings and sublistsArjen Markus
+- Re: Distinguishing list elements: strings and sublistsSchelte
+* Re: Distinguishing list elements: strings and sublistsChristian Gollwitzer
|`- Re: Distinguishing list elements: strings and sublistsArjen Markus
+- Re: Distinguishing list elements: strings and sublistsHarald Oehlmann
`* Re: Distinguishing list elements: strings and sublistssaitology9
 `* Re: Distinguishing list elements: strings and sublistsArjen Markus
  +* Re: Distinguishing list elements: strings and sublistssaitology9
  |`* Re: Distinguishing list elements: strings and sublistsRich
  | `* Re: Distinguishing list elements: strings and sublistssaitology9
  |  `* Re: Distinguishing list elements: strings and sublistsRich
  |   `- Re: Distinguishing list elements: strings and sublistsArjen Markus
  `- Re: Distinguishing list elements: strings and sublistsAndreas Leitgeb

1
Re: Distinguishing list elements: strings and sublists

<nnd$7439896f$41d344d8@081e0daa5c667085>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Date: Mon, 17 Apr 2023 11:53:58 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.9.1
Subject: Re: Distinguishing list elements: strings and sublists
Newsgroups: comp.lang.tcl
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
Content-Language: nl-NL, en-US
From: nospam@wanadoo.nl (Schelte)
In-Reply-To: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$7439896f$41d344d8@081e0daa5c667085>
Organization: KPN B.V.
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!sewer!alphared!news.uzoreto.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 32
Injection-Date: Mon, 17 Apr 2023 11:53:58 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1927
 by: Schelte - Mon, 17 Apr 2023 09:53 UTC

Arjen,

I quite liked the way ticklecharts solved that problem: It provides
tcl::oo classes that can be used to create what amounts to typed
variables in Tcl. Then you make a list of objects. By checking the class
of the object, you can distinguish lists, dicts, and strings. I don't
know how much overhead this creates and if that is an objection for your
use case.

Schelte.

On 17/04/2023 11:00, Arjen Markus wrote:
> I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?
>
> Here is a small example:
>
> set a {"A B" C}
> lindex $a 0 ==> A B
> llength [lindex $a 0] ==> 2
>
> set b {{"A B"} C}
> lindex $b 0 ==> "A B"
> llength [lindex $b 0] ==> 1
>
> I can of course require labels of more than one word to be protected like in the second example. But is there a better solution?
>
> Regards,
>

Re: Distinguishing list elements: strings and sublists

<u1j92t$30pj4$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: auriocus@gmx.de (Christian Gollwitzer)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 13:03:55 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <u1j92t$30pj4$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 11:03:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9e26fc4393936146fbe045e2bdf1c137";
logging-data="3171940"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MFHKdHk32gwCfo7LGHA4rjcF7oYjTVEk="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.10.0
Cancel-Lock: sha1:Y+dGKHlkpWd7wWR8Hm1pJvVS/G0=
In-Reply-To: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
 by: Christian Gollwitzer - Mon, 17 Apr 2023 11:03 UTC

Am 17.04.23 um 11:00 schrieb Arjen Markus:
> I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?
>

This is a drawback of the EIAS model and can be inconvenient from time
to time. One standard solution is to prefix the data with a type
specifier, i.e. every entry is always a list with either

BRANCH $a $b
or
LEAF $a

Christian

Re: Distinguishing list elements: strings and sublists

<u1jdrc$310j5$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 14:25:15 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u1jdrc$310j5$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 12:25:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e9e490ac70eafbc05540d87c65db51b3";
logging-data="3179109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gWlgj9fXamsKimQDVKVUI"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:7ewDy0u+pMbQlHI/o14Y8nKElqY=
In-Reply-To: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
Content-Language: en-GB
 by: Harald Oehlmann - Mon, 17 Apr 2023 12:25 UTC

Am 17.04.2023 um 11:00 schrieb Arjen Markus:
> I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?
>
> Here is a small example:
>
> set a {"A B" C}
> lindex $a 0 ==> A B
> llength [lindex $a 0] ==> 2
>
> set b {{"A B"} C}
> lindex $b 0 ==> "A B"
> llength [lindex $b 0] ==> 1
>
> I can of course require labels of more than one word to be protected like in the second example. But is there a better solution?
>
> Regards,
>

It might be overkill, but tdom is a tool to handle tree data. You win
the easy import/export to XML/JSON. And performance for mass data is
great, I suppose.

Harald

Re: Distinguishing list elements: strings and sublists

<u1jkkv$32i0m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 10:21:19 -0400
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <u1jkkv$32i0m$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 14:21:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0aea1c2310db457efd2fde5e0c9f799";
logging-data="3229718"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Pm3XS51MLwMeKlYxNNLRO"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:LT0JpSstxB2eu8PHXuJgRMhjjVw=
In-Reply-To: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
Content-Language: en-US
 by: saitology9 - Mon, 17 Apr 2023 14:21 UTC

On 4/17/2023 5:00 AM, Arjen Markus wrote:
> I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?
>
> Here is a small example:
>
> set a {"A B" C}
....
> set b {{"A B"} C}

What does the full structure look like for a complete example?

Re: Distinguishing list elements: strings and sublists

<0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:ac8:5910:0:b0:3ef:31a5:134 with SMTP id 16-20020ac85910000000b003ef31a50134mr918083qty.2.1681755174688;
Mon, 17 Apr 2023 11:12:54 -0700 (PDT)
X-Received: by 2002:a05:6214:1924:b0:5e6:4193:996f with SMTP id
es4-20020a056214192400b005e64193996fmr1807515qvb.9.1681755174422; Mon, 17 Apr
2023 11:12:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.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: Mon, 17 Apr 2023 11:12:54 -0700 (PDT)
In-Reply-To: <u1jkkv$32i0m$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=62.194.189.128; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 62.194.189.128
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com> <u1jkkv$32i0m$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
Subject: Re: Distinguishing list elements: strings and sublists
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Mon, 17 Apr 2023 18:12:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2547
 by: Arjen Markus - Mon, 17 Apr 2023 18:12 UTC

On Monday, April 17, 2023 at 4:21:25 PM UTC+2, saitology9 wrote:
> On 4/17/2023 5:00 AM, Arjen Markus wrote:
> > I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?
> >
> > Here is a small example:
> >
> > set a {"A B" C}
> ...
> > set b {{"A B"} C}
> What does the full structure look like for a complete example?

My test cases so far are:

set data {
"Label1" "Label2" {"Level2a" "Level2b"} {{A B} Cxxxx}
} set data2 {
"Label1" "Label2" {"Level2a" "Level2b"}
} set data3 {
"Label1" "Label2" {{A B} Cxxxx}
} set data4 {
"Label1" "Label2" {{A B} {C D}}
} set data5 {
"Label1" "Label2" {{A B} {C {D E}}}
} set data6 {
"Label1" "Label2" {F {A B} {C {D E}}}
} set data7 {
{"Label1" "Label2"} {F {A B} {C {D E}}}
}

Nothing spectacular, but the sort of presentation I have in mind is often seen to represent the result of clustering. Something like https://en.wikipedia.org/wiki/Dendrogram#/media/File:Global-Diversity-of-Sponges-(Porifera)-pone.0035105.s008.tif

Regards,

Arjen

Re: Distinguishing list elements: strings and sublists

<u1k70d$35fuc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 15:34:37 -0400
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <u1k70d$35fuc$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
<u1jkkv$32i0m$1@dont-email.me>
<0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 19:34:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3951e2315cd9706845a7635ada686d09";
logging-data="3325900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J34EKmQ22OEkkImey1QyV"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:xCtHEtCMkqrMiW4Td7ppP/HqXaM=
Content-Language: en-US
In-Reply-To: <0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
 by: saitology9 - Mon, 17 Apr 2023 19:34 UTC

On 4/17/2023 2:12 PM, Arjen Markus wrote:
>
> Nothing spectacular, but the sort of presentation I have in mind is often seen to represent the result of clustering. Something like https://en.wikipedia.org/wiki/Dendrogram#/media/File:Global-Diversity-of-Sponges-(Porifera)-pone.0035105.s008.tif
>
>

Thanks for that, though I am still not clear :-) As already suggested,
you may need to tag your data. I would offer the following more generic
structure:

% set my_dglist [list "root-label" $item1 $item2 $item3 ...]

where an item is as one or the other of:

[list "leaf" "Label1" more-details...] ## fixed-length of details
[list "combo" $item4 $item5 $item6 ...] ## any number of items

In general, dendrograms are created at the end of some sort of frequency
analysis and branches aren't necessarily binary. It sounds like you are
after the visual end result of it. So if you are creating the data
programmatically, it should be easy :-) to come up with a few proc's to
combine elements one by one into groups, and to display it at the end
with canvas drawing commands.

Re: Distinguishing list elements: strings and sublists

<u1kaus$36486$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 20:42:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <u1kaus$36486$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com> <u1jkkv$32i0m$1@dont-email.me> <0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com> <u1k70d$35fuc$1@dont-email.me>
Injection-Date: Mon, 17 Apr 2023 20:42:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="2a5b9cda10e2572c74159546293998c0";
logging-data="3346694"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VK4pMazon3VmvHqmoGZqd"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:RQIbKaJ3gACsmkW3N9rI8wEGVRA=
 by: Rich - Mon, 17 Apr 2023 20:42 UTC

saitology9 <saitology9@gmail.com> wrote:
> On 4/17/2023 2:12 PM, Arjen Markus wrote:
>>
>> Nothing spectacular, but the sort of presentation I have in mind is
>> often seen to represent the result of clustering. Something like
>> https://en.wikipedia.org/wiki/Dendrogram#/media/File:Global-Diversity-of-Sponges-(Porifera)-pone.0035105.s008.tif
>>
>>
>
> Thanks for that, though I am still not clear :-) As already suggested,
> you may need to tag your data. I would offer the following more generic
> structure:
>
>
> % set my_dglist [list "root-label" $item1 $item2 $item3 ...]
>
> where an item is as one or the other of:
>
> [list "leaf" "Label1" more-details...] ## fixed-length of details
> [list "combo" $item4 $item5 $item6 ...] ## any number of items
>
>

You are slowly reinventing Tcllib's huddle:
https://wiki.tcl-lang.org/page/huddle

Re: Distinguishing list elements: strings and sublists

<u1kco8$36b45$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 17:12:40 -0400
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <u1kco8$36b45$1@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
<u1jkkv$32i0m$1@dont-email.me>
<0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
<u1k70d$35fuc$1@dont-email.me> <u1kaus$36486$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 17 Apr 2023 21:12:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3951e2315cd9706845a7635ada686d09";
logging-data="3353733"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Dy/R7gbrfqNbvNwbURVnZ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.0
Cancel-Lock: sha1:/iS9XUEyl/BVU8GfMstY0po5Iss=
Content-Language: en-US
In-Reply-To: <u1kaus$36486$1@dont-email.me>
 by: saitology9 - Mon, 17 Apr 2023 21:12 UTC

On 4/17/2023 4:42 PM, Rich wrote:
>
> You are slowly reinventing Tcllib's huddle:
> https://wiki.tcl-lang.org/page/huddle
>

It is funny you should say that :-) Just last week, I worked on parsing
some yaml files - and by extension, the huddle system. I didn't want to
distract from the original post's subject by mentioning it.

But you are right: the structure is quite common and is easy to use.
The node deciders could be generic like in my post or they could be data
types like in huddle.

Re: Distinguishing list elements: strings and sublists

<u1kgf1$36rv2$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Mon, 17 Apr 2023 22:16:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <u1kgf1$36rv2$2@dont-email.me>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com> <u1jkkv$32i0m$1@dont-email.me> <0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com> <u1k70d$35fuc$1@dont-email.me> <u1kaus$36486$1@dont-email.me> <u1kco8$36b45$1@dont-email.me>
Injection-Date: Mon, 17 Apr 2023 22:16:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="18ffeb6756a533ff160a470488856f5e";
logging-data="3370978"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rSkD6Z1CSYSjyOzT5r3gq"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.19 (x86_64))
Cancel-Lock: sha1:cjArYxq0FPVPzypVSSfceI9myNc=
 by: Rich - Mon, 17 Apr 2023 22:16 UTC

saitology9 <saitology9@gmail.com> wrote:
> On 4/17/2023 4:42 PM, Rich wrote:
>>
>> You are slowly reinventing Tcllib's huddle:
>> https://wiki.tcl-lang.org/page/huddle
>>
>
> It is funny you should say that :-) Just last week, I worked on parsing
> some yaml files - and by extension, the huddle system. I didn't want to
> distract from the original post's subject by mentioning it.
>
> But you are right: the structure is quite common and is easy to use.
> The node deciders could be generic like in my post or they could be data
> types like in huddle.

Yes, and for generic strings is is not possible to tell, from the
characters themselves, whether the string represents a string, a list,
or a dict. Extra "out of band" data has to exist somewhere (in code or
in the data) to indicate whether:

the quick brown fox jumped over

Is a simple string, a list of six elements, or a dict with three keys.

Re: Distinguishing list elements: strings and sublists

<855a8a18-f91d-43db-a9ee-05a418060773n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:b33:b0:5ef:63e8:e64e with SMTP id w19-20020a0562140b3300b005ef63e8e64emr1542410qvj.7.1681799168965;
Mon, 17 Apr 2023 23:26:08 -0700 (PDT)
X-Received: by 2002:ac8:4e8f:0:b0:3ea:ce1c:a2b6 with SMTP id
15-20020ac84e8f000000b003eace1ca2b6mr4701496qtp.11.1681799168680; Mon, 17 Apr
2023 23:26:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.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: Mon, 17 Apr 2023 23:26:08 -0700 (PDT)
In-Reply-To: <u1kgf1$36rv2$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.184.73; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.184.73
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
<u1jkkv$32i0m$1@dont-email.me> <0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
<u1k70d$35fuc$1@dont-email.me> <u1kaus$36486$1@dont-email.me>
<u1kco8$36b45$1@dont-email.me> <u1kgf1$36rv2$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <855a8a18-f91d-43db-a9ee-05a418060773n@googlegroups.com>
Subject: Re: Distinguishing list elements: strings and sublists
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Tue, 18 Apr 2023 06:26:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2550
 by: Arjen Markus - Tue, 18 Apr 2023 06:26 UTC

On Tuesday, April 18, 2023 at 12:16:05 AM UTC+2, Rich wrote:
> saitology9 wrote:
> > On 4/17/2023 4:42 PM, Rich wrote:
> >>
> >> You are slowly reinventing Tcllib's huddle:
> >> https://wiki.tcl-lang.org/page/huddle
> >>
> >
> > It is funny you should say that :-) Just last week, I worked on parsing
> > some yaml files - and by extension, the huddle system. I didn't want to
> > distract from the original post's subject by mentioning it.
> >
> > But you are right: the structure is quite common and is easy to use.
> > The node deciders could be generic like in my post or they could be data
> > types like in huddle.
> Yes, and for generic strings is is not possible to tell, from the
> characters themselves, whether the string represents a string, a list,
> or a dict. Extra "out of band" data has to exist somewhere (in code or
> in the data) to indicate whether:
>
> the quick brown fox jumped over
>
> Is a simple string, a list of six elements, or a dict with three keys.

It could also be interpreted as an incomplete sentence ;).

Regards,

Arjen

Re: Distinguishing list elements: strings and sublists

<c45901f4-41b1-4e11-91ce-c4079c8a4ae9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:8e:b0:3ee:be98:9fce with SMTP id o14-20020a05622a008e00b003eebe989fcemr1594104qtw.1.1681733071448;
Mon, 17 Apr 2023 05:04:31 -0700 (PDT)
X-Received: by 2002:a05:620a:15ab:b0:74a:c537:1bcb with SMTP id
f11-20020a05620a15ab00b0074ac5371bcbmr1594093qkk.0.1681733071226; Mon, 17 Apr
2023 05:04:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Mon, 17 Apr 2023 05:04:31 -0700 (PDT)
In-Reply-To: <u1j92t$30pj4$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.184.73; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.184.73
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com> <u1j92t$30pj4$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c45901f4-41b1-4e11-91ce-c4079c8a4ae9n@googlegroups.com>
Subject: Re: Distinguishing list elements: strings and sublists
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Mon, 17 Apr 2023 12:04:31 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Arjen Markus - Mon, 17 Apr 2023 12:04 UTC

Thanks Christian, Schelte,

either idea could prove useful. For the moment I can simply ignore the problem, as I have to put it all into a more general form than I have now, but this was a problem that I anticipated.

Regards,

Arjen

Distinguishing list elements: strings and sublists

<8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:1643:b0:5e6:75b9:4889 with SMTP id f3-20020a056214164300b005e675b94889mr1957187qvw.0.1681722038187;
Mon, 17 Apr 2023 02:00:38 -0700 (PDT)
X-Received: by 2002:ac8:5910:0:b0:3ef:3126:7dca with SMTP id
16-20020ac85910000000b003ef31267dcamr525615qty.2.1681722037883; Mon, 17 Apr
2023 02:00:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer02.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: Mon, 17 Apr 2023 02:00:37 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=136.231.213.2; posting-account=A91wAAoAAADgBUxBX6QqsrSD26GLhVp8
NNTP-Posting-Host: 136.231.213.2
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
Subject: Distinguishing list elements: strings and sublists
From: arjen.markus895@gmail.com (Arjen Markus)
Injection-Date: Mon, 17 Apr 2023 09:00:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1791
 by: Arjen Markus - Mon, 17 Apr 2023 09:00 UTC

I have worked on an algorithm to plot a dendrogram where the data are stored as a nested list. The final elements are strings (labels, if you want). But I encounter the problem that a string with two or more words cannot be distinguished from a list with several elements. Is there a way to achieve this?

Here is a small example:

set a {"A B" C}
lindex $a 0 ==> A B
llength [lindex $a 0] ==> 2

set b {{"A B"} C}
lindex $b 0 ==> "A B"
llength [lindex $b 0] ==> 1

I can of course require labels of more than one word to be protected like in the second example. But is there a better solution?

Regards,

Re: Distinguishing list elements: strings and sublists

<slrnu5ka17.1v30n.avl@logic.at>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: avl@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: Distinguishing list elements: strings and sublists
Date: Tue, 9 May 2023 11:01:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <slrnu5ka17.1v30n.avl@logic.at>
References: <8e9d6a75-fda0-4f40-a052-ea6b8a3ecc49n@googlegroups.com>
<u1jkkv$32i0m$1@dont-email.me>
<0a216ad4-37ff-4fe6-93cd-16748dbec5a7n@googlegroups.com>
Reply-To: avl@logic.at
Injection-Date: Tue, 9 May 2023 11:01:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="307995da9ea68b406d6a3ec0f2390018";
logging-data="258913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tXscrHBTMUNCJhsS+VMps"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:OXcs6Vo5QRRkKPI1xnFpwTlnYdE=
 by: Andreas Leitgeb - Tue, 9 May 2023 11:01 UTC

Arjen Markus <arjen.markus895@gmail.com> wrote:
> My test cases so far are:
> set data {
> "Label1" "Label2" {"Level2a" "Level2b"} {{A B} Cxxxx}
> }
> set data2 {
> "Label1" "Label2" {"Level2a" "Level2b"}
> }
....

Another "poor man's huddle" could be to just mark all strings with a
"{}*" (left brace, right brace, any non-whitespace)
prefix, so these wouldn't be valid as lists...

If you could be sure that no label starts with whitespace, then just
a pair of braces would do, as well.

Any code displaying the structure would of course then need to strip the
prefix before displaying a label to users ;-)


devel / comp.lang.tcl / Re: Distinguishing list elements: strings and sublists

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor