groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8733) Groovy could provide a chop DGM method
Date Wed, 08 Aug 2018 14:25:00 GMT

     [ https://issues.apache.org/jira/browse/GROOVY-8733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Paul King updated GROOVY-8733:
------------------------------
    Description: 
The method would chop the list into pieces at a specified chop size (or chop sizes).
{code}
assert [1, 2, 3, 4].chop(1) == [[1]]
assert [1, 2, 3, 4].chop(1,-1) == [[1], [2, 3, 4]]
assert ('a'..'h').chop(2, 4) == [['a', 'b'], ['c', 'd', 'e', 'f']]
assert ['a', 'b', 'c', 'd', 'e'].chop(3) == [['a', 'b', 'c']]
assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3) == [['a'], ['b', 'c'], ['d', 'e']]
assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3, 3, 3) == [['a'], ['b', 'c'], ['d', 'e'], [],
[]]
{code}



  was:
The method would chop the list into pieces at a specified chop size (or chop sizes).
{{assert [1, 2, 3, 4].chop(1) == [[1], [2, 3, 4]]}}
{{assert ('a'..'h').chop(2, 4) == [['a', 'b'], ['c', 'd', 'e', 'f'], ['g', 'h']]}}
{{assert ['a', 'b', 'c', 'd', 'e'].chop(3) == [['a', 'b', 'c'], ['d', 'e']]}}
{{assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 5) == [['a'], ['b', 'c'], ['d', 'e']]}}
{{assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 5, 3) == [['a'], ['b', 'c'], ['d', 'e'], []]}}



> Groovy could provide a chop DGM method
> --------------------------------------
>
>                 Key: GROOVY-8733
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8733
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Priority: Major
>
> The method would chop the list into pieces at a specified chop size (or chop sizes).
> {code}
> assert [1, 2, 3, 4].chop(1) == [[1]]
> assert [1, 2, 3, 4].chop(1,-1) == [[1], [2, 3, 4]]
> assert ('a'..'h').chop(2, 4) == [['a', 'b'], ['c', 'd', 'e', 'f']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(3) == [['a', 'b', 'c']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3) == [['a'], ['b', 'c'], ['d', 'e']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3, 3, 3) == [['a'], ['b', 'c'], ['d', 'e'],
[], []]
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message