// Allocation-heavy list code: map, filter, fold, reverse (Perceus reuse // and drop paths). import std/io import std/list fn round :: xs: List -> Int { let doubled = list.map xs fn x { x * 2 } let kept = list.filter doubled fn x { x % 3 != 0 } let back = list.reverse kept use acc, x <- list.fold back 0 acc + x % 7 } fn rounds :: xs: List n: Int acc: Int -> Int { if n == 0 { acc } else { rounds xs (n - 1) (acc + round xs) } } pub fn main :: -> () / { let xs = list.range 1 200000 io.println (show (rounds xs 20 0)) } //> 8000000