# ── Generated by Nexa Transpiler ──────────────────────────────
# This file was auto-generated from a .nexa source file.
# Do not edit directly — regenerate with: nexa compile <file>
# ─────────────────────────────────────────────────────────────
from __future__ import annotations
import asyncio, math, json, os, random, time as _time

# ── Nexa runtime stubs ───────────────────────────────────────
_nexa_modules = {}

print('=== Nexa v5 Showcase ===\n')
print('--- 1. Struct Types ---')
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __repr__(self):
        return f"Point(x={self.x}, y={self.y})"

class Person:
    def __init__(self, name, age, score):
        self.name = name
        self.age = age
        self.score = score
    def __repr__(self):
        return f"Person(name={self.name}, age={self.age}, score={self.score})"

p = Point(1.5, 3.0)
print(f"Point: {p}")
print(f"x={p.x}, y={p.y}")
dist = (((p.x ** 2) + (p.y ** 2)) ** 0.5)
print(f"Distance from origin: {round(dist, 3)}")
alice = Person('Alice', 28, 95.5)
bob = Person('Bob', 32, 88.0)
print(f"Person: {alice}")
print(f"Score difference: {(alice.score - bob.score)}")
print('\n--- 2. Generators ---')
def fibonacci(n):
    """Yield the first n Fibonacci numbers."""
    a = 0
    b = 1
    i = 0
    while (i < n):
        yield a
        temp = (a + b)
        a = b
        b = temp
        i += 1
def range_step(start, stop, step = 1):
    i = start
    while (i < stop):
        yield i
        i += step
fibs = list(fibonacci(10))
print(f"Fibonacci(10): {fibs}")
evens_gen = list(range_step(0, 20, 2))
print(f"range(0,20,2): {evens_gen}")
print('\n--- 3. Docstrings ---')
def euclidean_distance(x1: float, y1: float, x2: float, y2: float) -> float:
    """
    Compute the Euclidean distance between two 2D points.
    Returns the distance as a float.
    """
    return ((((x2 - x1) ** 2) + ((y2 - y1) ** 2)) ** 0.5)
d = euclidean_distance(0, 0, 3, 4)
print(f"Distance (0,0) → (3,4) = {d}")
print('\n--- 4. DataFrame (df module) ---')
data = [{'name': 'Alice', 'dept': 'ML', 'score': 95, 'yrs': 3}, {'name': 'Bob', 'dept': 'NLP', 'score': 88, 'yrs': 5}, {'name': 'Carol', 'dept': 'ML', 'score': 92, 'yrs': 2}, {'name': 'Dave', 'dept': 'Vision', 'score': 79, 'yrs': 4}, {'name': 'Eve', 'dept': 'NLP', 'score': 97, 'yrs': 1}, {'name': 'Frank', 'dept': 'ML', 'score': 85, 'yrs': 6}]
frame = df.create(data)
df.show(frame)
print(f"
Total rows: {df.count(frame)}")
top = df.sort(frame, 'score', ascending=False)
df.show(df.head(top, 3))
stats = df.describe(frame)
print(f"
Describe score: {stats['score']}")
scores_col = df.col(frame, 'score')
print(f"Scores: {scores_col}")
print(f"Mean score: {round((sum(scores_col) / len(scores_col)), 2)}")
df.to_csv(frame, 'team_data.csv')
print('\n--- 5. Listing v5 examples dir ---')
examples = fs.list_dir('nexa_lang/examples')
print(f"Examples: {examples}")
print('\n--- 6. Integration Test ---')
class DataPoint:
    def __init__(self, x, y, label):
        self.x = x
        self.y = y
        self.label = label
    def __repr__(self):
        return f"DataPoint(x={self.x}, y={self.y}, label={self.label})"

def make_points(n):
    i = 0
    while (i < n):
        x = random.float((- 10.0), 10.0)
        y = random.float((- 10.0), 10.0)
        lbl = 'pos'
        if ((x + y) < 0):
            lbl = 'neg'
        yield DataPoint(x, y, lbl)
        i += 1
random.seed(123)
pts = list(make_points(6))
pos_pts = [p for p in pts if (p.label == 'pos')]
neg_pts = [p for p in pts if (p.label == 'neg')]
print(f"Total: {len(pts)}, Positive: {len(pos_pts)}, Negative: {len(neg_pts)}")
xs = [p.x for p in pts]
print(f"X range: [{round(min(xs), 2)}, {round(max(xs), 2)}]")
print('\n✅ All Nexa v5 features verified!')
