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 05:29: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 at a specified index (or multiple index values).
{{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'], []]}}


  was:
The method would chop the list at a specified index (or multiple index values).
{{assert [[1], [2, 3, 4]] == [1, 2, 3, 4].chop(1)}}
{{assert [['a', 'b'], ['c', 'd', 'e', 'f'], ['g', 'h']] == ('a'..'h').chop(2, 4)}}
{{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 at a specified index (or multiple index values).
> {{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'],
[]]}}



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

Mime
View raw message