Enumerating all possibilites for a nondeterministic list
I'm working with lists that could have "ambiguous" values in certain
places. The lists are small enough that implementing backtracking search
seems silly. Currently, I'm representing ambiguous values in my lists with
sub-lists containing possible values. For instance, the list:
[1, 2, [3,4]]
Could be either the list [1,2,3] or [1,2,4]. Lists may have multiple
ambiguous values in them, though ambiguous elements may not themselves
contain ambiguous elements. Given a list with ambiguous values in it, I'm
trying to generate a list of all the possible lists that list could
represent. The previous list should return [[1,2,3],[1,2,4]].
Is there an elegant way to do this? I tried to recursively build each list
backwards and append to an empty list, but I can't quite wrap my brain
around how to do it.
No comments:
Post a Comment