A Groovy snippet to get first n elements from a list.

def a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
a.take(3)  // [1, 2, 3]