# RoadC Advanced Features Demo
# Tests: lists, dicts, for loops, string interpolation, methods

# === Lists ===
let fruits = ["apple", "banana", "cherry"]
print("Fruits:", fruits)
print("First:", fruits[0])
print("Count:", len(fruits))

# List methods
let nums = [3, 1, 4, 1, 5, 9, 2, 6]
print("Sorted:", sorted(nums))
print("Sum:", sum(nums))
print("Min:", min(nums))
print("Max:", max(nums))

# === For loops ===
print("\nSquares 1-5:")
for i in range(1, 6):
    print(i * i)

# For over list
print("\nFruit list:")
for fruit in fruits:
    print("- {fruit}")

# === Dicts ===
let person = {"name": "Alexa", "role": "founder", "level": 99}
print("\nPerson:", person)

# === String methods ===
let msg = "hello blackroad"
print("\nUpper:", msg.upper())
print("Contains 'road':", msg.contains("road"))

# === Nested functions ===
fun make_adder(n):
    fun adder(x):
        return x + n
    return adder

let add5 = make_adder(5)
print("\nadd5(10) =", add5(10))
print("add5(20) =", add5(20))

# === Power operator ===
print("\n2^10 =", 2 ** 10)
print("3^4 =", 3 ** 4)

# === Boolean logic ===
let x = 42
print("\nx == 42 and x > 0:", x == 42 and x > 0)
print("not false:", not false)

# === List comprehension via map ===
let doubles = [2, 4, 6, 8, 10]
print("\nDoubles:", doubles)
print("Reversed:", reversed(doubles))

print("\nAll advanced features working!")
