Ahoy matey! New treasures await in Maroon v1.1View the Loot

Maroon Documentation

Master the art of pirate programming 🏴‍☠️

New in v1.1

NEW

Loop Enhancements

# While loops with comparisons
while counter be less_than 3 bark counter

# Plunder (forEach) loops
plunder each coin from treasure_chest:
    bark coin
end plunder

# Simple repeat loops
repeat 3 times bark "BOOM!"

Error Handling

brace for impact:
    bark "Attempting dangerous waters"
if capsized, bark "Error, Capsized!"

Advanced List Operations

# Map with inline operations
coins be list of 1, 2, 3 where each times 2

# Filter lists
big_coins be coins where it greater_than 5

# Reduce operation
total be reduce coins with result plus it

Dialects & String Operations

# Custom dialects
dialect Caribbean:
    "shout" be "bark"
    "expedition" be "voyage"
end dialect

# String operations
greeting be "hello world" upper
words be greeting split " "
sentence be words join ", "

Switch Statements

choose x:
    case 1: bark "one"
    case 2: bark "two"
    default: bark "unknown"
end choose

Math and Randomization

roll_dice sails with 20
random_float sails with 10,20
crew be list of 1,2,3,4,5
random_pick sails with crew
random_sample sails with crew, 3
normal_random,
factorial sails with 5
sin sails with 1
cos sails with 2
tan sails with 3
exp sails with 1
log sails with 2
mean sails with list of 1, 2, 3
median sails with list of 1, 2, 3, 1, 2
sum sails with list of 1, 2, 3, 6
flip_coin sails with
roll_multiple sails with 3, 6
              

Quick Start

# Your first Maroon program
treasure be "Ahoy, World!"
bark treasure

# Basic arithmetic
gold be 5
silver be 3
total be gold plus silver
bark total  # Outputs: 8

Variables & Types

  • Numbers (integers & floats)
  • Strings with double quotes
  • Booleans (true/false)
  • Lists

Operators

  • plus, minus, times
  • divided_by, modulo, power
  • equals, greater_than, less_than
  • and, or, not

Built-in Functions

  • bark (print output)
  • count_booty (length)
  • plunder (max value)
  • abandon (min value)

Functions

Function Definition

voyage calculate_treasure(gold, silver):
    total be gold plus silver
    bark "Total treasure:" total
end voyage

calculate_treasure sails with 100, 50

Control Flow

Conditional Statements

treasure be 100

if treasure be greater_than 50, then
    bark "Rich pirate!"
else
    bark "Keep searching!"

# Comparison operators:
# equals, greater_than, less_than
# greater_or_equal, less_or_equal

Working with Lists

# Create a list
loot be list of "gold", "silver", "gems"

# Add to list
add "diamond" to loot

# Access elements
first_item be loot[0]

# List operations
size be count_booty sails with loot
best be plunder sails with loot
worst be abandon sails with loot

Debug Tools

# View current variable state
debug_chest

# Type checking
type_val be type_of sails with treasure
bark type_val  # Outputs: number