Polynomix

From Esolang
Jump to navigation Jump to search

Versions:   1 - 2 - 3 - 4   |   6   |   8

This is still a work in progress. It may be changed in the future.
This is not an esolang!
Only User:I am islptng can modify this page's content (others can still fix errors). If you want to make suggestions, go to the talk page.
Polynomix
Designed by User:I am islptng
Appeared in 2026
Computational class Turing-complete
Reference implementation Unimplemented
Influenced by APL
Haskell
Python
File extension(s) .plx

Polynomix is a powerful computer language designed by User:I am islptng.
It combines polynomials as first-class citizens with APL's array-oriented programming paradigm, Haskell's functional programming paradigm, and Python's dynamic typing.

Data types & TypeString

TypeString is a string that represents the type of a value. It is used to annotate the type of a value in the source code. a TypeString always begin and end with $.
In Polynomix, there are 7 data types:

  • Algebraic Expression is represented by +
    Format of Polynomial. x is represented by ^.
  • Boolean is represented by =
  • Character is represented by "
  • List is represented by [] or [type] if typed
  • Pair is represented by , or l,r if typed
  • Nil is represented by ;
  • Lambda is represented by >

Note that you can use () to group expressions in a TypeString.
Specially, Wildcard is represented by * or {type1|type2|type3|...}

Syntax

Tokens

A valid token consists of alphanumeric characters, underscores, and Unicode characters which codepoint is larger than 128. A valid token does not begin with a digit.

Syntactic symbols

  • \;: Nil constant.
  • (): Expression grouping, and function calls.
  • []: List constructor and accessor.
  • {}: Code block. Can also group expressions and make trains.
  • `': String constructor. Note that strings are list of chars, or $["]$. Can be nested and no escaping sequences.
  • "x: Character constructor.
  • Allowed escaping sequence:
  • "\n for newline
  • "\t for tab
  • "\r for carriage return
  • "\b for backspace
  • "\p for backtick
  • "\q for single quote
  • "\1234 for Unicode character with specified code point.
  • x>y: Lambda expression.
  • x?y: If expression. x?(y z) for if-else.
  • x@y: While loop.
  • x~y: For loop. y should be a lambda expression.
  • x##y: Declare a variable y with initial value x. Evaluates to x.
  • x#y: Assign x to y. Evaluates to x.
  • x,y: Pair constructor.
  • x:y: Try-except block. Tries x, if error occurs, then y is evaluated.
  • x:(y z): Assert and throw. If x is false, raises an error called y

The full list and details is available at Polynomix/Symbols.

Operators (as functions)

Operators are functions that operate on one or more operands. They are defined in the language and can be used in expressions.
In Polynomix, expressions evaluate strictly from left to right, so a+b*c is equivalent to (a+b)*c instead of a+(b*c).

By adding a !, you can make any non-operator thing into a verb(operator), and any operator to a noun.

  • Monadic: x f! for f(x)
  • Dyadic: a f! w for a.f(w)
  • Tryadic+: x f!(a b c d ...) for x.f(a,b,c,d)

Adding a # after the operator means assignment, for example: a +# 1 for a+=1.