# Dot Notation Showcase
# Demonstrates field access with dot notation
print("╔════════════════════════════════════════════╗")
print("║ Dot Notation Feature Showcase ║")
print("╚════════════════════════════════════════════╝")
print("")
# ═══ Simple Record Access ═══
print("🔹 Simple Field Access:")
person = {
name: "Alice",
age: 30,
email: "alice@example.com"
}
print(" Name: " + person.name)
print(" Age: " + person.age)
print(" Email: " + person.email)
print("")
# ═══ Nested Records ═══
print("🔹 Nested Records:")
company = {
name: "TechCorp",
location: {
city: "San Francisco",
state: "CA",
country: "USA"
},
employees: 150
}
print(" Company: " + company.name)
print(" City: " + company.location.city)
print(" State: " + company.location.state)
print(" Employees: " + company.employees)
print("")
# ═══ Records in Arrays ═══
print("🔹 Accessing Records in Arrays:")
users = [
{name: "Bob", score: 95},
{name: "Carol", score: 87},
{name: "Dave", score: 92}
]
# Extract fields from array elements
user_names = users | map(fn(u) => u.name)
user_scores = users | map(fn(u) => u.score)
print(" Names: ")
print(user_names)
print(" Scores: ")
print(user_scores)
print("")
# ═══ Dot Notation in Pipelines ═══
print("🔹 Dot Notation in Pipelines:")
products = [
{name: "Laptop", price: 999, inStock: true},
{name: "Mouse", price: 25, inStock: true},
{name: "Keyboard", price: 75, inStock: false}
]
available = products | where(fn(p) => p.inStock == true)
print(" Available products:")
names = available | map(fn(p) => p.name)
print(names)
print("")
# ═══ Computing with Fields ═══
print("🔹 Computing with Fields:")
prices = products | map(fn(p) => p.price)
total = prices | reduce(fn(a,b) => a + b, 0)
print(" Total value: $" + total)
print("")
# ═══ Type Introspection ═══
print("🔹 Type Introspection with Fields:")
data = {
numbers: [1, 2, 3],
text: "hello",
flag: true
}
print(" Type of numbers: " + type_of(data.numbers))
print(" Type of text: " + type_of(data.text))
print(" Type of flag: " + type_of(data.flag))
print(" Length of numbers: " + len(data.numbers))
print(" Length of text: " + len(data.text))
print("")
# ═══ File System Example ═══
print("🔹 Real-World Example - File Listing:")
files = ls(".")
regular_files = files | where(fn(f) => f.is_dir == false)
file_count = len(regular_files)
print(" Total files: " + file_count)
# Get file names using dot notation in map
file_names = regular_files | map(fn(f) => f.name) | take(5)
print(" First 5 files:")
print(file_names)
print("")
print("╔════════════════════════════════════════════╗")
print("║ ✅ Dot Notation Fully Functional! ✅ ║")
print("╚════════════════════════════════════════════╝")