We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Pseudocode (College Board)

From Esolang
Jump to navigation Jump to search
Pseudocode
Paradigm(s) imperative, procedural
Designed by College Board
Appeared in Before 2018
Type system static
Memory system variable-based
Dimensions one-dimensional
Computational class Turing complete
Reference implementation None

Pseudocode is a programming language designed by College Board for the AP Computer Science Principles course. Pseudocode was created to provide language-agnostic examples and exam questions.

Syntax

Pseudocode has two official representations; textual and block. The formats are presented together on exams and in examples.

Standard functions:

DISPLAY (expr)
INPUT ()
RANDOM (a, b)

DISPLAY is effectively equivalent to the Python code print(expr, end=" "). RANDOM includes both ends.

Assignment is done with

varexpr

expr can be an arithmetic expression containing procedure calls, operators, etc. The arithmetic operators are +, -, *, / (not floor division), MOD (only positive arguments). Comparison operators are =, , >, <, , . Connectives are NOT, AND, OR. Expressions can be parenthesized for precedence.

List literals are [v1, v2, ...] and a list variable l would be indexed like l[i] with the first valid i being 1. Lists can be modified with the functions INSERT (l, i, v) shifts list elements to accomodate an empty position at l[i and sets it to v, APPEND (l, v) extends the list and puts v at the end, REMOVE (l, i) deletes the element l[i] and shifts later elements back, LENGTH (l) returns the length of the list.

Conditionals can be either

IF (expr)
{
   code
}

Or

IF (expr)
{
   code
}
ELSE
{
   code
}

While loops are in the form:

REPEAT UNTIL expr
{
   code
}

With count loops being:

REPEAT n TIMES
{
   code
}

No variable is assigned for count loops.

Loop iteration:

FOR EACH v IN l
{
   code
}

The variable v is assigned to each value of l.

Functions are defined like:

PROCEDURE name (p1, p2, ...)
{
    code
}

Where p1 and so on are the untyped parameter names. code is arbitrary code, which may include the RETURN (expr) statement anywhere, which immediately returns from the function with a value if encountered.

The language also has a turtle system which is used via the commands:

MOVE_FORWARD() // one unit
ROTATE_LEFT() // 90 degrees
ROTATE_RIGHT() // 90 degrees
CAN_MOVE(dir) // left, right, forward, backward

Movement is 1 unit, rotations are 90°, dir can be left, right, forward, or back.

See also

External links