package extras

/**
 *  Selectively, find the sum of all the elements in a list. The list
 *    comprises sub-lists of length two. All the values in these sub-lists
 *    are summed provided the two values are in order.
 */

import fp.*

def map = Functor.map
def zip = Functor.zip

def flat = { list -> return list.flatten() }

def l1 = [1, 2, 3]
def l2 = [4, 5, 6]
def l3 = [7, 8, 9]

def zip3 = { list1, list2, list3 ->
	return map(flat, zip(zip(list1, list2), list3))
}
def res = zip3(l1, l2, l3)
println "res: ${res}"
