Stream: contributing

Topic: new builtins


view this post on Zulip Nick Hallstrom (Feb 16 2023 at 01:22):

Is there some sort of process for deciding what new builtins are added? I'd like to add a zip : List a, List b, (a, b -> c) -> List c function if you guys think it would be a good addition.

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 01:30):

Some others I was thinking about would be maxBy : List a, (a -> Num *) -> Result a [ListWasEmpty] and the equivalent minBy

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 01:30):

Oooh just found this :eyes:
https://github.com/roc-lang/roc/issues/664

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 01:33):

Just found that zip already exists and is called map2. I guess this one could probably at least go in the "Different Names" section of the docs

view this post on Zulip Richard Feldman (Feb 16 2023 at 02:59):

great catch - I'd be happy to accept a PR for a "different names" addition!

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 03:13):

What do you think about the maxBy and minBy additions?

view this post on Zulip Ron Panduwana (Feb 16 2023 at 03:51):

Shouldn't it result List a? What if there are ties?

view this post on Zulip Ron Panduwana (Feb 16 2023 at 03:58):

suggestion: would havingMax/havingMin be a better name?

e.g.

players |> List.havingMax score

vs.

players |> List.maxBy score

view this post on Zulip Brendan Hansknecht (Feb 16 2023 at 04:45):

Why would maxBy return a number in the lambda?

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 04:47):

https://www.scala-lang.org/api/2.12.6/scala/collection/TraversableOnce.html#maxBy[B](f:A=%3EB):A

https://www.scala-lang.org/api/2.12.6/scala/collection/TraversableOnce.html#maxBy[B](f:A=%3EB):A

Here’s some examples from other languages I’m familiar with. I think it makes sense to just return the first element if there are ties instead of returning a list. But ya Brendon, if it returned something like [Gt, Lt, Eq] it would be much better.

view this post on Zulip Nick Hallstrom (Feb 16 2023 at 04:50):

So kind of like a combo of List.sortWith and List.first


Last updated: Jul 26 2025 at 12:14 UTC