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

MathGroup Archive 1997

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

Search the Archive

Functions and evaluation, returning themselves

  • To: mathgroup at smc.vnet.net
  • Subject: [mg7212] Functions and evaluation, returning themselves
  • From: Red <red at nym.alias.net>
  • Date: Fri, 16 May 1997 02:30:54 -0400 (EDT)
  • Organization: mail2news@nym.alias.net
  • Sender: owner-wri-mathgroup at wolfram.com

-----BEGIN PGP SIGNED MESSAGE-----

I am trying to write a function in Mathematica
that can give a message and return the 
expression entered.

For example
In[1] :=  Sin[]

``Sin::"argx":
 "Sin called with 0 arguments; 1 argument is expected.

Out[1]=  Sin[]

(There is no HoldForm around this output)


To do this I tried to make definitions like

f[] := (Message[f::argx]; Return @ Unevaluated @ f[])

But the Out is
Unevaluated[f[]]  instead of f[]

or
f[] := (Message[f::argx]; Unevaluated @ f[])

which gives infinite recursion.

I tried some definitions that change 
$Line or DownValues[Out].

f[] := (Message[f::argx]; l = $Line; $Line = Infinity;
Unprotect[Out]; Out[l] := f[]; Protect[Out]; $Line = l+1)



If you know how to write a function that acts like Sin
above then please help.


- -----------
finger:red at nym.alias.net


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBM3i8Vbcaab4ltFhVAQHYNgP8D9dGsDBwL3ikruifff8xVZr9czX6nc4L
bCsZeErDDcdGCHmSCtTgpguJSMAmDe1lM/mB0TErzW78JSd7i/cshJsYjpXYbiLd
DyearYmI/ZQ3x5Wyltz+rMwAHyjEd6sc7PUgtA4nyeoqtpF379/vuzA+vQyYy8rw
jbjkTOzA0UE=
=/jws
-----END PGP SIGNATURE-----




  • Prev by Date: Re: ParametricPlot Remark
  • Next by Date: Re: Re: Input using palettes
  • Previous by thread: Re: Nonlinear Fit Problem
  • Next by thread: Re: Functions and evaluation, returning themselves