Friday 21 May, 2010
#
Here's a Groovy version of the Java code below. It's more or less identical to the Python original.
import uk.co.jezuk.mango.Iterators
def prev_this_next(items) {
chain = Iterators.ChainIterator(null, items, null)
(prev, current, next) = Iterators.TeeIterator(chain, 3)
current.next()
next.next()
next.next()
return Iterators.ZipIterator(prev, current, next)
}
long_weekend = ["Friday", "Saturday", "Sunday", "Monday"]
yesterday_today_tomorrow = prev_this_next(long_weekend)
for(ytt in yesterday_today_tomorrow)
println ytt
Zippy, fruity, groovy ... YEAH!
[Add a comment]