Timeline for Changing the definition of N: unexpected $RecursionLimit::reclim error
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:55 | history | edited | CommunityBot |
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
|
|
Dec 3, 2014 at 5:11 | vote | accept | ktm | ||
Nov 28, 2014 at 19:50 | comment | added | Alexey Popkov | @OleksandrR. I included your workaround in my answer. If you post your own answer, I'll delete the corresponding part of mine. | |
Nov 28, 2014 at 19:49 | history | edited | Alexey Popkov | CC BY-SA 3.0 |
added 864 characters in body
|
Nov 28, 2014 at 19:27 | comment | added | Alexey Popkov |
@OleksandrR. I tried to set the NHoldAll attribute for Object but it does not help. Looks like a bug indeed.
|
|
Nov 28, 2014 at 19:16 | comment | added | Oleksandr R. |
The Trace is not very enlightening, but I think this may have to do with the recursive behavior of N . When called on any expression, it applies itself to the parts first (and the parts of the parts, &c.) in an effort to numericize the whole. Here it seems that it gets stuck while repeatedly trying to numericize the second argument. Possibly a bug in N ? By the way, a better pattern is Object /: Verbatim[N][Object[arg1_, arg2_, argRest__], Narg : _ | PatternSequence[]] := Object[arg1, N[arg2, Narg], argRest] . This handles the argument of N correctly.
|
|
Nov 28, 2014 at 18:55 | comment | added | Alexey Popkov |
@OleksandrR. It works, thank you. Do you have any idea why the recursion limit error appears without Verbatim ?
|
|
Nov 28, 2014 at 18:53 | comment | added | Oleksandr R. |
Object /: Verbatim[N][Object[arg1_, arg2_, argRest__]] := Object[arg1, N[arg2], argRest]
|
|
Nov 28, 2014 at 18:23 | comment | added | Alexey Popkov |
Sorry for disinformation but with UpValues I get the recursion limit error too. The idea was: Object /: N[Object[arg1_, arg2_, argRest__]] := Object[arg1, N@arg2, argRest] . I do not know why with N this gives the recursion limit error, it does work with other heads.
|
|
Nov 28, 2014 at 18:08 | comment | added | ktm |
Can you explain a lit bit more about UpValues ? I'm afraid, I haven't understood you.
|
|
Nov 28, 2014 at 18:00 | comment | added | Alexey Popkov |
In this case you will not have such a simple and elegant solution and probably will need to go through UpValues in a way similar to what you showed in your question. Other way is shown by @belisarius in his comment.
|
|
Nov 28, 2014 at 17:35 | comment | added | ktm |
Wow, what a nice attribute! This will probably solve my problem. Don't you know, what can I do, if my data list is somewhere between other parameters, like: Object[param1, data, param2] ? I can place my list at the first place in Object , but maybe I can somehow avoid this.
|
|
Nov 28, 2014 at 15:30 | history | answered | Alexey Popkov | CC BY-SA 3.0 |