Inverted syntax

From Fōrmulæ wiki
Revision as of 15:09, 1 August 2019 by Admin (Talk | contribs) (Inverted syntax with assignment)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is the answer to the task Inverted syntax in the Rosetta Code.

Description (from Rosetta Code)

Inverted syntax with conditional expressions

In traditional syntax conditional expressions are usually shown before the action within a statement or code block:

IF raining=true THEN needumbrella=true

In inverted syntax, the action is listed before the conditional expression in the statement or code block:

needumbrella=true IF raining=true

Inverted syntax with assignment

In traditional syntax, assignments are usually expressed with the variable appearing before the expression:

a = 6

In inverted syntax, the expression appears before the variable:

6 = a


The task is to demonstrate support for inverted syntax forms within the language by showing both the traditional and inverted forms.


Inverted syntax with conditional expressions

The following is how is visualized the common If expression:


The following is the visualization of the Inverted If expression. Note that they are different expressions, in order that they can be visualized in different form, but they reduce the same way.


Inverted syntax with assignment

The Assignment expression does not have an inverted form, so it looks as usual;


However, Fōrmulæ supports right to left orientation, in such a case the last expression would look like:


Right to left orientation might look confusing. The following are the right to left visualization of both the traditional and inverted conditional we have seen above: