;;;; Copyright 2002, Jonathan Bachrach.  See file TERMS.

(use goo/boot)
(use goo/fun)
(use goo/class)
(use goo/macros)
(use goo/types)
(use goo/math)
(use goo/cols/col)
(use goo/cols/seq)

(exported
  (dc <zip> (<seq>))
  (dg zip (e|... => <zip>))
  (dg unzip (z|<zip> => <tup>)))

(dp zip-dat (<zip> => <tup>) #())

(dm zip (e|... => <zip>)
  (new <zip> zip-dat (as <tup> e)))

(dm unzip (z|<zip> => <tup>)
  (zip-dat z))

(dc <zip-state> (<any>))

(dp zip-states (<zip-state> => <tup>))

(dc <zip-enum> (<enum>))

(dp! %enums (<zip-enum> => <zip>))

(dm enum (x|<zip> => <zip-enum>)
  (new <zip-enum> %enums (map enum x)))

(dm fin? (e|<zip-enum> => <log>)
  (any? nul? (%enums e)))

(dm nxt (e|<zip-enum> => <zip-enum>)    
  (renew e %enums (map nxt (%enums e))))

(dm now (e|<zip-enum> => <any>)
  (map now (%enums e)))

(dm now-setter (v|<zip> e|<zip-enum>)
  (for ((ve v) (ee (%enums e))) (set (now ee) (now ve))))

(dm now-key (e|<zip-enum> => <zip>)
  (map now-key (%enums e)))
