package extras

/**
 *  Composition and currying can lead to many useful closure definitions
 *    that can be combined in countless ways to produce problem solutions.
 */

def zip = { list1, list2 ->
    def res = []
    def size = (list1.size() < list2.size()) ? list1.size() : list2.size()
    for(k in 0..<size) {
        res << [list1[k], list2[k]]
    }
    return res
}

def odds = [1, 3, 5, 7]
def evens = [2, 4, 6, 8]

println "zip: ${zip(odds, evens)}"

