Examples

Complete working programs that demonstrate BrainRot Lang features. These are actual working test scripts transcribed from the core compiler repository.

Hello World

Variables and printing. Getting the absolute basics down. fr_fr

hello.brt
let_him_cook main() { trust_me_bro name = "Walter White" trust_me_bro age = 52 trust_me_bro alive = fr_fr say_my_name("my name is " + name) }

Conditionals

A simple grade evaluator that shows how to chain multiple logical checks utilizing BrainRot slang.

ifelse.brt
let_him_cook main() { trust_me_bro score = 85 chat_is_this_real (score >= 90) { say_my_name("S tier no cap W rizz") } wait_hold_up (score >= 75) { say_my_name("pretty mid ngl but you tried") } wait_hold_up (score >= 60) { say_my_name("sus ahh score fr") } nah_bro { say_my_name("massive L ratio bro ur cooked") } }

Loops

Starting the grand hustle with a classic for-loop structure. Keep grinding.

for.brt
let_him_cook main() { say_my_name("starting the grind fr fr") run_it_back (trust_me_bro i = 0; i < 5; i += 1) { say_my_name("done " + i) } say_my_name("grind complete W") }

Fibonacci

Classic recursive Fibonacci sequence using let_him_cook and take_this.

fibonacci.brt
let_him_cook fib(n) { chat_is_this_real (n <= 1) { take_this n } take_this fib(n - 1) + fib(n - 2) } let_him_cook main() { say_my_name("Fibonacci sequence:") run_it_back (trust_me_bro i = 0; i < 10; i += 1) { say_my_name(fib(i)) } }

FizzBuzz

The canonical interview problem, BrainRot style.

fizzbuzz.brt
let_him_cook main() { run_it_back (trust_me_bro i = 1; i <= 30; i += 1) { chat_is_this_real (i % 15 == 0) { say_my_name("FizzBuzz") } wait_hold_up (i % 3 == 0) { say_my_name("Fizz") } wait_hold_up (i % 5 == 0) { say_my_name("Buzz") } nah_bro { say_my_name(i) } } }

Closures

BrainRot functions capture their definition-time environment (closure). Here a counter factory returns a function that closes over a private count variable.

closures.brt
let_him_cook make_counter() { trust_me_bro count = 0 let_him_cook increment() { count += 1 take_this count } take_this increment } let_him_cook main() { trust_me_bro counter = make_counter() say_my_name(counter()) # 1 say_my_name(counter()) # 2 say_my_name(counter()) # 3 }

Array Operations

Pass arrays to functions and iterate with run_it_back.

arrays.brt
let_him_cook sum(arr, len) { trust_me_bro total = 0 run_it_back (trust_me_bro i = 0; i < len; i += 1) { total += arr[i] } take_this total } let_him_cook main() { trust_me_bro nums = [10, 20, 30, 40, 50] trust_me_bro result = sum(nums, 5) say_my_name(result) # 150 }