brief example of ZipList?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

brief example of ZipList?

Michael Mossey
Can someone give me a brief example using ZipList? I want to do something like

z1 :: [Int -> Int]
z1 = [succ,succ]

z2 :: [Int]
z2 = [1,2]

z3 = z1 <*> z2

But don't know to get it to regard these as ZipLists and not regular lists.

This is purely for learning purposes. No application in mind.

-Mike
Reply | Threaded
Open this post in threaded view
|

brief example of ZipList?

Antoine Latter-2
On Mon, Aug 10, 2009 at 7:08 PM, Michael P Mossey<[hidden email]> wrote:

> Can someone give me a brief example using ZipList? I want to do something
> like
>
> z1 :: [Int -> Int]
> z1 = [succ,succ]
>
> z2 :: [Int]
> z2 = [1,2]
>
> z3 = z1 <*> z2
>
> But don't know to get it to regard these as ZipLists and not regular lists.
>
> This is purely for learning purposes. No application in mind.

z3 = getZipList $ (ZipList z1) <*> (ZipList z2)

Should do what you want. Does that make sense?

Antoine
Reply | Threaded
Open this post in threaded view
|

brief example of ZipList?

Thomas Davie
In reply to this post by Michael Mossey
z1 :: ZipList (Int -> Int)
z1 = ZipList [succ,succ]

z2 :: ZipList Int
z2 = ZipList [1,2]

z3 :: ZipList Int
z3 = z1 <*> z2

Bob

On 11 Aug 2009, at 02:08, Michael P Mossey wrote:

> Can someone give me a brief example using ZipList? I want to do  
> something like
>
> z1 :: [Int -> Int]
> z1 = [succ,succ]
>
> z2 :: [Int]
> z2 = [1,2]
>
> z3 = z1 <*> z2
>
> But don't know to get it to regard these as ZipLists and not regular  
> lists.
>
> This is purely for learning purposes. No application in mind.
>
> -Mike
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/beginners