Hasekll使用复制选择矩阵

时间:2017-06-28 05:39:52

标签: haskell grid

我正在尝试解决一个我不知道如何处理的问题:如何使用>OK The Microsoft Exchange IMAP4 service is ready. [QwBZADQAUABSADEANABDAEEAMAAwADQAOAAuAG4AYQBtAHAAcgBkADEANAAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A] A0 CAPABILITY * CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL A0 OK CAPABILITY completed. DEBUG: protocolConnect login, host=outlook.office365.com, user=yyy@xxx.onmicrosoft.com, password=<non-null>> javax.mail.MessagingException: No login methods supported!; nested exception is: com.sun.mail.iap.ProtocolException: No login methods supported! 定义在每个单元格中包含replicate的矩阵choice :: Matrix [Int]?< / p>

1 个答案:

答案 0 :(得分:0)

首先,我假设你想要一个9乘9的网格,每个条目都有一个列表,Matrix的定义如下所示:

type Matrix a = [[a]]

现在,函数replicate :: Int -> a -> [a]采用Int和某种类型a,重复多​​次。

因此我们首先要尝试的是:我们如何在每个元素中创建一个包含[1..9]的列表?

Prelude> replicate 9 [1..9]
[[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]
,[1,2,3,4,5,6,7,8,9]]

略微编辑输出以显示其自己行中的每个元素,但这实际上是矩阵中的单行,不是吗?为什么我们不再重复9次呢?

Prelude> replicate 9 $ replicate 9 [1..9]
[[[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6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