Jaccard index: Difference between revisions

Add APL
(Add APL)
Line 16:
Write a program that computes the Jaccard index for every ordered pairing (to show that J(A, B) and J(B, A) are the same) of these sets, including self-pairings.
<br><br>
 
=={{header|APL}}==
<lang apl>task←{
jaccard ← (≢∩)÷(≢∪)
 
A ← ⍬
B ← 1 2 3 4 5
C ← 1 3 5 7 9
D ← 2 4 6 8 10
E ← 2 3 5 7
F ← ,8
 
'.ABCDEF' ⍪ 'ABCDEF' , ∘.jaccard⍨ A B C D E F
}</lang>
{{out}}
<pre>. A B C D E F
A 1 0 0 0 0 0
B 0 1 0.4285714286 0.25 0.5 0
C 0 0.4285714286 1 0 0.5 0
D 0 0.25 0 1 0.125 0.2
E 0 0.5 0.5 0.125 1 0
F 0 0 0 0.2 0 1 </pre>
 
=={{header|Factor}}==
2,096

edits