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 6729255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:16:03+00:00 2026-05-26T10:16:03+00:00

I am facing problem how to check whether the list returned by the procedure

  • 0

I am facing problem how to check whether the list returned by the procedure consist of a single list or may have sub list inside.

#simple list
set a { 1 2 3 4}

# list consisting of sub list
set a { {1 2 3 4} {5 6 7 7} }

As above some times the variable a will have a list and sometime proc will return list consisting of sub list.

Update part

set a [mysqlsel $db “SELECT * FROM abc” -list]

I do not know weather query will return a single list or list consisting of sublist

  • 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-05-26T10:16:04+00:00Added an answer on May 26, 2026 at 10:16 am

    You should really rethink your approach: since Tcl is typeless, you can’t really tell if {{1 2 3 4} {5 6 7 8}} is a list of two lists or a list of two strings or a literal string {1 2 3 4} {5 6 7 8}, because all these propositions are true depending on how you make Tcl interpret this value.

    Another thing, is that even if you were to try something like catch {lindex $element 0} or string is list $element on each top-level element to see if it can be interpreted as a list, that would qualify as being non-lists only strings that really can’t be parsed as lists, like aaa { bbb. And string foo is also a proper list (of length 1, containing “foo” as its sole element).

    One approach you can consider using is wrapping the returned value in another value which has some sort of “tag” attached to it–the trick routinely used in some other typeless languages like LISP and Erlang. That would look like this:

    • If you need to return 1 2 3 4, return {flat {1 2 3 4}} instead.
    • If you need to return {1 2 3 4} {5 6 7 8}, return {nested {{1 2 3 4} {1 2 3 4 5}}}.

    Then in the client code do switch on the “tag” element and decapsulate the payload:

    lassign [your_procedure ...] tag payload
    switch -- $tag {
      flat {
        # do something with $payload
      }
      nested {
        # do something with $payload
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently facing the problem to check whether a property of an Object
I facing a weird problem here. I already have a simple try-out for jquery
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
Brand new to android and facing a weird problem.Check out the code below FirstActivity.java:
I have developed some code, and I'm facing problem with error flagging of the
I am facing a problem storing original values of a form. I have a
I have never dealt with regular expressions before, and I am facing a problem
I am facing some problem with ListView , I have inflated a layout with
I am facing problem while trying to open a simple text file in C#.
I am facing one problem. I have to create asp.net 4.0 web application which

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.