Sponsored Content
Full Discussion: Recursive Lists in Tcl
Top Forums Shell Programming and Scripting Recursive Lists in Tcl Post 302530445 by sarbjit on Tuesday 14th of June 2011 03:48:38 AM
Old 06-14-2011
You need to execute the procedure again in order to calculate the index of newly created list.

For instance if my initial list list1 has elements as 'a b c' and i inserted an element at last i need to pass this modified list again to procedure.

Are you saying you want to handle lindex based on index returned by procedure? like for "h" it is 22, so if you add new element it should add in nested list.

Can you pls elaborate on your requirement.
 

10 More Discussions You Might Find Interesting

1. Programming

C++ programming using lists

To test this program it must create 2 integer lists - list1, list2 - and then read and process a series of list commands from a file named "data.txt". Each command and any associated values, list number, value appears on a separate line. All I can do is get it to input the integers and then... (3 Replies)
Discussion started by: tiger13e
3 Replies

2. Shell Programming and Scripting

How to get the files lists

Hi All, Need the help in getting the file list which are generated for the time period. example if i want to get the list of file generated between 11 to 12 clock. i used the find command search the files with -cmin flag with -60. find /home/test/* -cmin -60 -type f -exec ls {} \; ... (2 Replies)
Discussion started by: nmadhuhb
2 Replies

3. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

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

4. Shell Programming and Scripting

Using foreach with two lists

Hi everybody, I'm trying to use a foreach command with two lists. The file.txt looks like this: var1: 100 200 300 var2: 3 6 9 I'm trying to use a foreach command to associate the two variables together. My script looks like this: #! /bin/tcsh set a=(`cat file.txt | grep 'var1' | cut -d... (8 Replies)
Discussion started by: SimonWhite
8 Replies

5. Shell Programming and Scripting

combining two lists

Hi, So I I received two lists for my merchandise and both are similar but differences do occur. I want to combine two lists that have similar names but I dont want the similar name to come up twice because I will end up purchasing two of those items. Heres an example below (file is massive). ... (1 Reply)
Discussion started by: kylle345
1 Replies

6. Shell Programming and Scripting

get the lists

I expert, I may cross post something similar but I dirtyed my quesion somehow to be clear in the thread #cat file1 88dee gcc: Grok for callconvention-hard to enable hard float a2ad2 eglibc: package mtrace separately 61487 python: bump PR of packages after update of distutils.bbclass... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

7. Shell Programming and Scripting

Listing cross cases within lists in TCL

Hello everyone, I am new here forgive me if I omit something, I have a problem which I can't seem to solve using TCL so I am posting it here. Here it is : I retrieve a UNKNOWN number of lists from an XML file. Let's skip the part where I retrieve these lists and say for example that you have... (4 Replies)
Discussion started by: Noobard
4 Replies

8. UNIX for Dummies Questions & Answers

Lists in awk

Hi togehter! I would like to write an awk script which prints the first column divided by the sum of the second column: So if this is my list 1 2 2 1 3 1 4 1 it should print a list like this: 1/5 2/5 3/5 4/5 My idea was to use END like this: (3 Replies)
Discussion started by: bjoern456
3 Replies

9. Shell Programming and Scripting

Issue with Lists

Hey guys, so I wrote this simple script. The first time I typed it all out, I had the issue where whatever choice I entered, it would simply tell me it was a "bad selection" aka the else output. I redid everything, and now no matter the choice, it does the backup option.. My brain hurts, and... (12 Replies)
Discussion started by: jakelawson44
12 Replies

10. Shell Programming and Scripting

Combining lists

Hello everybody. My operating system is Fedora30, shell - bash I faced combining lists. I will be glad for help regarding strings, arrays and so on. The bottom line is as follows. It is necessary to combine each element from the first list with elements from the second. if the second is longer... (4 Replies)
Discussion started by: nezabudka
4 Replies
lreplace(n)						       Tcl Built-In Commands						       lreplace(n)

__________________________________________________________________________________________________________________________________________________

NAME
lreplace - Replace elements in a list with new elements SYNOPSIS
lreplace list first last ?element element ...? _________________________________________________________________ DESCRIPTION
lreplace returns a new list formed by replacing one or more elements of list with the element arguments. first and last are index values | specifying the first and last elements of the range to replace. The index values first and last are interpreted the same as index values | for the command string index, supporting simple index arithmetic and indices relative to the end of the list. 0 refers to the first ele- | ment of the list, and end refers to the last element of the list. If list is empty, then first and last are ignored. If first is less than zero, it is considered to refer to before the first element of the list. For non-empty lists, the element indicated by first must exist or first must indicate before the start of the list. If last is less than first, then any specified elements will be inserted into the list at the point specified by first with no elements being deleted. The element arguments specify zero or more new arguments to be added to the list in place of those that were deleted. Each element argu- ment will become a separate element of the list. If no element arguments are specified, then the elements between first and last are sim- ply deleted. If list is empty, any element arguments are added to the end of the list. EXAMPLES
Replacing an element of a list with another: % lreplace {a b c d e} 1 1 foo a foo c d e Replacing two elements of a list with three: % lreplace {a b c d e} 1 2 three more elements a three more elements d e Deleting the last element from a list in a variable: % set var {a b c d e} a b c d e % set var [lreplace $var end end] a b c d A procedure to delete a given element from a list: proc lremove {listVariable value} { upvar 1 $listVariable var set idx [lsearch -exact $var $value] set var [lreplace $var $idx $idx] } SEE ALSO
list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n), lset(n), lrange(n), lsort(n), string(n) | KEYWORDS
element, list, replace Tcl 7.4 lreplace(n)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy