2 ms·
With backtracking you typically have some kind of pruning stragegy. That means keeping track of your best result so far and dont go into branches where it is cl
by misja111 10y ago
With backtracking you typically have some kind of pruning stragegy. That means keeping track of your best result so far and dont go into branches where it is clear that they can never beat your current winner anymore.
So you cannot simply concatenate the results of the subbranches, each new branch needs to be aware of what has been found so far. That can quickly become ugly in pure FP, that's why people have been looking for solutions that do that in an elegant way, e.g. using Monads.
- setra 10y agoPruning can be implemented by just not computing a part of a stream based on some predicate. If you want some kind of global state of the current results then you just pass around the current calculated states. Pure FP has many simple solutions for passing around state.