POP-11

Paradigm:
Typing discipline:
Versions and implementations (Collapse all | Expand all):
Programming language

POP-11 is an incrementally compiled programming language.

POP-11 is used mostly for research in artificial intelligence and teaching symbolic programming techniques.

Examples:

Hello, World!:

Example for versions Poplog 15.5 (POP-11)

=> is output operator.

'Hello, World!' =>

Factorial:

Example for versions Poplog 15.5 (POP-11)

This example uses recursive factorial definition. factorial(n) calculates the actual value of factorial, while loop(n) is used to loop through factorials of numbers between 0 and n, inclusive. >< is concatenation operator. Note that loop doesn’t return a value.

Alternatively, one could save function definitions to file fact.p, place it in Poplog working folder, and enter load fact.p in interactive mode to upload the contents of file.

define factorial(n);
    if n == 0 
        then 1
        else n * factorial(n - 1)
    endif
enddefine;

define loop(n);
    if n>0 
        then loop(n-1)
    endif;
    n >< '! = ' >< factorial(n) =>
enddefine;

loop(16) =>

Fibonacci numbers:

Example for versions Poplog 15.5 (POP-11)

This example uses recursive definition of Fibonacci numbers and works in the same way as factorial example, except for that loop returns a string which contains a concatenation of all Fibonacci numbers up to n-th.

define fibonacci(n);
    if n < 3 
        then 1
        else fibonacci(n - 1) + fibonacci(n - 2)
    endif
enddefine;

define loop(n);
    if n>1 
        then loop(n-1) >< ', ' >< fibonacci(n)
        else fibonacci(n)
    endif;
enddefine;

loop(16) >< ', ...' =>