% crochet

// Collections of elements.
//
// - Required: `_ has: _`, `_ is-empty`, `#_ empty`, `_ ++ _`

command #tuple empty = [];

command (X is tuple) is-empty =
  X count =:= 0
test
  assert [] is-empty;
  assert not ([0] is-empty);
end

command (X is tuple) has: Value =
  foreign tuple.contains(X, Value)
test
  assert not ([] has: 1);
  assert ([1] has: 1);
  assert ([0, 1, 2] has: 1);
  assert not ([0, 1, 2] has: 3);
end

command (X is tuple) ++ (Y is tuple) = 
  foreign tuple.concat(X, Y)
test
  assert ([] ++ []) =:= [];
  assert ([1, 2, 3] ++ []) =:= [1, 2, 3];
  assert ([] ++ [1, 2, 3]) =:= [1, 2, 3];
  assert ([1, 2] ++ [3, 4, 5]) =:= [1, 2, 3, 4, 5];
end
