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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:17:46+00:00 2026-05-27T17:17:46+00:00

I am writing a debug function, which prints a variable name, and its value.

  • 0

I am writing a debug function, which prints a variable name, and its value. I call this debug function with a list of variables from anywhere in the program. So the idea is for it to work like this:

debug[var_List] := Module[{values = ReleaseHold[var], i},

  For[i = 1, i <= Length[values], i++,
   Print[var[[i]], " = ", values[[i]]]
   ]
  ];

Now I use the above, like this

x = 3; y = 5;
debug[{HoldForm[x], HoldForm[y]}]

and I see in the console the following

 x = 3
 y = 5

But I have a large program and long list of variables at different places I want to debug. And I do not want to type HoldForm to each variable to make up the list to call the debug[] function. Much easier to Map it if possible. Less typing each time. But this does not work:

 debug[ Map[HoldForm,{x,y}]]

The reason is that {x,y} was evaluated before HoldForm got hold of it. So I end up with a list that has the values in it, like this:

 3 = 3
 5 = 5

I could not find a way to Map HoldForm without the list being evaluated.

The best I could find is this:

debug[HoldForm[Defer[{x, y}]]]

which gives the following output from the above debug[] function:

{x,y} = {3,5}

Since Defer[{x, y}] has length 1, and it is just one thing, I could not break it up to make a 2 column list like in the above example.

It will be better if I can get an output of the form

 x = 3
 y = 5

easier to match the variable with its value since I have many variables.

question is: Any one knows of a programming trick to convert HoldForm[{x,y}] to {HoldForm[x],HoldForm[y]}

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-05-27T17:17:46+00:00Added an answer on May 27, 2026 at 5:17 pm

    Just use Thread:

    Thread[HoldForm[{x, y}]]
    

    alternatively,

    Map[HoldForm, Unevaluated[{x, y}]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a Java function to reverse a linked list in-place. I am
When I am writing Javascript, I use window.alert() to debug. Usually I pass variables
I am writing an XNA library, and I need to view its debug output
I'm writing a little debug app for a bit of kit we're developing and
When writing C/C++ code, in order to debug the binary executable the debug option
I'm writing a class in C++ that I cannot debug by using F5. The
I am writing a desktop and j2me application. I have debug statements in program.
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I'm working on writing an OS and I'm running into problems trying to debug
I'm writing a jQuery plug-in so I can reuse this code in many places

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.