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

  • Home
  • SEARCH
  • 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 8909849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:32:20+00:00 2026-06-15T03:32:20+00:00

How Do I convert the below string/list to a list whose first element is

  • 0

How Do I convert the below string/list to a list whose first element is 1-81 second element is 81-162 3rd element us 162-243 using tcl

{} {} {1 -81} { } {81 -162} { } {162 -243} { } {243 -324} { } {324 -405} { } {405 -486} { } {486 -567} { } {567 -648} { } {648 -729} { } {729 -810} { } {810 -891} { } {891 -972} { } {972 -1053} { } {1053 -1134} { }

Thanks

  • 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-15T03:32:21+00:00Added an answer on June 15, 2026 at 3:32 am

    If you just want to filter out empty list elements, the obvious thing to do is:

    # Assuming the original list is in $list
    
    set result {}
    foreach x $list {
        if {[string trim $x] != ""} {
            lappend result $x
        }
    }
    
    # The result list should contain the cleaned up list.
    

    Note that you don’t need to do the [string trim] if you’re sure all empty elements really are empty and don’t contain whitespace (meaning {} instead of possibly { }). But your example contain both empty elements and whitespace so you need to do the string trim.

    Alternatively you can use a regular expression to test:

    foreach x $list {
        # Test if $x contains non-whitespace characters:
        if {[regexp {\S} $x]} {
            lappend result $x
        }
    }
    

    You can however do the above in a single line using lsearch:

    # Find all elements that contain non whitespace characters:
    
    set result [lsearch -inline -all -regexp $list {\S}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<Parts>' Below is the code generating this error.
I want to convert below string to an array in javascript. {a:12, b:c, foo:bar}
I'm attempting to convert a string to a TStream. My code below gives me
I need to convert a navigable map to a 2D String array. Below given
I am using .NET 3.5 and need to convert the below select new result
I am trying to access each element in a List<string> list and split each
please see the list below : string[] Separator = new string[] { __ };
Possible Duplicate: C# ‘var’ vs specific type performance When I write below code: List<string>
I'm trying to convert some older code for Windows 8 using SQLite. Below is
In the below example, how can I easily convert eventScores to List<int> so that

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.