Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #312 List equality

Set b to true if the lists p and q have the same size and the same elements, false otherwise.

import "golang.org/x/exp/slices"
b := slices.Equal(p, q)
classes
  b := (p.count = q.count);
  if b then for i := 0 to p.count-1 do 
    if (p.items[i] <> q.items[i]) then
    begin
      b := false;
      break;
    end;
b = p == q
b = p == q

New implementation...
< >
programming-idioms.org