I'm looking through rocci bird updates (to the new compiler), and wow...the gap between this original function and the new one is really dramatic!
original function:
startingPlants : Task (List Plant) []
startingPlants =
List.range { start: At 0, end: At 14 }
|> List.walk (Task.ok (List.withCapacity 20)) \task, i ->
plant <- randomPlant (i * 12) |> Task.await
current <- task |> Task.await
current
|> List.append plant
|> Task.ok
new one:
starting_plants! : () => List(Plant)
starting_plants! = || {
0.to(15).map!(|i| random_plant!(i * 12)).collect()
}
(related: I have now found a motivating use case for map! :joy:)
also this will be faster at runtime because it's not instantiating a list at runtime like the old one (since 0.to(15) returns an Iter, not a List) - not to mention no Task data structures
So much clearer too
Last updated: Jun 16 2026 at 16:19 UTC