Master the art of pirate programming 🏴☠️
# 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
# 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
# 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 functionality
import map
import treasure_utils
# Use imported functions
find_treasure sails with
chart_course sails with "Tortuga"
# 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
# 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
voyage calculate_treasure(gold, silver):
total be gold plus silver
bark "Total treasure:" total
end voyage
calculate_treasure sails with 100, 50
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
# 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
# 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
# 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
# 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
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
# 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
# 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, " & "