<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/17269" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2009-10-25T07:23:54-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/17269</id>

		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-25T07:23:54-04:00</updated>

		<published>2009-10-25T07:23:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90630#p90630</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90630#p90630"/>
		<title type="html"><![CDATA[array comparing, same results in new array]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90630#p90630"><![CDATA[
Yes I agree, it will probably fail.<br><br>Unless you are able to better compose a question in terms of script logic, I very much doubt if you will be getting a competent specific answer.<br><br>The only items you put in quotes seemed to be the array element values "bla" and "blub" and not the array element names, not that they need to be in quotes as things stand.<br><br>Variable values are often dynamic (change), that would be one good reason to call them variables. This includes array variables. An array element name does not change, it simply exist or not. I think what you mean is the array sizes are dynamic. This does not really have the same significance in Tcl that it has elsewhere.<br><br>Let me give you one example of the confusion that you communicate :-<br><br>newarray(value,posarray1,posarray2,posarray3)<br><br>The name of the array is newarray, the name of the array element is some sort of string concatenation of the value in the other arrays plus the element names in the said other arrays (positions as you call it). However, what is the value of this element of newarray?<br><div class="codebox"><p>Code: </p><pre><code>set newarray(value,posarray1,posarray2,posarray3) ???</code></pre></div>This would be my suggestion :-<br><br>The newarray element name is the value from the other arrays and the newarray element value is a list of the element names where it occurs in the other arrays<br><br>value    array1    array2    array3<br>bla       1,3          2,8        1,9<br>blub     0,2          *           0,6 <br><br>So, for example, the value blub occurs in array1(0,2) and array3(0,6) but does not occur at all in array2<br><br>With the correct code, this could yield<br><br>newarray(bla) {1,3 2,8 1,9}<br>newarray(blub) {0,2 "" 0,6}<br><br>Even this assumes certain things :-<br><br>1. The value blub is not duplicated in the original arrays (occurs in more than one element of any one of the arrays)<br><br>2. The values in the original arrays do not contain spaces (this is possible to deal with, but potentially more difficult)<br><br>I'm sorry to be negative about your question but it does indicate a lack of understanding of Tcl arrays. Probably you are coming to Tcl from an alternative language where arrays are what might be called more 'normal' in structure/behaviour. Hopefully the Tcl experts won't shoot me for saying that.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Oct 25, 2009 7:23 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-24T16:21:15-04:00</updated>

		<published>2009-10-24T16:21:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90624#p90624</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90624#p90624"/>
		<title type="html"><![CDATA[array comparing, same results in new array]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90624#p90624"><![CDATA[
i know thats its not a real 2 dim array thats why i put it in "".<br><br>the problem is that the values in the arrays are dynamic.<br><br>ill try your suggestion and report success or more likely my failing.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Sat Oct 24, 2009 4:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-24T15:51:33-04:00</updated>

		<published>2009-10-24T15:51:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90623#p90623</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90623#p90623"/>
		<title type="html"><![CDATA[array comparing, same results in new array]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90623#p90623"><![CDATA[
I would like to add a further comment. There is no such thing as a two dimensional array in Tcl (not yet anyway).<br><br>Your code is an emulation of a two dimensional array which relies on the fact that Tcl arrays are associative. That is to say that the array element name can be any string and "1,8" for example is a string. It looks like a two dimensional array but it isn't, it only has one index/key (element name).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sat Oct 24, 2009 3:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-10-24T15:35:11-04:00</updated>

		<published>2009-10-24T15:35:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90622#p90622</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90622#p90622"/>
		<title type="html"><![CDATA[array comparing, same results in new array]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90622#p90622"><![CDATA[
The following code will create an array called newarray which is an exact duplicate of an existing array called oldarray<br><div class="codebox"><p>Code: </p><pre><code>foreach {name value} [array get oldarray] {  set newarray($name) $value}</code></pre></div>You could add additional logic within the foreach loop which would only duplicate the name/value pair in the newarray based on some aspect of $value (or even $name or both). For example :-<br><div class="codebox"><p>Code: </p><pre><code>foreach {name value} [array get oldarray] {  if {[string equal -nocase bla $value]} {    set newarray($name) $value  }}</code></pre></div>I don't know if there is a simpler and/or faster method<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sat Oct 24, 2009 3:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ChooChoo]]></name></author>
		<updated>2009-10-24T13:35:58-04:00</updated>

		<published>2009-10-24T13:35:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=90620#p90620</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=90620#p90620"/>
		<title type="html"><![CDATA[array comparing, same results in new array]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=90620#p90620"><![CDATA[
hi<br><br>i have 3 "2-dimensional" arrays.<br><br>array1(0,0-X) -        0-X max value is in var $limit1<br>array2(1,0-X) -       0-X max value is in var $limit2<br>array3(2,0-X) -       0-X max value is in var $limit3<br><br>i want same entries to be put in a new array, with the positions where it is in the original arrays <br><br>newarray(value,posarray1,posarray2,posaray3)<br><br>so entrys would be<br><div class="codebox"><p>Code: </p><pre><code>index   value pos1 pos2 pos30       blub  2    *   61       bla   3    8   9....</code></pre></div><br>if a value is not in all 3 arrays the value marked with * should be "25000" <br>if a value is only in 1 array it should not be in the new array.<br><br>so the string "blub" is in array1(0,2) and in array3(2,6)<br>string "bla" is in array1(0,3) and array2(1,8) and in array3(2,9)<br><br>is there any way to do this (as fast as possible)?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10921">ChooChoo</a> — Sat Oct 24, 2009 1:35 pm</p><hr />
]]></content>
	</entry>
	</feed>
