Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations
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
Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations