Re: [Haskell-cafe] 回复: Replace list item with list.

If you sure "z" is the last element of A you can use
init A ++ B
if it's somwhere in the middle consider
cocat $ map f A
where
f x
| x == "z" = B
| otherwise = [x]
On Sat, Nov 4, 2017 at 2:41 PM, Денис Мирзоев
If you sure "z" is the last element of A you can use
init A ++ B
if it's somwhere in the middle consider
cocat $ map f A where f x | x == "z" = B | otherwise = [x]
On Sat, Nov 4, 2017 at 1:57 PM, FlyingSheep
wrote: (take 2 A) ++ B
------------------ 李 鹏 四川大学计算机学院
------------------ 原始邮件 ------------------ *发件人:* "mirone"
; *发送时间:* 2017年11月4日(星期六) 晚上6:48 *收件人:* "haskell-cafe" ; *主题:* [Haskell-cafe] Replace list item with list. Hello everyone! If I have a list A : ["x", "y", "z"] and a list B: ["f", "g"]. Here is my question: What's the simplest way to replace "z" in the list A by list B, and get ["x", "y", "f", "g"] ?
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (1)
-
Денис Мирзоев