Skip to content

Commit db95f35

Browse files
committed
Merge pull request #63 from sharkdp/documentation
Update documentation, resolves #56
2 parents dd9b949 + b7aafc6 commit db95f35

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Data/Array.purs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,16 @@ nubBy eq xs =
519519
Just o -> o.head : nubBy eq (filter (\y -> not (o.head `eq` y)) o.tail)
520520
Nothing -> []
521521

522-
-- | Calculate the union of two lists.
522+
-- | Calculate the union of two arrays. Note that duplicates in the first array
523+
-- | are preserved while duplicates in the second array are removed.
523524
-- |
524525
-- | Running time: `O(n^2)`
525526
union :: forall a. Eq a => Array a -> Array a -> Array a
526527
union = unionBy (==)
527528

528529
-- | Calculate the union of two arrays, using the specified function to
529-
-- | determine equality of elements.
530+
-- | determine equality of elements. Note that duplicates in the first array
531+
-- | are preserved while duplicates in the second array are removed.
530532
unionBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Array a
531533
unionBy eq xs ys = xs <> foldl (flip (deleteBy eq)) (nubBy eq ys) xs
532534

@@ -551,12 +553,16 @@ difference xs ys
551553

552554
infix 5 difference as \\
553555

554-
-- | Calculate the intersection of two arrays, creating a new array.
556+
-- | Calculate the intersection of two arrays, creating a new array. Note that
557+
-- | duplicates in the first array are preserved while duplicates in the second
558+
-- | array are removed.
555559
intersect :: forall a. Eq a => Array a -> Array a -> Array a
556560
intersect = intersectBy eq
557561

558562
-- | Calculate the intersection of two arrays, using the specified equivalence
559-
-- | relation to compare elements, creating a new array.
563+
-- | relation to compare elements, creating a new array. Note that duplicates
564+
-- | in the first array are preserved while duplicates in the second array are
565+
-- | removed.
560566
intersectBy :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Array a
561567
intersectBy eq xs ys = filter (\x -> isJust (findIndex (eq x) ys)) xs
562568

0 commit comments

Comments
 (0)