Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Single-step evaluation in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81235] Single-step evaluation in Mathematica
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Mon, 17 Sep 2007 03:32:27 -0400 (EDT)

I would like to have a function, hasOwnValue, that takes the name of a 
symbol as a string, and tells whether the symbol has an own-value.  It 
should do this without evaluating the value of the symbol.

Examples:

abc := Print["side effect"]
xyz =.

In := hasOwnValue["abc"] (* "side effect" must not be printed *)
Out = True

In := hasOwnValue["xyz"]
Out = False

How can I achieve this?

This is a practical problem that I ran into, but the general question 
is:  What do you do when you feel the need for *single-step evaluation* 
in Mathematica?  E.g. how can I manipulate/transform held expressions 
made up of symbols that have values?  An artificial example:

a = 1
Hold[{a,b,c}]

How do I reverse the list inside Hold?  I could map Hold to each 
element, reverse the list, hold the list again, and remove Hold from 
individual elements to get Hold[{c,b,a}], but this is very inconvenient.

Szabolcs


  • Prev by Date: question on 2 separate Mathematica instances on the same PC
  • Next by Date: piecewise functions from logical relationships (ie. solving with constraints)
  • Previous by thread: Re: question on 2 separate Mathematica instances on the same PC
  • Next by thread: Re: Single-step evaluation in Mathematica