;;;; 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
 ;;  represents infinite repeating series
 (dc <cycle> (<seq>))
 (dg cycle (e|... => <cycle>)))

(dp cycle-elts (<cycle> => <tup>))

(dm cycle (e|... => <cycle>)
  (new <cycle> cycle-elts (as <tup> e)))
 
(dc <cycle-enum> (<enum>))
(dp! %key (<cycle-enum> => <int>) 0)
(dp %len (<cycle-enum> => <int>))
(dp %dat (<cycle-enum> => <cycle>))
(dm enum (x|<cycle> => <cycle-enum>) 
  (new <cycle-enum> %dat x %len (len x)))
(dm fin? (e|<cycle-enum> => <log>)       
  #f)
(dm nxt (e|<cycle-enum> => <cycle-enum>)  
  (renew e %key (mod (+ (%key e) 1) (%len e)) ;; %dat (%dat e)
         ))
(dm now (e|<cycle-enum> => <any>)         
  (elt (cycle-elts (%dat e)) (%key e)))
