Zippy Triples with Groovy and Mango

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

Tagged code, mango, java, ranges, iterators, and fp


Jez Higgins

Freelance software grandad
software created
extended or repaired


Jez Higgins

Freelance software grandad
software created
extended or repaired


Jez Higgins

Freelance software grandad
software created
extended or repaired



Jez Higgins

Freelance software grandad
software created
extended or repaired


Jez Higgins

Freelance software grandad
software created
extended or repaired


Jez Higgins

Freelance software grandad
software created
extended or repaired