Group Abstract Group Abstract

Message Boards Message Boards

Deduct by the rules for two schemes?

Posted 7 years ago

Consider the following code:

Input[1]: rules = {a -> b, b -> c, c -> x, b -> d, d -> y};a//.rules;
output[2]:x

In the above program, "b" respectively implies two variables "c" and "d", and the two branches respectively go to the two terminal results "x" and "y". But the program runs only one branch a->b->c->x,losing a->b->d->y. Is there any approach to run all elements of the set of rules, so that the output would be "x" and "y"?

POSTED BY: Math Logic
4 Replies
Posted 7 years ago

Excellent! Many thanks!

POSTED BY: Math Logic
Posted 7 years ago
POSTED BY: Math Logic
Posted 7 years ago
POSTED BY: Michael Helmle

Here is my not very elegant approach (I am curious to see other/better solutions):

a //. Permutations[rules] // Union
(*  Out:  {x,y}  *)
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard