' --- Example for SELECT and FILTER with Lambdas ---

MyNumbers = IOTA(10)
PRINT "Original Array: "; FRMV$(MyNumbers)
PRINT

' Use SELECT with a lambda to transform every element
SquaredNumbers = SELECT(lambda x -> x * x, MyNumbers)
PRINT "After SELECT with lambda: "; FRMV$(SquaredNumbers)
PRINT

' Use FILTER with a lambda to keep only the even numbers
EvenNumbers = FILTER(lambda n -> (n MOD 2) = 0, MyNumbers)
PRINT "After FILTER with lambda: "; FRMV$(EvenNumbers)
PRINT

' Chain the operations together with lambdas!
result_nested = SELECT(lambda v -> v * 10, FILTER(lambda val -> val > 5, SELECT(lambda i -> i + 1, MyNumbers)))
PRINT "Chained lambda result: "; result_nested

' Expected Output:
' Original Array:           1 2 3 4 5 6 7 8 9 10
'
' After SELECT with lambda: 1 4 9 16 25 36 49 64 81 100
'
' After FILTER with lambda: 2 4 6 8 10
'
' Chained lambda result:    60 70 80 90 100 110