std-intersection


Synopsis

(std-intersection <lst1> <lst2>)

Description

STD-INTERSECTION returns the intersection of the two sets lst1 and lst2, a list of all elements that are in both lists. The returned list keeps the order of the first list, but we cannot consider it stable because of the problem outlined below.

Problem with Duplicates

The actual implementation has a problem with duplicate elements in the first list:

You might expect that (std-intersection '(0 0 0 1) '(0 0 1)) returns (0 0 1), but it actually returns (0 0 0 1).

Example

(std-intersection '(0 1 2) '(2 3 4))	=> (2)

Arguments

lst1, lst2: proper lists, without defined order.

Return Value

The intersection set. A list with elements which are contained in both lists, keeping the order of the first list.

Side Effects

None.

Module

(std-require 'STDLIST)

Defined in STDLIST