Learn REBOL-RED with Real Code Examples
Updated Nov 21, 2025
Code Sample Descriptions
1
REBOL / Red Counter and Theme Toggle
count: 0
isDark: false
updateUI: func [] [
print rejoin ["Counter: " count]
print rejoin ["Theme: " either isDark ["Dark"] ["Light"]]
]
increment: func [] [
count: count + 1
updateUI/()
]
decrement: func [] [
count: count - 1
updateUI/()
]
reset: func [] [
count: 0
updateUI/()
]
toggleTheme: func [] [
isDark: not isDark
updateUI/()
]
; Simulate actions
updateUI/()
increment/()
increment/()
toggleTheme/()
decrement/()
reset/()
Demonstrates a simple counter with theme toggling using REBOL/Red variables and functions.
2
REBOL / Red Random Number Generator
foreach i [1 2 3] [
num: random 100 + 1
print rejoin ["Random " i ": " num]
]
Generates random numbers between 1 and 100 and prints them.
3
REBOL / Red Todo List
todos: copy []
addTask: func [task] [
append todos task
print todos
]
removeTask: func [index] [
remove todos index
print todos
]
; Simulate actions
addTask "Buy milk"
addTask "Write REBOL code"
removeTask 1
Maintains a simple todo list with add and remove functionality.
4
REBOL / Red Dice Roller
foreach i [1 2 3] [
roll: random 6 + 1
print rejoin ["Roll " i ": " roll]
]
Rolls a six-sided dice three times.
5
REBOL / Red Countdown Timer
count: 5
while [count >= 0] [
print rejoin ["Countdown: " count]
count: count - 1
]
print "Done!"
Counts down from 5 to 0.
6
REBOL / Red Prime Checker
isPrime: func [n] [
if n < 2 [return false]
foreach i 2 n-1 [
if n // i = 0 [return false]
]
return true
]
nums: [7 10 13]
foreach n nums [
print rejoin [n " is " either isPrime n ["Prime"] ["Not Prime"]]
]
Checks if numbers are prime.
7
REBOL / Red Temperature Converter
cToF: func [c] [c * 9 / 5 + 32]
fToC: func [f] [(f - 32) * 5 / 9]
print rejoin ["25°C = " cToF 25 ":F"]
print rejoin ["77°F = " fToC 77 ":C"]
Converts Celsius to Fahrenheit and Fahrenheit to Celsius.
8
REBOL / Red Shopping Cart
cart: copy []
prices: copy []
addItem: func [item price] [
append cart item
append prices price
print rejoin ["Cart: " cart]
print rejoin ["Total: " sum prices]
]
removeItem: func [index] [
remove cart index
remove prices index
print rejoin ["Cart: " cart]
print rejoin ["Total: " sum prices]
]
; Simulate actions
addItem "Apple" 2
addItem "Banana" 3
removeItem 1
Adds and removes items in a shopping cart with total cost.
9
REBOL / Red Name Greeting
greet: func [name] [print rejoin ["Hello, " name "! Welcome!"]]
greet "Saurav"
greet "Alice"
greet "Bob"
Greets users by name.
10
REBOL / Red Stopwatch
time: 0
while [time < 5] [
print rejoin ["Stopwatch: " time " seconds"]
time: time + 1
]
print "Done!"
Simulates a stopwatch incrementing seconds.