def packAddr(symbolic) { packd = 0 symbolic.split(/\./).eachWithIndex { b, i -> packd |= (b as Long) << (8*(3-i)) } return packd } def packIP(symbolic) { i = 0 symbolic.split(/\./).inject(0) { p, b -> p |= (b as Long) << (8*(3-(i++))) } } def packIt(symbolic) { symbolic.split(/\./)*.toLong().inject([p:0,i:0]) { m, b -> [p: m.p |= b << (8*(3-m.i++)), i: m.i] }.p } def unpackIt(packed) { (0..3).collect(new ArrayList()) { i -> packed >>> (8*(3-i)) & 255 }.join('.') } def addr = '198.50.24.68' def pckd = 3325171780 println packIt(addr) println unpackIt(pckd) [addr.split(/\./),[24,16,8,0]].transpose().collect(new HashSet()) { m -> (m[0]as Long) << m[1] }.sum()