Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:13:45+00:00 2026-06-05T22:13:45+00:00

I have a flat Tcl list. Now I want to append a new element

  • 0

I have a “flat” Tcl list. Now I want to append a new element as a child to one of the existing elements. How can I do this?

This is what I tried:

[ lindex $flights $i ] [ lindex $flight 0 ] ]

I try to add an element form the list “flight” to an element of the list “flights”. The element $i in the flights list already exists.

I might be running against Tcl syntax as I’m new to Tcl.

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:13:47+00:00Added an answer on June 5, 2026 at 10:13 pm

    You can use lset to replace an element of your list with a new list. http://www.tcl.tk/man/tcl8.5/TclCmd/lset.htm The first element of the new list will be the old element, the 2nd element will be its child. Here’s an example:

    % set flights [list a b c d e]
    a b c d e
    % set i 1
    1
    % lset flights $i [list b child]
    a {b child} c d e
    % lindex $flights 1
    b child
    % lindex [lindex $flights 1] 1
    child
    % lindex [lindex $flights 1] 0
    b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
I have the Lat/Long value of New York City, NY; 40.7560540,-73.9869510 and a flat
I want to use an embed an sqlite database into an existing tcl application
I used to have flat scripts. The classic HTML+PHP in one file: $result =
I have a flat array that I'm trying to make multidimensional. Basically, I want
I have a flat list of pages in a mySQL Table. ID | Tab
(This is rather hypothetical in nature as of right now, so I don't have
I have a flat file with xml data that contains parent and child information
Lets say I have a flat list of objects, each of which has a
I have a flat file source from Excel that has a structure like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.