Find first missing positive: Difference between revisions

Content added Content deleted
Line 951:
<code>uniquewith</code> is defined at [[Remove duplicate elements#Quackery]] and conveniently sorts the nest.
 
Then hunt for the first item which does not have the same value as its index. If they all have the same values as their indices, the missing integer is the same as the size of the processed nest.
 
<syntaxhighlight lang="Quackery"> [ dup size 1+ [] rotswap
witheach
[ dup 0 > iff
Line 960:
0 join
uniquewith >
dup size swap
witheach
[ i^ != if
[ drop i^
conclude ] ] ] is task ( [ --> n )
 
' [ [ 1 2 0 ] [ 3 4 -1 1 ] [ 7 8 9 11 12 ] ]
 
witheach [ task echo sp ]</syntaxhighlight>
</syntaxhighlight>
 
{{out}}