[ 
https://issues.apache.org/jira/browse/GROOVY-11654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949702#comment-17949702
 ] 

ASF GitHub Bot commented on GROOVY-11654:
-----------------------------------------

paulk-asert opened a new pull request, #2214:
URL: https://github.com/apache/groovy/pull/2214

   (no comment)




> Create AGM#putAt variants
> -------------------------
>
>                 Key: GROOVY-11654
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11654
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> When creating potential examples for the Groovy 5 release notes, I created 
> this example:
> {code:groovy}
> // keep top 5 scores in top array
> int[] scores = [56, 82, 70, 74, 63, 92, 49, 69, 85, 79, 80, 82, 99, 95]
> int[] top = scores[0..4].sort()
> scores[5..-1].each { next ->
>     def ins = top.partitionPoint{ it < next } - 1
>     if (ins > 0) {
>         System.arraycopy(top, 1, top, 0, ins)
>         // top[0..<ins] = top[1..ins]
>     }
>     if (ins >= 0) {
>         top[ins] = next
>     }
> }
> assert top == [82, 85, 92, 95, 99]
> {code}
> The {{System.arraycopy()}} line would be {{top[0..<ins] = top[1..ins]}} if 
> using lists. It would be nice if arrays supported putAt and that line didn't 
> need to change.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to