Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.1K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Question about the RuleDelayed and the definition of delayed

Posted 5 years ago
POSTED BY: Timo K
2 Replies
Posted 5 years ago

Thank you!

POSTED BY: Timo K
Posted 5 years ago

Hi Timo,

With Rule the pattern will be evaluated prior to application of the rule, so any definition of i that is in scope will be used rather than the value matching the pattern.

x = 1; i = 1;
{1, 2, 3} /. i_Integer -> {i, x++}
(* {{1, 1}, {1, 1}, {1, 1}} *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard