Chris F Clark wrote:
> Thus, as we traverse a list, the first element might be an integer,
> the second a floating point value, the third a sub-list, the fourth
> and fifth, two more integers, and so on.  If you look statically at
> the head of the list, we have a very wide union of types going by.
> However, perhaps there is a mapping going on that can be discerned.
> For example, perhaps the list has 3 distinct types of elements
> (integers, floating points, and sub-lists) and it circles through the
> types in the order, first having one of each type, then two of each
> type, then four of each type, then eight, and so on.

  Sounds like an interesting problem.  Although not the exact type
specified above, here's something pretty similar that I could think of
implementing in Haskell.  (I don't know what a "sub-list" is, for
example).  Maybe some Haskell wizard could get rid of the tuples?


data Clark a b c = Nil | Cons a (Clark b c (a,a)) deriving Show

clark = (Cons 42 (Cons 3.14 (Cons "abc"
        (Cons (1,2) (Cons (1.2,3.4) (Cons ("foo","bar")
        (Cons ((9,8),(7,6)) (Cons ((0.1,0.2),(0.3,0.4)) Nil))))))))

main = print clark

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to