extend("array")

big = array:filter(
  (n) => n > 10,
  [4,8,15,16,23,42]
)

# Print the result => [15,16,23,42]
slog(big)


myFilter1 = array:filter((n) => n > 10)

# Use myFilter1 on [4,8,15,16,23,42]
result1 = myFilter1([4,8,15,16,23,42])
slog(result1)  # prints [15, 16, 23, 42]

# Re-use the same partial filter on [2,12,9,100]
result2 = myFilter1([2, 12, 9, 100])
slog(result2)  # prints [12, 100]


# 3) Partial usage with underscore in the predicate:
#    ( _ ) => true => "We don't care about the input, always return true."
myFilter2 = array:filter((_) => true)

# Now apply it to an array => everything passes the filter.
resultAll = myFilter2([4,8,15,16,23,42])
# Prints [4,8,15,16,23,42]
slog(resultAll)

# 4) Partial usage with underscore for the FIRST parameter (missing the predicate).
#    We do supply the array now ([4,8,15,16,23,42]).
myFilter3 = array:filter(_, [4,8,15,16,23,42])

# Later, we call that partial with the actual predicate => (n) => n>10
resultPartial = myFilter3((n) => n > 10)

# This prints [15, 16, 23, 42]
slog(resultPartial)
