我正在尝试编写一个函数,它将给定值附加到嵌套列表结构的最里面的列表中,但是当我什至不确定此类函数的类型签名是什么时,我遇到了类型错误.
digpend a xs = case xs of [_:_] -> map (digpend a) xs
[[]] -> [[a]]
xs -> a:xs
例如,
digpend 555 [ [ [ 5,1,-12,33 ] , [ 6,22 ] ] , [ [ -9,0,9,12,83 ] ] ]
应该返回
[ [ [ 555,5,1,-12,33 ] , [ 555,6,22 ] ] , [ [ 555,-9,0,9,12,83 ] ] ]
理想情况下,它可以通过递归在任何级别的嵌套上工作。这是允许的吗?