Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search and destroy.....

Status
Not open for further replies.

sl1200mk2

Technical User
Jun 7, 2005
39
FR
hi
i'm looking for a way to do this job:
i've got +1 +2 +3 +4 +5 +6 -2 -4
i want 1 3 5 6

or +1 +4 +6 +3 +5 +2 -1 -3
want 4 6 5 2

any ideas are welcome

thanks
nicolas
 
Maybe I'm missing something here. What is the criterion for picking the numbers you want?

_________________
Bob Rashkin
rrashkin@csc.com
 
hi bong
the filter is done with - sign

in words :
1)look for number with - sign
2)remove all number equal to those with the - sign
3) remove number with - sign

if i have
+1 +2 +6 +200 +4 +9 +73 -6 -73
the result should be
1 2 200 4 9

someone helped me for this job
one result is

% proc filter data {
foreach item $data {
set uns [expr {abs($item)}]
if {$item > 0} {
set res($uns) {}
} else {
unset -nocomplain res($uns)
}
}
array names res

}

% set d {+1 +4 +6 +3 +5 +2 -1 -3}
+1 +4 +6 +3 +5 +2 -1 -3
% filter $d
4 5 2 6

some are really good TCLers.........
thanks for your post

best regards
nico
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top