Quick Navigation #

  • Functions - Built-in functions for I/O, iteration, and data transformation
  • Types - Built-in data types (Int, String, Bool, Any)
  • Operators - Arithmetic, comparison, and logical operators
  • Keywords - Language keywords (fn, let, type, match, import)

Function Reference #

Function Description
filter Filters elements in an iterator based on a predicate function.
fold Reduces an iterator to a single value using an accumulator function.
forEach Applies a function to each element in an iterator.
input Reads an integer from the user’s input.
map Transforms each element in an iterator using a function, returning a new iterator.
print Prints a value to the console. Automatically converts the value to a string representation.
range Creates an iterator that generates numbers from start to end (exclusive).
toString Converts a value to its string representation.

Type Reference #

Type Description
Any A type that can represent any value. Useful for generic programming but should be used carefully as it bypasses type checking.
Bool A boolean type that can be either true or false. Used for logical operations and conditionals.
Int A 64-bit signed integer type. Can represent whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
String A sequence of characters representing text. Supports string interpolation and escape sequences.

Operator Reference #

Operator Name Description
!= Inequality Compares two values for inequality.
% Modulo Returns the remainder of dividing the first number by the second.
* Multiplication Multiplies two numbers.
+ Addition Adds two numbers together.
- Subtraction Subtracts the second number from the first.
/ Division Divides the first number by the second.
< Less Than Checks if the first value is less than the second.
<= Less Than or Equal Checks if the first value is less than or equal to the second.
== Equality Compares two values for equality.
> Greater Than Checks if the first value is greater than the second.
>= Greater Than or Equal Checks if the first value is greater than or equal to the second.
[ >](operators/pipe-operator/) Pipe Operator

Keyword Reference #

Keyword Description
false Boolean literal representing the logical value false.
fn Function declaration keyword. Used to define functions with parameters and return types.
import Import declaration keyword. Used to bring modules and their exports into the current scope.
let Variable declaration keyword. Used to bind values to identifiers. Variables are immutable by default in Osprey.
match Pattern matching expression. Used for destructuring values and control flow based on patterns.
true Boolean literal representing the logical value true.
type Type declaration keyword. Used to define custom types and type aliases.