Skip to main content

List Difference

rascal-0.34.0

Synopsis

The difference between two lists.

Syntax

Exp₁ - Exp₂

Types

//

Exp₁Exp₂Exp₁ - Exp₂
list[T₁]list[T₂]list[lub(T₁,T₂)]
list[T₁]T₂list[lub(T₁,T₂)]

Description

If both Exp₁ and Exp₂ have a list as value, the result is the difference of these two list values. If Exp₂ does not have a list as value, it is first converted to a list before the difference is computed. The difference is computed by taking the successive elements of the second list and removing the first occurrence of that element in the first list.

Examples

rascal>[1, 2, 3, 4] - [1, 2, 3];
list[int]: [4]
rascal>[1, 2, 3, 4] - [3];
list[int]: [1,2,4]
rascal>[1, 2, 3, 4] - 3;
list[int]: [1,2,4]
rascal>[1, 2, 3, 4] - [5, 6, 7];
list[int]: [1,2,3,4]
rascal>[1, 2, 3, 1, 2, 3] - [1];
list[int]: [2,3,1,2,3]
rascal>[1, 2, 3, 1, 2, 3] - [1, 2];
list[int]: [3,1,2,3]