<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, &quot;Lorenzo Isella&quot; &lt;<a href="mailto:lorenzo.isella@gmail.com">lorenzo.isella@gmail.com</a>&gt; wrote:<br type="attribution">&gt; Dear All,<br>&gt; I still have to find my way with immutable lists and list comprehension.<br>
&gt; Consider the following lists<br>&gt; <br>&gt; A=[0,10,20,30,40,50]<br>&gt; B=[0,10,50] (i.e. B is a subset of list A; list A is already ordered in <br>&gt; increasing order and so is B).<br>&gt; C=[2,1,-5] i.e. there is a corresponding element in C for every element <br>
&gt; in B.<br>&gt; <br>&gt; Now, I would like to define a new list D having length equal to the <br>&gt; length of A. The elements of D in the position of the elements of A in <br>&gt; common with B are equal to the corresponding entries in C, whereas the <br>
&gt; other ones are zero i.e.<br>&gt; D=[2,1,0,0,0,-5]. How can I achieve that? The first thought that comes <br>&gt; to my mind is to define a list of zeros which I would modify according <br>&gt; to my needs, but that is not allowed...<br>
&gt; Many thanks<br>&gt; <br>&gt; Lorenzo<br>&gt; _______________________________________________<br>&gt; Beginners mailing list<br>&gt; <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</p>