roc icon indicating copy to clipboard operation
roc copied to clipboard

Add `List.iterate` symbol

Open cjduncana opened this issue 3 years ago • 5 comments

cjduncana avatar Oct 12 '22 03:10 cjduncana

Hm, I don't think we actually want to expose List.iterate 😅

Or at least that's how I remember the design discussion!

rtfeldman avatar Oct 15 '22 21:10 rtfeldman

That's disappointing to hear. I used it to solve one of the Advent of Code problems by exiting the loop early when a card reached bingo. I can implement the same with List.walk and skip the rest of the loop or with a recursive function.

Let me know whether to close this PR.

cjduncana avatar Oct 15 '22 23:10 cjduncana

Will the documentation still show iterate if it is not meant to be used?

cjduncana avatar Oct 15 '22 23:10 cjduncana

Oh, walkUntil is supposed to be for that! 😅

I'm not sure why walkUntil is not exposed but iterate is; it should be the other way around.

rtfeldman avatar Oct 16 '22 20:10 rtfeldman

Oh and also walkBackwardsUntil should be exposed too!

rtfeldman avatar Oct 16 '22 21:10 rtfeldman

I removed List.iterate from the exported functions, so it no longer appears in the documentation. We should probably think about how we want to document the API exposed outside the library and the API exposed internally across the library.

In this case, we had a function (List.iterate) that we wanted to use internally in the Roc Standard Library, but we didn't want to expose it outside the library, so how can we support these two use cases?

cjduncana avatar Oct 23 '22 14:10 cjduncana

Since I touched the Dict.contains definition to remove the use of List.iterate, I added some documentation and tests to it. Screen Shot 2022-10-23 at 6 33 23 PM

cjduncana avatar Oct 23 '22 22:10 cjduncana