Simple List Question

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

Simple List Question

Jenny678
Hello

Little Problem, hope that somebody can help me

I have a list
>main [(1,2,3),(4,5,6),(3,4,5)]

and i want all Elements at the 1. Pos.  in new List:
>[1,4,3]

Thanks for help
Reply | Threaded
Open this post in threaded view
|

Re: Simple List Question

haskell-2
Jenny678 wrote:

> Hello
>
> Little Problem, hope that somebody can help me
>
> I have a list
>> main [(1,2,3),(4,5,6),(3,4,5)]
>
> and i want all Elements at the 1. Pos.  in new List:
>> [1,4,3]
>
> Thanks for help
>

Hello Jenny, and welcome to haskell-cafe.

I will hazard a guess that this resembles a homework problem, so
http://www.haskell.org/hawiki/HomeworkHelp applies.

It appears you need to change [(Int,Int,Int)] into [Int].  How would you get the
first element of a single tuple (1,2,3) ?  Then, how would you do this for each
member of the list?

--
Chris
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Simple List Question

Neil Mitchell
In reply to this post by Jenny678
Hi


> I have a list
> >main [(1,2,3),(4,5,6),(3,4,5)]
>
> and i want all Elements at the 1. Pos.  in new List:
> >[1,4,3]

You might want to take a look at list comprehensions, they fit very
nicely for this sort of problem.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe