Wednesday, July 13, 2011

A List containing elements with consecutive types A and B

Just wondering how we can create a "heterogenous" list of two types, where an object of the first type must be inserted after the second.

Examples:
5 :: "help" :: 8 :: "ldf" to create a list with type (Int, String)
 "help" :: 8 :: "ldf" :: 9 to create a list with type (String, Int)

Here is what I got:
Wondering if I can do better.

-