Stream: roctoberfest

Topic: 2023 day 3


view this post on Zulip Fabian Schmalzried (Oct 03 2023 at 17:25):

It definetly needs more cleanup: https://gist.github.com/FabHof/d65eab72dceca521642e90f8e5dd5ad7
But I did find a bug with dbg: https://github.com/roc-lang/roc/issues/5883

view this post on Zulip Elias Mulhall (Oct 03 2023 at 18:39):

https://github.com/mulias/roctoberfest/blob/main/advent_2022/day_03/main.roc

view this post on Zulip Isaac Van Doren (Oct 04 2023 at 01:28):

Yes, partition would be great

view this post on Zulip Brendan Hansknecht (Oct 04 2023 at 01:59):

What is partition in this case? Like what does the function do?

view this post on Zulip Isaac Van Doren (Oct 04 2023 at 02:01):

What I would expect is that it would break the input list into chunks of size n. With the last chunk potentially containing less than n elements.

view this post on Zulip Elias Mulhall (Oct 04 2023 at 02:03):

Here's what I did

partition : List a, Nat -> List (List a)
partition = \lst, idx ->
    { before, others } = List.split lst idx
    if List.isEmpty others then
        [before]
    else
        List.prepend (partition others idx) before

expect partition [1, 2, 3, 4, 5, 6, 7, 8] 3 == [[1, 2, 3], [4, 5, 6], [7, 8]]

view this post on Zulip Brendan Hansknecht (Oct 04 2023 at 02:03):

Ah, that form of partition.

view this post on Zulip Brendan Hansknecht (Oct 04 2023 at 02:04):

I wonder if there is a better name for it.

view this post on Zulip Elias Mulhall (Oct 04 2023 at 02:04):

Yes, not sorting partition. Uhhhh, chunk?

view this post on Zulip Isaac Van Doren (Oct 04 2023 at 02:05):

Or possibly chunksOf

view this post on Zulip Isaac Van Doren (Oct 04 2023 at 02:06):

Personally partition is what I would think of first if I was searching for it

view this post on Zulip Elias Mulhall (Oct 04 2023 at 02:08):

I think Brendan is right that partition is overloaded, since partitioning in half/around a pivot point is a common operation in sorting.

view this post on Zulip Anton (Oct 04 2023 at 09:39):

In the haskell split package this is called chunksOf, that seems like a great name.

view this post on Zulip Anton (Oct 04 2023 at 09:45):

List.sum tripped me up, I waned to sum up a list of U8s into an U64 but got a type error.

I think making that work could be very complicated

view this post on Zulip Elias Mulhall (Oct 04 2023 at 16:04):

Anton said:

I think making that work could be very complicated

sure sure. It wasn't a particularly constructive comment, mostly that I'm not used to a functional language caring so much about number encodings.

view this post on Zulip Brendan Hansknecht (Oct 04 2023 at 23:37):

I think we should look at adding automatic upcasting. If integer and the same sign with more bits, just automatically convert. This could be done automatically during the underlying list walk that sum should be calling. That will also be more performance than making the entire list first

view this post on Zulip Anton (Oct 06 2023 at 08:59):

Interesting!


Last updated: Jul 06 2025 at 12:14 UTC