<p>Are these truly lists, or would you be better suited using Sets, Maps or IntMaps?</p>
<p>Then you can use some of the unionWith functions to decide what to insert, or you can simply wrap the looking functions to return zero on failure.</p>
<p>Antoine</p>
<p>On Sep 14, 2010 6:35 PM, "Lorenzo Isella" <<a href="mailto:lorenzo.isella@gmail.com">lorenzo.isella@gmail.com</a>> wrote:<br type="attribution">> Dear All,<br>> I still have to find my way with immutable lists and list comprehension.<br>
> Consider the following lists<br>> <br>> A=[0,10,20,30,40,50]<br>> B=[0,10,50] (i.e. B is a subset of list A; list A is already ordered in <br>> increasing order and so is B).<br>> C=[2,1,-5] i.e. there is a corresponding element in C for every element <br>
> in B.<br>> <br>> Now, I would like to define a new list D having length equal to the <br>> length of A. The elements of D in the position of the elements of A in <br>> common with B are equal to the corresponding entries in C, whereas the <br>
> other ones are zero i.e.<br>> D=[2,1,0,0,0,-5]. How can I achieve that? The first thought that comes <br>> to my mind is to define a list of zeros which I would modify according <br>> to my needs, but that is not allowed...<br>
> Many thanks<br>> <br>> Lorenzo<br>> _______________________________________________<br>> Beginners mailing list<br>> <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>> <a href="http://www.haskell.org/mailman/listinfo/beginners">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</p>