Stream: contributing

Topic: List.walk variants


view this post on Zulip Kiryl Dziamura (Jan 30 2024 at 10:10):

Created a ticket for absent List.walk variants

The number of combinations looks ridiculous (8 out of 16 are implemented). Does it make sense to combine at least from, until, fromUntil into a single fromUntil? It would reduce the number of variants by 8

If to use the same type as in List.range for the config, it would be possible to eliminate forward/backward difference, so start and end would affect the iteration direction. So it's 2 variants less, leaving only 6 of them:

view this post on Zulip mkrieger1 (Feb 15 2024 at 17:06):

I already tripped over this while doing AoC. It baffles me that in a functional language these orthogonal concepts, "with index", "backwards", "until" are not easily composable but need dedicated functions for each combination.

view this post on Zulip Richard Feldman (Feb 15 2024 at 17:37):

walkRange isn't necessary anymore thanks to seamless slices, and once we have deforestation/fusion we can replace the others with just |> List.reverse for backwards and |> List.withIndex for "with index"

view this post on Zulip Richard Feldman (Feb 15 2024 at 17:38):

you can already do it today using composition, but the performance cost is very high because it requires copying the entire list

view this post on Zulip Richard Feldman (Feb 15 2024 at 17:38):

so if we didn't expose some of these primitives (range is obsolete and we can get rid of those anytime), then today there would be no option but to pay that performance cost


Last updated: Jul 06 2025 at 12:14 UTC