Physica – Docs

Syntax

Physica's syntax is a mix of Python and Mathematica, along with a couple of unique elements, which are described thoroughly on this page.

String Literals

In order to create a string literal in Physica, you should use the delimiter '. If you don't want to encounter transpilation issues, please avoid ". Escaping works as expected: prepend a backslash to that character (e.g. 'Her name is \'Sally\'' gives Her name is 'Sally'). Note that you don't have to worry about transpiling in strings. The engine behing Physica's transpiler doesn't make any changes to pieces of code surrounded by ' characters.

Separators

Unlike Python's , (comma), the standard separator for function arguments is ; (semicolon). When it comes to multiple statements on the same line, it's the other way around: Instead of Python's semicolon (;), Physica uses a single comma (,)

Naming convensions

Variable names should preferrably start with a lowercase letter, and should only contain alphanumeric characters, combined with underscores.

Functions typically start with a uppercase letters. If a function's name consists of two or more words, they all start with uppercase letters. The rest of the characters in a function name are usually lowercase letters, with the exceptions being input functions, such as STDIN and ARGV.

Functions that return a truthy / falsy value depending on whether their arguments satisfy certain conditions are called boolean functions. All built-in boolean functions have an uppercase Q appended to their names (e.g. PrimeQ).

Lists

{elem1; elem2; elem3; ...; elemn}

Lists in Physica are delimited using curly braces: { and }. Consistently with the separator convensions for function arguments, elements of lists are separated by semi-colons.