我想用换行符输出这个2D列表。我尝试了一些方法,但它们似乎没有用。请帮助我感谢
我的代码:
list = [[' ',' ','*',' ',' ',' ',' ',' ',' ','*',' ',' ',' ',' ',' ',' ','*',' ',' '],
[' ','*',' ','*',' ',' ',' ',' ','*',' ','*',' ',' ',' ',' ','*',' ','*',' '],
['*',' ','*',' ','*',' ',' ','*',' ','*',' ','*',' ',' ','*',' ','*',' ','*'],
['-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-'],
[' ',' ','1',' ',' ',' ',' ',' ',' ','2',' ',' ',' ',' ',' ',' ','3',' ',' ']]
num :: [Int] -> String
num x = case x of
[] -> []
x:xs -> list!!x ++ "\n" ++ num xs
我输出我得到:
Prelude-> num [0,1,2,3,4]
" * * * \n * * * * * * \n* * * * * * * * *\n-------------------\n 1 2 3 \n"
我想要的输出:
Prelude-> num [0,1,2,3,4]
* * *
* * * * * *
* * * * * * * * *
-------------------
1 2 3