12-07-2012
Wel, in some languages you can have lists of lists, so you can say:
for every list of list1 of lists
get every item of the list and for it
get every list of list2 of lists
get every item of that list
compare item of list of list1 with item of list of list2
but you are decomposing the lists over and over, so for efficiency, you can decompose both once, sort them and do the sort-optimized cartesian join in 'join' or you can put one decomposed list of lists into one associative array and look up every line of the other list of lists.
It is important to see the disorder of having peer data elements in two dimensions, across and down the page. Disorder generates more code and less speed.
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories.
The following command also shows the files but I only want to see the directories.
ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
2. Solaris
i've installed solaris 10 on E 3500 server ..
1. i cant install patch cluster on it , cause when i extract the file , i gives me an OUT file .. i dont know what to do with it .
2. i want to know which files to edit so i can use Exceed Client Software for X Terminal .. its working fine with... (9 Replies)
Discussion started by: mduweik
9 Replies
3. UNIX for Advanced & Expert Users
in my organisation the unix server is migrated.the ip of the server changed and the hardware.i need to test that i am aving the same file structure and data which is created under my user id.and the utilities like sqlplus,ftp are working or not.i am talking abt the general user perspective who... (0 Replies)
Discussion started by: dr46014
0 Replies
4. UNIX for Dummies Questions & Answers
Hi Guys,
I am using the following command in a script.
cat $sql_file_path"/"${sql_file_list} | grep "ABCDE"
but it returns only exactly matching lines (ABCDE)
how can i modify this single line so it will return if it finds a matching string with any case.
eg: Abcde, abCDe, abcdeE,... (4 Replies)
Discussion started by: mwrg
4 Replies
5. Shell Programming and Scripting
File_A contains Strings:
a
b
c
d
File_B contains Strings:
a
c
z
Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below.
Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies
6. Shell Programming and Scripting
Hi,
I am new to tcl programming, i want to know how to write a procedure for list operations taking the user input from command line and outputs the the index of each element in the list.
Eg:
input list is : { 1 2 {ab cde} {acf t12 l34} 3 5{43 {try 5 }} } something like this.
output should... (6 Replies)
Discussion started by: mail2leo
6 Replies
7. Shell Programming and Scripting
hi guys
i have a file like this which is contain more than 3000 records
i want to extract emails have Creation Date: : Wed, 14 Aug 2009 and their POP3 Last Login Date and WebMail Last Login Date is Thu, 01 Jan 1970
how can i could do that
for example in this sample i need... (13 Replies)
Discussion started by: mhs
13 Replies
8. UNIX for Dummies Questions & Answers
Hi All,
Could you please help to resolve my following issues:
Problem Description:
Suppose my user name is "MI90".
i.e. $USER = MI90
when i run below command, i get all the processes running on the system containing name MQ.
ps -ef | grep MQ
But sometimes it lists... (8 Replies)
Discussion started by: KDMishra
8 Replies
9. Shell Programming and Scripting
Hi All,
Good morning
I have a below code which is working & getting expected output. the problem in this code is it is executing 3 if conditions, my requirement is
suppose if first condition is success then it should print echo statement & exit from if condition
else if the 1st if condition... (4 Replies)
Discussion started by: sam@sam
4 Replies
LEARN ABOUT REDHAT
foreach
foreach(n) Tcl Built-In Commands foreach(n)
__________________________________________________________________________________________________________________________________________________
NAME
foreach - Iterate over all elements in one or more lists
SYNOPSIS
foreach varname list body
foreach varlist1 list1 ?varlist2 list2 ...? body
_________________________________________________________________
DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one
loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each
element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been
used to extract the element, then calls the Tcl interpreter to execute body.
In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of
loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive
values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The
total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough
elements for each of its loop variables in each iteration, empty values are used for the missing elements.
The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string.
EXAMPLES
The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f}
{
lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop.
The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} {
lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop.
The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} {
lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop.
SEE ALSO
for(n), while(n), break(n), continue(n)
KEYWORDS
foreach, iteration, list, looping
Tcl foreach(n)