User:Leland McInnes/Pseudocode examples

The following represent some suggested examples of pseudocode in the style suggested by WikiProject Computer science/Manual of style (computer science) for various idiomatic constructs. This does not represent an authoritative source, nor rules, nor even guidelines for how to express these constructs in pseudocode on Wikipedia. Rather it offers suggestions for possible methods of expression consistent with the standard style for those who are uncertain as to how to proceed.

type type_name is description
 * Datatype declaration
 * where "description" is any reasonable description of the type, such as Integer, Non-negative number, Array of graph nodes etc.

type color is red | green | blue
 * Algebraic datatype declaration

variable_name : type_name
 * Typed variable declaration

function function_name | pattern1 is code block ...   | patternn is code block end function
 * Pattern matched function

class class_name is property property1 property property2 ...    method method1 is code block end method method method2 is code block end method ... end class
 * Class declaration
 * where property and method keywords are any reasonable keyword such as attribute, variable, etc. and operation, <tt>procedure</tt>, etc.