Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Question about mathematics commands

  1. May 23, 2012 #1
    I was going to ask if there's a way to command mathematica not to run a sentence or a part of a sentence as "//" works in php and "!" in fortran
  2. jcsd
  3. May 23, 2012 #2
    You mean comment out a line?

    (* This is a Mathematica comment *)
  4. May 23, 2012 #3
    is that the only way
    isn't there any syntax like the ones in fortran or php?
  5. May 23, 2012 #4
    I don't think I follow...

    This is a command // remove this bit in PHP (or C++)
    This is a command ! remove this bit in Fortran
    This is a command (* remove this bit in Mathematica *)
    This is a command /* remove this bit in C */

    The start and end braces mean you can have it mid-line, whereas the // and ! assume you mean 'comment out to the end of the line'.

    a = b + c (* + d *) + e

    will give you a = b + c + e
  6. May 23, 2012 #5
  7. May 24, 2012 #6
    If the material you want to comment out is in a separate cell, or you position the cursor and divide the cell with <shift><ctrl>d to put the material in a separate cell, then you change the cell properties and make that a text cell or a Section cell or a SubSection cell or any other kind of cell that isn't evaluated.

    Later you can merge the cells back together by selecting the desired cells and merging with <shift><ctrl>m

    This would not be appropriate for some things.

    Or... something perhaps much less appropriate. What if you picked one of the otherwise unused characters, defined it to be an operator, which is really just a function, set the attributes so that it would not evaluate any arguments and had the operator return Null. I am not certain all this could be done or that this would be a good idea.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook