Find first missing positive: Difference between revisions

m
Added Easylang
(add RPL)
m (Added Easylang)
 
(2 intermediate revisions by 2 users not shown)
Line 573:
</pre>
 
 
=={{header|EasyLang}}==
<syntaxhighlight>
func missing a[] .
h = 1
repeat
v = 0
for v in a[]
if h = v
break 1
.
.
until v <> h
h += 1
.
return h
.
a[][] = [ [ 1 2 0 ] [ 3 4 -1 1 ] [ 7 8 9 11 12 ] ]
for i to len a[][]
write missing a[i][] & " "
.
</syntaxhighlight>
{{out}}
<pre>
3 2 1
</pre>
 
=={{header|F_Sharp|F#}}==
Line 1,204 ⟶ 1,230:
{{out}}
<pre>3, 2, 1</pre>
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">[[1,2,0], [3,4,1,1], [7,8,9,11,12],[1,2,3,4,5],
[-6,-5,-2,-1], [5,-5], [-2], [1], []].each {|arr|
var s = Set(arr...)
say (arr, " ==> ", 1..Inf -> first {|k| !s.has(k) })
}</syntaxhighlight>
{{out}}
<pre>[1, 2, 0] ==> 3
[3, 4, 1, 1] ==> 2
[7, 8, 9, 11, 12] ==> 1
[1, 2, 3, 4, 5] ==> 6
[-6, -5, -2, -1] ==> 1
[5, -5] ==> 1
[-2] ==> 1
[1] ==> 2
[] ==> 1</pre>
 
=={{header|True BASIC}}==
Line 1,278 ⟶ 1,321:
=={{header|Wren}}==
{{libheader|Wren-sort}}
<syntaxhighlight lang="ecmascriptwren">import "./sort" for Sort
 
var firstMissingPositive = Fn.new { |a|
2,063

edits