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.
Some others I was thinking about would be maxBy : List a, (a -> Num *) -> Result a [ListWasEmpty]
and the equivalent minBy
Oooh just found this :eyes:
https://github.com/roc-lang/roc/issues/664
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
great catch - I'd be happy to accept a PR for a "different names" addition!
What do you think about the maxBy
and minBy
additions?
Shouldn't it result List a
? What if there are ties?
suggestion: would havingMax
/havingMin
be a better name?
e.g.
players |> List.havingMax score
vs.
players |> List.maxBy score
Why would maxBy return a number in the lambda?
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.
So kind of like a combo of List.sortWith
and List.first
Last updated: Jul 26 2025 at 12:14 UTC