Groovy web console

subscribe to the feed Subscribe
to this
site
Content (via #groovywebconsole)
tweet this snippet Tweet
this
script

Content

Published 3 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def contents = [[null], [null], [1,2,3,5], [11,12,32], [], [null], [null]]
def h = []
def reachedCount = false
contents.each { n ->  
    n.removeAll([null])
    if (n.size() >= 5 && !reachedCount) {
        h.add(n)
        reachedCount = true
    } else {
        if (!reachedCount && h.size() < 20) {
            h.add(n)
        } else {
            reachedCount = true   
        }
    }
}

println "" + h.flatten().unique()