Re: using a zip as a sequence?
Jonathan Bachrach <[email protected]> Wed, 26 Oct 2005 17:00:19 -0400
| Newsgroups | gmane.comp.lang.goo.general |
|---|---|
| Message-ID | <[email protected]> |
this is a bug and while debugging it i found other problems with zip.
here's the new zip.goo file that should fix it. let me know.
(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> => <tup>))
(dm enum (x|<zip> => <zip-enum>)
(new <zip-enum> %enums (map enum (zip-dat x))))
(dm fin? (e|<zip-enum> => <log>)
(any? fin? (%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)))
(dm elt-or (x|<zip> key|<int> default => <any>)
(rep fnd (((count <int>) 0) ((e <zip-enum>) (enum x)))
(if (fin? e)
default
(if (== count key)
(now e)
(fnd (+ count 1) (nxt e))))))
Paul Dufresne wrote:
> I tend to think this is a bug:
> goo/user 0<= (set myzip (zip #[ 1 2 3 4] #[ 5 6 7 8] ) )
> goo/user 0=> #{<zip> zip-dat: #(#[1 2 3 4] #[5 6 7 8])}
> goo/user 0<= (1st myzip)
> ERROR: No applicable methods on #{Gen elt-or ((x <col>) (k <any>)
> (default <any>))} when called with (#{<zip> zip-dat: #(#[1 2 3 4] #[5 6
> 7 8])} 0 #{<elt-default>}).
> Type ",restart N" to restart execution:
> Is it?
>
_______________________________________________
Googoogaga mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/googoogaga