UP | HOME
grm blog. Work is copyrighted unless otherwise stated.
2020-11-23 Mon
^

Multidimentional arrays and l33tspeak

Ha\/inG LOGIC 3ncOded In Y0Ur dAt@ DeFINITIoNs CAn b3 a verY useFul tHing @S liSp-Like l4NGUaGES Pr0\/E TIMe and 4GaiN. When UsIng C hOweVer it'S usuaLlY rEcOmmeNDed to STIck T0 Th3 imPer4tIv3 TecHnIQueS aNd @Void 3mbedDiNG daTA wiTH LOgIC.

H@ving ThIS iN mInd, I Rarely used L0gIc-E|\/|bedded data in mY C projeCTS. And as 4 siD3 3FfecT I Ne\/3R got TO Expl0r3 |\/|uLtidImEnTIONal C arr4Ys, aS I NEVEr H4d 4 neEd FOr ThOs3 sincE I 3Nc0dED all |\/|Y D4T@ IN STrUcts.

I hAd an idea lYiNG aroUNd in a .C fil3 f0R a wHile now, a sImplE pRogrAm t0 TuRn Text In l33TsPeAK, ANd T0dAY I hAd AN EpIpH@Ny to use @ mUltidIMentiOn@l @Rray t0 3NcODE th3 mApPinG fr0m ThE 3Nglish char4CT3rs to th3 L33tspEAk SyMbolS.

THiS iS thE OutpUT of tHe progr4m! And tHIs iS Th3 MuLtIdiMenTion4l aRraY:

struct x {
  char k;
  int n;
  char v[10][10];
};

const struct x M[] = {
  {.k = 'a', .n = 3, .v = {"A", "@" , "4"  } },
  {.k = 'b', .n = 2, .v = {"B", "|3",      } },
  {.k = 'c', .n = 1, .v = {"C",            } },
  {.k = 'd', .n = 1, .v = {"D",            } },
  {.k = 'e', .n = 2, .v = {"E", "3",       } },
  {.k = 'f', .n = 1, .v = {"F",            } },
  {.k = 'g', .n = 1, .v = {"G",            } },
  {.k = 'h', .n = 1, .v = {"H",            } },
  {.k = 'i', .n = 1, .v = {"I",            } },
  {.k = 'j', .n = 1, .v = {"J",            } },
  {.k = 'k', .n = 1, .v = {"K",            } },
  {.k = 'l', .n = 1, .v = {"L",            } },
  {.k = 'm', .n = 2, .v = {"M", "|\\/|",   } },
  {.k = 'n', .n = 1, .v = {"N",            } },
  {.k = 'o', .n = 2, .v = {"O", "0",       } },
  {.k = 'p', .n = 1, .v = {"P",            } },
  {.k = 'q', .n = 1, .v = {"Q",            } },
  {.k = 'r', .n = 1, .v = {"R",            } },
  {.k = 's', .n = 1, .v = {"S",            } },
  {.k = 't', .n = 1, .v = {"T",            } },
  {.k = 'u', .n = 1, .v = {"U",            } },
  {.k = 'v', .n = 2, .v = {"V", "\\/"      } },
  {.k = 'w', .n = 2, .v = {"W", "\\/\\/"   } },
  {.k = 'x', .n = 1, .v = {"X",            } },
  {.k = 'y', .n = 1, .v = {"Y",            } },
  {.k = 'z', .n = 1, .v = {"Z",            } },
};