in reply to List all different equations for a given one
where a canonical sorting algorithm is used to order terms. Note that, if you want to accept complex expressions, the sort is non-trivial since you'll need to rank complex references, so cmp won't be enough. This type of format also supports nested operations:my $eq = {op => '+', terms => [1, 'x', ], };
You can then do a recursive descent in order to check equivalence. Of course, this isn't going to help you with distributivity.my $eq = {op => '+', terms => [{ op => '*', terms => [3, 'z', ], }, 'x', ], };
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: List all different equations for a given one
by jess195 (Novice) on Sep 24, 2013 at 17:06 UTC | |
by kennethk (Abbot) on Sep 24, 2013 at 17:10 UTC | |
by jess195 (Novice) on Sep 24, 2013 at 18:39 UTC |