<?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/16666" />

	<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-03-03T06:20:06-04:00</updated>

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

		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2009-03-03T06:20:06-04:00</updated>

		<published>2009-03-03T06:20:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87676#p87676</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87676#p87676"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87676#p87676"><![CDATA[
You could perhaps use the command lsearch in some way to maintain a list of unique names by only adding them if they don't already exist.<br><br>I haven't studied your code so I don't know exactly how to resolve your specific problem but below is an example of using a proc to parse a line (in this case a space delimited string of names). A global variable is maintained and consists of a list of unique names. The command lsearch is used to determine if a name within the line (after splitting into a list) already exists. If it already exists within the global variable then ignore it, if it doesn't exist then lappend to the global variable.<br><br>For each instance of a line simply call the proc pParseNames with the line as a single argument. Ultimately the global variable vNamesList will be an unsorted list of unique names taken from within all the lines.<br><div class="codebox"><p>Code: </p><pre><code>proc pParseNames {line} {    global vNamesList    set linelist [split $line]    if {[info exists vNamesList]} {        foreach name $linelist {            if {[lsearch -exact $vNamesList $name] == -1} {                lappend vNamesList $name            }        }    } else {set vNamesList $linelist}}</code></pre></div>Untested but it looks OK. In any case I'm sure you understand my reasoning.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Tue Mar 03, 2009 6:20 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pranjal_ccna961]]></name></author>
		<updated>2009-03-02T04:19:52-04:00</updated>

		<published>2009-03-02T04:19:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87655#p87655</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87655#p87655"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87655#p87655"><![CDATA[
[lsort -unique] is working to sort out duplicate names in the one line. But, if the loops encounter the same name in different line, its getting in the list. so the list still contains the duplicate names.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10504">pranjal_ccna961</a> — Mon Mar 02, 2009 4:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2009-03-02T03:12:31-04:00</updated>

		<published>2009-03-02T03:12:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87653#p87653</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87653#p87653"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87653#p87653"><![CDATA[
What's wrong with [lsort -unique]?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Mon Mar 02, 2009 3:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pranjal_ccna961]]></name></author>
		<updated>2009-03-02T00:27:08-04:00</updated>

		<published>2009-03-02T00:27:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87651#p87651</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87651#p87651"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87651#p87651"><![CDATA[
puts -nonewline "Choose Input File Name: "<br>flush stdout <br>set myString [gets stdin]<br><br><br>set fp [open $myString r]<br>set data [read $fp]<br>close $fp<br><br><br>puts -nonewline "Choose Cell: "<br>flush stdout <br>set cell [gets stdin]<br><br><br>puts -nonewline "Output File: "<br>flush stdout<br>set output [gets stdin]<br><br><br>puts "Extracting nets for $cell .............."<br>after 1000<br><br>#split the file into lines<br>set data [split $data "\n"]<br><br>#total no of lines in the file<br>set datalength [llength $data]<br>###puts $datalength<br><br>#get the initial index for the cell line<br>set count -1 <br>foreach line $data {<br>incr count<br>if {[regexp ".SUBCKT $cell" $line] == 1} {<br>set init $count<br>}<br>}<br>###puts $init<br><br>#sort the file from the cell line till end<br>set sortlist [lrange $data $init $datalength]<br><br>#get the final index for the cell line<br>set linecount -1<br>foreach newline $sortlist {<br>incr linecount<br>if {[regexp ".ENDS" $newline] == 1} {<br>set final $linecount<br>break<br>}<br>}<br>###puts $final<br><br><br>#adjust indexes<br>set firstindex [expr $init+1]<br>set endindex [expr $init+$final-1]<br><br>set cellsort [lrange $data $firstindex $endindex]<br>set uniquesort [lsort -unique $cellsort]<br>#puts $uniquesort<br><br><br>##sort out the nets for the cell<br>##this logic is to be improved yet to sort nets across lines<br>##in its current form sorts the nets just in every netlines<br><br>foreach netline $uniquesort {<br>if {[regexp {[A-Z][0-9]} $netline] == 1} {  <br>set new [list $netline]<br>foreach nets $new {<br>set newnets [lrange $nets 1 3]<br>}<br>#puts $newnets<br>set out [open $output a+]<br>puts $out $newnets<br>close $out<br>}<br>}<br>puts "Extracted nets are in $output .............."<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10504">pranjal_ccna961</a> — Mon Mar 02, 2009 12:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Sir_Fz]]></name></author>
		<updated>2009-03-01T15:54:41-04:00</updated>

		<published>2009-03-01T15:54:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87648#p87648</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87648#p87648"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87648#p87648"><![CDATA[
What do you mean by "receiving the input through a resultant loop?" a code example would make things a lot clearer.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3085">Sir_Fz</a> — Sun Mar 01, 2009 3:54 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[pranjal_ccna961]]></name></author>
		<updated>2009-03-01T09:10:49-04:00</updated>

		<published>2009-03-01T09:10:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87642#p87642</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87642#p87642"/>
		<title type="html"><![CDATA[how to remove duplicate items from a list]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87642#p87642"><![CDATA[
how to remove duplicate items from a list ? The list is receiving the input through a resultant loop. <br><br>If i use "lsort -unique", it gives me for that particlur loop run. If the same item is repeated next time in the loop, its not taking. Can anyone suggest me something. I figured out " lrmdups " solves this problem, but it is not working for the tcl version that i am using.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10504">pranjal_ccna961</a> — Sun Mar 01, 2009 9:10 am</p><hr />
]]></content>
	</entry>
	</feed>
