PAL

From Esolang
Jump to navigation Jump to search

PAL is an esolang created by islptng. It is designed to have no flow control.

Programs consist of a single expression containing nested function calls, lambdas and literals (numbers and lists), written using Polish (prefix) notation. Each function has a predefined number of arguments, making the notation unambiguous.

This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
This is still a work in progress. It may be changed in the future.

Data types

There are 3 data types.

  • Number, which stores a fraction.
  • List, which stores a list of objects.
  • Lambda, which is a monadic lambda function

Syntax

In this esolang, a program is a single expression. They're written in Polish(Prefix) notation.

Like @ and XENBLN, expressions are made of trees of function calls. Each character represents a function that takes a predefined amount of arguments, which follow directly after it in the code. For example, if command A takes 1 argument, B takes 2, C takes 3, and D and E both take none, then this code

CBADCDBEDEDAE

would be written in many languages like

C(B(A(D()),C(D(),B(E(),D()),E()))),D(),A(E()))

There are exceptions. To define a list, you use []; To define a lambda, you use {}.

There are some special cases in the console.
A line that begins with ] prints the text after it.
A line that begins with } defines macros.

To separate 2 integers, use a space. Otherwise, you won't need any separators.

True is 1, and False is -1 (unlike most languages, which is 0; In this language, however, 0 is truthy).

Implementation

Try it online!

Examples

Hello World

]Hello, world!

XKCD Random Number and Quine

4

Since the whole program is an expression, a single number evaluates to itself, and finally it's printed.

A+B problem

+a b

Replace a and b with your integer since this language has no input!

Factorial

f{i1{*#x0#x1}r1+1x1} 10

Output: 3628800 (10! = 3628800)

FizzBuzz

~{?=0%x5?=0%x3-41228022-8022?=0%x3-4122x}r1 101 1

Since this language is not able to print (only evaluation), the result will be a list.
Like the Mathematics solution, Fizz/Buzz/FizzBuzz are replaced with -4122/-8022/-41228022.

Judge a number is prime or not

f{->x_~{r*x2*xxx}r2+1x1} 87

Output: -1 (87=3*29 not a prime)

f{->x_~{r*x2*xxx}r2+1x1} 97

Output: 1 (97 is a prime)