function rotate<T> (arr: T[], forward): T[] { // /!\ mute array, the mutation is "the state"
  if (forward) {
    arr.push(arr.shift())
  } else {
    arr.unshift(arr.pop())