Tin

Examples · learn/09-closures · 151 of 339

pipe

examples/learn/09-closures/pipe.tintin run examples/learn/09-closures/pipe.tin
fn main() {
  let orders = [12, 250, 40, 8, 99]

  // x |> f(y) means f(x, y). Read it top to bottom, like a recipe.
  let bigTotal = orders
    |> filter((n) => n >= 40)
    |> map((n) => n * 2)
    |> sum()
  print(bigTotal)

  // the same thing, nested inside out:
  print(sum(map(filter(orders, (n) => n >= 40), (n) => n * 2)))
}