<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">There is a function "concatMap" to simplify "concat $ map".</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small">Furthermore, you could use inline notation as follow:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">concatMap (\x -> x == "z" then B else [x]) A</font></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;font-size:small"><br></div><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 4, 2017 at 7:50 AM, Денис Мирзоев <span dir="ltr"><<a href="mailto:nolane16@gmail.com" target="_blank">nolane16@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">If you sure "z" is the last element of A you can use</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">init A ++ B</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">if it's somwhere in the middle consider</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">cocat $ map f A</span><br style="font-size:12.8px"><span style="font-size:12.8px"> where</span><br style="font-size:12.8px"><span style="font-size:12.8px"> f x</span><br style="font-size:12.8px"><span style="font-size:12.8px"> | x == "z" = B</span><br style="font-size:12.8px"><span style="font-size:12.8px"> | otherwise = [x]</span><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 4, 2017 at 2:41 PM, Денис Мирзоев <span dir="ltr"><<a href="mailto:nolane16@gmail.com" target="_blank">nolane16@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If you sure "z" is the last element of A you can use<br><br>init A ++ B<br><br>if it's somwhere in the middle consider<br><br>cocat $ map f A<br> where<br> f x<br> | x == "z" = B<br> | otherwise = [x]</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5"><div><div class="m_3177840860357363486h5">On Sat, Nov 4, 2017 at 1:57 PM, FlyingSheep <span dir="ltr"><<a href="mailto:flyingsheep@qq.com" target="_blank">flyingsheep@qq.com</a>></span> wrote:<br></div></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div><div class="m_3177840860357363486h5"><div>(take 2 A) ++ B</div><div> </div><div><u></u><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><div style="font-size:14px;font-family:Verdana;color:#000"><div>李 鹏<br>四川大学计算机学院</div></div><u></u></div><div> </div><div><br></div><div><br></div><div style="font-size:12px;font-family:Arial Narrow;padding:2px 0 2px 0">------------------ 原始邮件 ------<wbr>------------</div><div style="font-size:12px;background:#efefef;padding:8px"><div><b>发件人:</b> "mirone"<<a href="mailto:saul-mirone@qq.com" target="_blank">saul-mirone@qq.com</a>>; </div><div><b>发送时间:</b> 2017年11月4日(星期六) 晚上6:48</div><div><b>收件人:</b> "haskell-cafe"<<a href="mailto:haskell-cafe@haskell.org" target="_blank">haskell-cafe@ha<wbr>skell.org</a>>; </div><div><b>主题:</b> [Haskell-cafe] Replace list item with list.</div></div><div class="m_3177840860357363486m_-141577956242795312HOEnZb"><div class="m_3177840860357363486m_-141577956242795312h5"><div><br></div>Hello everyone! <div>If I have a list A : ["x", "y", "z"]</div><div>and a list B: ["f", "g"].</div><div>Here is my question:</div><div>What's the simplest way to replace "z" in the list A by list B, and get ["x", "y", "f", "g"] ?</div></div></div><br></div></div></div></div>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
</blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width:0px;max-height:0px;overflow:hidden" src="https://mailfoogae.appspot.com/t?sender=aZHZkYWxpbHVlQGdtYWlsLmNvbQ%3D%3D&type=zerocontent&guid=02db7c34-7e85-4174-8df4-c43613539673"><font color="#ffffff" size="1">ᐧ</font></div>