Common list elements: Difference between revisions
Content added Content deleted
(Added Go) |
(Realize in F#) |
||
Line 9: | Line 9: | ||
<br><br> |
<br><br> |
||
=={{header|F_Sharp|F#}}== |
|||
Of course it is possible to use sets but I thought the idea was not to? |
|||
<lang fsharp> |
|||
// Common list elements. Nigel Galloway: February 25th., 2021 |
|||
let nums=[|[2;5;1;3;8;9;4;6];[3;5;6;2;9;8;4];[1;3;7;6;9]|] |
|||
printfn "%A" (nums|>Array.reduce(fun n g->n@g)|>List.distinct|>List.filter(fun n->nums|>Array.forall(fun g->List.contains n g)));; |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
[3; 9; 6] |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Note: in older versions of Factor, <code>intersect-all</code> was called <code>intersection</code>. |
Note: in older versions of Factor, <code>intersect-all</code> was called <code>intersection</code>. |