[英]Composed data type haskell
So, I have this function: 所以,我有这个功能:
solve x y = do
...
return (newx,y++[1])
where x and newx are [[Int]] and y is [Int]. 其中x和newx是[[Int]],y是[Int]。 And with this function, I will return a "value". 有了这个功能,我将返回一个“值”。 Now, I would like to know how can I "process" this value in order to extract the 2 components and use them separately. 现在,我想知道如何“处理”此值以便提取2个组件并分别使用它们。
Something like this: 像这样:
a <- solve x y
b <- a[0]
c <- a[1]
as the return
will wrap it into some monad, you can then get to the parts by deconstructing it directly inside a do
block like this: 因为return
会将它包装到一些monad中,所以您可以通过在do
块内直接对其进行解构来获得零件,如下所示:
do
(b,c) <- solve x y
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.