Skip to content

tlhakatlhakanya

Jumbles the items of a list into an order that cannot be predicted.

By default tlhakatlhakanya makes a copy of the list, shuffles that copy, and returns it. The original list is left unchanged — which matters when you want to use it again afterwards.

When you pass nnete as a second value, the original list itself is shuffled, and is also returned.

tlhakatlhakanya(lenaneo) — a fresh copy; the original is untouched. tlhakatlhakanya(lenaneo, nnete) — the original is changed.

The order differs every time the sketch runs, so do not expect to see the same thing twice.

tlhakatlhakanya(lenaneo, fetolaLaNtlha)
NameTypeDescription
lenaneolenaneoThe list to shuffle.
fetolaLaNtlha (optional)nnetemaakaWhen nnete, the original list itself is changed. Defaults to maaka, which makes a copy.
Circles in a jumbled order
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(220);
  tlogelaMothalo();

  diri dibogolo = [40, 80, 120, 160];
  diri lenaneo = tlhakatlhakanya(dibogolo);

  kwala(dibogolo);
  kwala(lenaneo);

  diri x = 70;
  gopheta (metlha bogolo mo lenaneo) {
    tlatsaMmala(0, 60 + bogolo, 200);
    kgolokwe(x, 200, bogolo);
    x = x + 90;
  }
}
A copy, or the original list itself
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(220);
  tlogelaMothalo();

  diri dibogolo = [40, 80, 120, 160];

  // Ka tlwaelo go dirwa khopi — lenaneo la ntlha ga le fetoge
  tlhakatlhakanya(dibogolo);
  kwala(dibogolo);

  // Ka `nnete`, lenaneo la ntlha ka bolona le a fetoga
  tlhakatlhakanya(dibogolo, nnete);
  kwala(dibogolo);

  diri x = 70;
  gopheta (metlha bogolo mo dibogolo) {
    tlatsaMmala(200, 100, 60);
    kgolokwe(x, 200, bogolo);
    x = x + 90;
  }
}

kgaoganyaMokwalo, nnete, gopheta