Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: is there an 'issue' with putting Notation[] command inside a Module[]?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113552] Re: is there an 'issue' with putting Notation[] command inside a Module[]?
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Tue, 2 Nov 2010 05:02:06 -0500 (EST)
  • References: <iam34e$k18$1@smc.vnet.net>

No problems here.

foo[p_] :=
 Module[{f},
  Notation[  f_i <==>  f[[i]] ]; f = {3, 2, 1, 6, 5}; Subscript[f, p]=
]

works just fine.

In[287]:= foo[4]

Out[287]= 6

Note that you can't copy this example above. You have to work through
the Notation palette to get the Notation template in place. So, when
precisely do you get those errors?

Cheers -- Sjoerd


On Nov 1, 11:00 am, "Nasser M. Abbasi" <n... at 12000.org> wrote:
> I really like the Notation package. I use it now, but very carefully and
> for very limited purpose, just to index my vectors and matrices by replac=
ing
>
> f[[i]]    by    f_i    <==== This is subscript, not u=
nderscore
> A[[i,j]]  by    f_i,j  <==== This is subscript, not under=
score
>
> So that the code is more clear, no need to enter double brackets any
> more, and no need to remember escape sequences for [[ ]] or to count
> Brackets. Many problems went away with this notation.
>
> But for the last 2 hrs, I have been struggling to find what was the
> problem with the code. It was working fine, but I started getting
> strange errors. Sometimes when I use  A[[i,j]] but not A_i,j the proble=
m
> went away, even though the notation was clear and correct.
>
> When I finally moved the Notation command outside the Module, then the
> problems went away.
>
> I had it originally like this:
>
> ------------------------
> foo[]:=Module[{f},
> Notation[  f_i <==>  f[[i]] ];
> .....
>
>     f_5= etc.....
>
> ]
> ------------------
>
> I was getting recursion error messages, and other weird errors.
>
> When I replaced the above with
>
> ------------------------
> Notation[  f_i <==>  f[[i]] ];
> foo[]:=Module[{},
>
>     f_5= etc.....
>
> ]
> ------------------
>
> I wanted to put the Notation[]; inside the module, since that is where
> my variable are, and I do not like to use the global name space if I can
> help it.
>
> Here is a screen shot, showing the Notations I was using and now I had
> to move them outside the Module where the variables are :(
>
> http://12000.org/tmp/notation/strange_notation_issue.png
>
> Any one knows if there is a problem with using Notation inside a Module
> or Block and such? I do not think it is a hidden character issue. So I
> think it is just Notation did not like being inside a Module? But why
> Recursions limit exceeded errors?
>
> thanks,
> --Nasser



  • Prev by Date: Re: Balance point of a solid
  • Next by Date: Re: Assertions in Mathematica?
  • Previous by thread: Re: Manipulate with dynamic maximum on slider
  • Next by thread: Re: is there an 'issue' with putting Notation[] command inside a Module[]?