Fargo

From Esolang
Jump to navigation Jump to search

Fargo (Function argument-o) is an esolang created by User:PythonshellDebugwindow.

Overview

Fargo is a functional esolang. Each line is either a function definition, a function call, a blank line, or a comment.

Syntax

Function calls

A function can be called by typing its name followed by a space, then its (space-separated) arguments.

Function definitions

Function definitions are rather unorthodox in Fargo. Each definition takes up exactly one line (excluding comments). The first token of a function definition is its name (redefining an existent function is an error); the rest of the tokens are its arguments and its code. The divide between arguments and code is fairly unusual: the first defined name is the first code token, and the previous token is the final argument. Defined names are built-in functions, user-defined functions (including the function being defined), and the arguments of the function currently being defined.

Functions must contain exactly one outer function call (e.g., myFn x y z otherFn x y z is legal while myFn x y z otherFn x y z anotherFn x and myFn are not).

Colons

If a token begins with a : colon, it either represents a raw function (as opposed to a function call), which can be used as an argument to a function, if it is not a function argument; or marks a function argument as being a raw function, rather than a value.

Literals

Literals are integers matching the regex /[0-9]+/.

Comments

Comments are declared by using #, and last until the end of the line.

Built-in functions

  • < x returns x right-shifted by 1
  • > x returns x left-shifted by 1
  • & x y returns x bitwise-AND y
  • | x y returns x bitwise-OR y
  • ^ x y returns x bitwise-XOR y
  • [] x returns an array with only x in it
  • +[] x y returns the array x concatenated with the array y
  • [?] x y returns the yth element of the array x