Talk:Order disjoint list items: Difference between revisions

(→‎Perl 6 entry: regarding members of N not in M)
Line 9:
 
:I've added the requested cases; you'll note that the solution to A X ==> Y A assumes (reasonably, I think) that the N list elements are a subset of the M elements, as the task postulates without commentary on violations. The reason I think this assumption is okay is that it scales well to arbitrarily long M lists (indeed, Perl 6 could apply this function lazily to an infinitely long M list, though of course it can't work with an infinitely long N list due to the necessity of testing set/bag membership). We tend to avoid solutions that require an unnecessary prescan of a list for this reason, and it would take such an "unnecessary" prescan of M to enforce set membership in the other direction. In any case, whether or not your language supports infinite lists, it's extra work, and prevents the function from being used to substitute a list of words that weren't in the original, which seem like a kind of arbitrary restriction from a practical point of view. --[[User:TimToady|TimToady]] ([[User talk:TimToady|talk]]) 04:40, 13 May 2014 (UTC)
 
:: I agree with you, and I somehow missed the "N items chosen from M" part completely. I don't much care about the second test case, it's the first one that's important, but then I wrote it wrong: it's M = <X X Y> and N = <X>. Basically your test should read <tt>bag{$_}-- > 0</tt> instead of just a non-zero test, if Perl 6 hash works similarly to 5. --[[User:Ledrug|Ledrug]] ([[User talk:Ledrug|talk]]) 05:04, 13 May 2014 (UTC)
Anonymous user