Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Truth has always been found to promote the best interests of mankind... -- Percy Bysshe Shelley


devel / comp.lang.tcl / Syncronize list with same length beetween 2 Sync objects

SubjectAuthor
* Syncronize list with same length beetween 2 Sync objectseddy
`- Re: Syncronize list with same length beetween 2 Sync objectsSchelte

1
Syncronize list with same length beetween 2 Sync objects

<4f2cc5f8-80f3-4dee-878a-d2ef16d814aen@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:6214:5602:b0:650:304:5137 with SMTP id mg2-20020a056214560200b0065003045137mr305345qvb.12.1693317972598;
Tue, 29 Aug 2023 07:06:12 -0700 (PDT)
X-Received: by 2002:ac8:7f07:0:b0:40e:b4f2:b382 with SMTP id
f7-20020ac87f07000000b0040eb4f2b382mr873112qtk.11.1693317972244; Tue, 29 Aug
2023 07:06:12 -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: Tue, 29 Aug 2023 07:06:11 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=95.208.212.132; posting-account=jSBTQwoAAABx3aLZbpk3pmdTTutLeO7v
NNTP-Posting-Host: 95.208.212.132
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4f2cc5f8-80f3-4dee-878a-d2ef16d814aen@googlegroups.com>
Subject: Syncronize list with same length beetween 2 Sync objects
From: eddy2943@googlemail.com (eddy)
Injection-Date: Tue, 29 Aug 2023 14:06:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1610
 by: eddy - Tue, 29 Aug 2023 14:06 UTC

Hello,

i get from my System following String back
set info1 {SYNC 1;OP1 4;OP2 4;SYNC 2;OP3 3;SYNC 3;SYNC 4}
set info2 {SYNC 1;SYNC 2;SYNC 3;OP1 4;OP2 4;SYNC 4}

The result should be that beetween SYNC 1 and SYNC2 should be the same counter of elements. Placeholder is named e.g NOOP and when OP 1 have a 4 then NOOP should have a 3

And at the end both lists should have the same length.

set result1 {SYNC 1;OP1 4;OP2 4;SYNC 2;OP3 3;SYNC 3;NOOP 4;NOOP 4;SYNC 4}
set result2 {SYNC 1;NOOP 3;NOOP 3;SYNC 2;NOOP 4;SYNC 3;OP1 3;OP2 3;SYNC 4}

Hope that clear what i mean.

Can someone help me.

Re: Syncronize list with same length beetween 2 Sync objects

<nnd$26822406$0ef0e292@4b94a8d73f0aa569>

  copy mid

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

  copy link   Newsgroups: comp.lang.tcl
Date: Tue, 29 Aug 2023 23:15:41 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Syncronize list with same length beetween 2 Sync objects
Content-Language: en-US
Newsgroups: comp.lang.tcl
References: <4f2cc5f8-80f3-4dee-878a-d2ef16d814aen@googlegroups.com>
From: nospam@wanadoo.nl (Schelte)
In-Reply-To: <4f2cc5f8-80f3-4dee-878a-d2ef16d814aen@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <nnd$26822406$0ef0e292@4b94a8d73f0aa569>
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!tr2.iad1.usenetexpress.com!feeder.usenetexpress.com!tr2.eu1.usenetexpress.com!94.232.112.244.MISMATCH!feed.abavia.com!abe004.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 77
Injection-Date: Tue, 29 Aug 2023 23:15:41 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Schelte - Tue, 29 Aug 2023 21:15 UTC

On 29/08/2023 16:06, eddy wrote:
> Hello,
>
> i get from my System following String back
> set info1 {SYNC 1;OP1 4;OP2 4;SYNC 2;OP3 3;SYNC 3;SYNC 4}
> set info2 {SYNC 1;SYNC 2;SYNC 3;OP1 4;OP2 4;SYNC 4}
>
> The result should be that beetween SYNC 1 and SYNC2 should be the same counter of elements. Placeholder is named e.g NOOP and when OP 1 have a 4 then NOOP should have a 3
>
> And at the end both lists should have the same length.
>
> set result1 {SYNC 1;OP1 4;OP2 4;SYNC 2;OP3 3;SYNC 3;NOOP 4;NOOP 4;SYNC 4}
> set result2 {SYNC 1;NOOP 3;NOOP 3;SYNC 2;NOOP 4;SYNC 3;OP1 3;OP2 3;SYNC 4}
>
> Hope that clear what i mean.
>
It isn't clear to me why the "OP1 4" and "OP2 4" from info2 change to
"OP1 3" and "OP2 3" in result2.

So I ignored that in my solution below. It may not be the simplest, but
it was fun to play with coroutines as generators:

set info1 {SYNC 1;OP1 4;OP2 4;SYNC 2;OP3 3;SYNC 3;SYNC 4}
set info2 {SYNC 1;SYNC 2;SYNC 3;OP2 4;OP3 4;SYNC 4}

proc generator {info} {
foreach n [split $info {;}] {yield $n}
return
}

set result1 {}
set result2 {}

# Start a generator with each of the input strings
set str1 [coroutine gen1 generator $info1]
set str2 [coroutine gen2 generator $info2]

# An empty string indicates the generator is finished
while {$str1 ne "" || $str2 ne ""} {
# Check which input is at a SYNC item, if any
set sync1 [expr {$str1 eq "" || [string match {SYNC *} $str1]}]
set sync2 [expr {$str2 eq "" || [string match {SYNC *} $str2]}]
# Initialize the output variables
set val1 $str1
set val2 $str2
# Boolean XOR
if {$sync1 != $sync2} {
# Exactly one of the inputs is at a SYNC item
if {$sync1} {
# Determine an alternative value to use for output variable 1
scan $str2 {%*s %d} num
set val1 "NOOP [expr {7 - $num}]"
} else {
# Determine an alternative value to use for output variable 2
scan $str1 {%*s %d} num
set val2 "NOOP [expr {7 - $num}]"
}
}
# Add the output variables to their respective lists
lappend result1 $val1
lappend result2 $val2
# Take the next value from the input that is not at a SYNC item.
# If they are both at a SYNC item, take the next value from both
inputs.
if {!$sync1 || $sync2} {set str1 [gen1]}
if {!$sync2 || $sync1} {set str2 [gen2]}
}

# Present the result:
puts "result1: [join $result1 {;}]"
puts "result2: [join $result2 {;}]"

Schelte


devel / comp.lang.tcl / Syncronize list with same length beetween 2 Sync objects

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor