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

MathGroup Archive 1993

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

Search the Archive

Re: Why printing?

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Re: Why printing?
  • From: jacobson at cello.hpl.hp.com
  • Date: Mon, 05 Apr 93 08:44:57 -0700

Trott Michael <Michael.Trott at physik.tu-ilmenau.de> notes the
following:

 1.) 
 {a,b}/.{x___,a,y___}:>Print[z;x]

 This prints z!!!

This is a normal consequence of the strange semantics of Mathematics.

For the pattern {x___,a,y___} to match {a,b}, x must be bound to an
empty sequence: Sequence[].  Now the FullForm of the Print thing is
Print[CompoundStatement[z,x]].  When we replace x by Sequence[], we
get Print[CompoundStatement[z,Sequence[]]], which immediately
collapses to Print[CompoundStatement[z]], which then evaluates to
Print[z].  

You have to be real careful with Sequences.  This is but one of many
examples where they result in unexpected behavior.

  -- David Jacobson







  • Prev by Date: line thickness and ScatterPlot3D
  • Next by Date: Help me
  • Previous by thread: Re: Why printing?
  • Next by thread: Re: Why printing?