Aye Aye! New treasure arrived in Update v1.2.1 - The Captain's ReshuffleView the Booty

Maroon Documentation

Master the art of pirate programming 🏴‍☠️

New in v1.2

NEW

Default Parameters & Functions

# Functions with default values
voyage sail_to(destination, speed be 10):
    bark "Sailing to", destination, 
         "at", speed, "knots!"
end voyage

sail_to sails with "Tortuga"
sail_to sails with "Havana", 15

List Operations

# Map, Filter, Reduce operations
numbers be list of 1, 2, 3, 4, 5
doubled be map sails with numbers, "double"
evens be filter sails with numbers, "is_even"

# New list features
shuffled be shuffle sails with original
weighted be weighted_choice sails with 
  options, weights

String Operations

# New string operations
bark shout sails with "ahoy matey!"

# Split strings
treasure_str be "gold,silver,gems"
loot be split_loot sails with 
  treasure_str, ","

# Join strings
crew be list of "Jack", "Anne", "Mary"
bark join_crew sails with crew, " & "

Import & Modularity

# Import functionality
import map
import treasure_utils

# Use imported functions
find_treasure sails with
chart_course sails with "Tortuga"

Enhanced Features

# Fixed parser issues
random_sample sails with crew, 2
random_float sails with 1, 10
flip_coin sails with

# Parentheses support
result be (5 plus 3) times 2

# First mate now inactive by default
revive_first_mate  # To enable

# Fixed plunder loop
plunder each sailor from crew:
    bark "Welcome aboard", sailor
end plunder

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

Help

  • Help on every inbuilt function with usage

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)

Type Checking

  • check_type
  • assert_type
  • is_list_of_type

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 & Type System

# View current variable state
debug_chest

# Type checking and conversion
type_val be type_of sails with treasure
to_int sails with "42"
to_float sails with "3.14"
to_str sails with 123

Advanced Math Operations

# Basic Math
result be (5 plus 3) times 2
power_val be 2 power 3
sqrt sails with 16
abs sails with -42
round sails with 3.7

# Trigonometry & Complex Math
sin sails with 1
cos sails with 2
tan sails with 3
exp sails with 1
log sails with 2
factorial sails with 5

# Comparisons & Logic
result be x greater_or_equal y
result be x less_or_equal y
result be not (x equals y)
condition be a and b
condition be a or b

Advanced List Operations

# Statistical Operations
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

# Pattern Operations
coins be list of 1, 2, 3 where each times 2
big_coins be coins where it greater_than 5

# List Transformations
double_values be map sails with numbers, "double"
even_numbers be filter sails with numbers, "is_even"
total be reduce numbers with result plus it

# Random Operations
shuffled be shuffle sails with crew
sample be random_sample sails with crew, 3
chosen be random_pick sails with options
weighted be weighted_choice sails with 
  options, weights

Error Handling & Flow Control

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

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

# Loop Control
while counter be less_than 3:
    bark counter
end while

plunder each coin from treasure_chest:
    bark coin
end plunder

repeat 3 times:
    bark "BOOM!"
end repeat

Random Operations

# Basic Random
roll_dice sails with 20
flip_coin sails with
random_float sails with 10,20
random_pick sails with crew

# Advanced Random
roll_multiple sails with 3, 6
normal_random sails with 0, 1
random_sample sails with crew, 3

Dialects & String Operations

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

# String Operations
text be shout sails with "hello"
parts be split_loot sails with "a,b,c", ","
result be join_crew sails with crew, " & "