well,<br>&gt; selFn = map (\x -&gt; (! x)) sel -- This is not necessarily the most elegant way to word it<br>would return a list of functions, which, when applied to a list, return an element from it based on the index<br>
&gt; results = map ($ ml) selFn<br>would solve your problem<br><br>alternatively (and more cleanly),<br>&gt; results = map (ml !) sel<br><br><div class="gmail_quote">On Fri, Sep 10, 2010 at 10:55 AM, Lorenzo Isella <span dir="ltr">&lt;<a href="mailto:lorenzo.isella@gmail.com">lorenzo.isella@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear All,<br>
I know this must be a one-liner, but it am banging my head against the wall.<br>
I am trying my hands at list manipulation in Haskell and a lot of useful function are making my life easier but I cannot achieve something really simple.<br>
Let us say you have the lists ml and sel<br>
<br>
ml=[23,44,55,8,98]<br>
and<br>
sel=[1,2] .<br>
<br>
Now, I would like simply to get a new list whose entries are the elements of ml in position sel. In my case things might be a little more complicated because all the elements are Integer and not Int (I noticed that sometimes this means I have to resort to generic functions).<br>

Cheers<br>
<br>
Lorenzo<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><div>          Alex R</div></div><br>