Skip to content

String reverser breakdown

Giorgio Garofalo edited this page Jan 29, 2024 · 6 revisions

Reverser

This sample reverses the string "Reversed" and prints it out.
Here you can find the color scheme used. Without it, obtained via the standardize command (plus some manual recoloring), it would look like this:

Standardized

Which can be decompacted into:

Decompacted

Line by line explanation:

  1. "Reversed" is saved into a variable .

  2. An empty string (final output) is saved into another variable . The black pixel is a non-displayed character that forces a string initialization.

  3. A for-each is used on our string which is read character by character.

  4. A lambda.open opens the sub-block and takes an argument (the character of the string which is being read).

  5. The output variable gets updated: its new value is: current char + output value .
    Again, the black pixel is used to force string concatenation between the values.

  6. lambda.close closes the for-each block.

  7. Print is called on the output value . desreveR is the output.