Common list elements: Difference between revisions

(Added Perl)
Line 119:
{{out}}
<pre>3 6 9</pre>
 
=={{header|Phix}}==
<lang Phix>function intersection(sequence s)
sequence res = {}
if length(s) then
for i=1 to length(s[1]) do
integer candidate = s[1][i]
bool bAdd = not find(candidate,res)
for j=2 to length(s) do
if not find(candidate,s[j]) then
bAdd = false
exit
end if
end for
if bAdd then res &= candidate end if
end for
end if
return res
end function
?intersection({{2,5,1,3,8,9,4,6},{3,5,6,2,9,8,4},{1,3,7,6,9}})
?intersection({{2,2,1,3,8,9,4,6},{3,5,6,2,2,2,4},{2,3,7,6,2}})</lang>
{{out}}
<pre>
{3,9,6}
{2,3,6}
</pre>
 
=={{header|Raku}}==
7,806

edits