我有一个清单。我需要创建一个新列表,如下例所示:
 [3, 3, 1, 3]to [3, 3, 3, 1, 1, 3, 3]. 谁能告诉我的代码有什么问题?
add xs
   = let
      adding (x : xs) as
         =
            if x == head(xs) && length(xs) >= 1
               then adding xs (x : as)
               else adding xs (x : x : as)
      adding _ as
         = as
   in
   adding xs []
ghci 告诉总是有空列表是xs,但我有xs length控制权。