Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 函数过滤中的非穷举模式? cubes=[(a,b,c)| a_Haskell_Functional Programming - Fatal编程技术网

Haskell 函数过滤中的非穷举模式? cubes=[(a,b,c)| a

Haskell 函数过滤中的非穷举模式? cubes=[(a,b,c)| a,haskell,functional-programming,Haskell,Functional Programming,试试这个: cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ] filtering (d,f,g) | d == f && f == g && d ==g = "cube" third = filter newfun cubes newfun (x,y,z) = (filtering (x,y,z) == "cube") *Charana> third [(

试试这个:

cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering (d,f,g)
 | d == f && f == g && d ==g = "cube"

third = filter newfun cubes 

newfun (x,y,z) = (filtering (x,y,z) == "cube")



*Charana> third
[(1,1,1)*** Exception: haskell.hs:(55,1)-(56,37): Non-exhaustive patterns in  function filtering
始终在编译代码时启用警告。例如,在文件顶部使用此选项

cubes :: [(Int,Int,Int)]
cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering :: (Int,Int,Int) -> Bool
filtering (d,f,g) = d == f && f == g && d == g

third :: [(Int,Int,Int)]
third = filter filtering cubes 
或者手动将
-Wall
标志传递给GHC。如果这样做,它将警告您在编译时函数可能不完整。例如

{-# OPTIONS -Wall #-}
将触发警告,因为当
SomeCondition x
为false时,它不会说明结果。

请尝试以下操作:

cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering (d,f,g)
 | d == f && f == g && d ==g = "cube"

third = filter newfun cubes 

newfun (x,y,z) = (filtering (x,y,z) == "cube")



*Charana> third
[(1,1,1)*** Exception: haskell.hs:(55,1)-(56,37): Non-exhaustive patterns in  function filtering
始终在编译代码时启用警告。例如,在文件顶部使用此选项

cubes :: [(Int,Int,Int)]
cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering :: (Int,Int,Int) -> Bool
filtering (d,f,g) = d == f && f == g && d == g

third :: [(Int,Int,Int)]
third = filter filtering cubes 
或者手动将
-Wall
标志传递给GHC。如果这样做,它将警告您在编译时函数可能不完整。例如

{-# OPTIONS -Wall #-}
将触发警告,因为当
SomeCondition x
为false时,它不会说明结果。

请尝试以下操作:

cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering (d,f,g)
 | d == f && f == g && d ==g = "cube"

third = filter newfun cubes 

newfun (x,y,z) = (filtering (x,y,z) == "cube")



*Charana> third
[(1,1,1)*** Exception: haskell.hs:(55,1)-(56,37): Non-exhaustive patterns in  function filtering
始终在编译代码时启用警告。例如,在文件顶部使用此选项

cubes :: [(Int,Int,Int)]
cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering :: (Int,Int,Int) -> Bool
filtering (d,f,g) = d == f && f == g && d == g

third :: [(Int,Int,Int)]
third = filter filtering cubes 
或者手动将
-Wall
标志传递给GHC。如果这样做,它将警告您在编译时函数可能不完整。例如

{-# OPTIONS -Wall #-}
将触发警告,因为当
SomeCondition x
为false时,它不会说明结果。

请尝试以下操作:

cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering (d,f,g)
 | d == f && f == g && d ==g = "cube"

third = filter newfun cubes 

newfun (x,y,z) = (filtering (x,y,z) == "cube")



*Charana> third
[(1,1,1)*** Exception: haskell.hs:(55,1)-(56,37): Non-exhaustive patterns in  function filtering
始终在编译代码时启用警告。例如,在文件顶部使用此选项

cubes :: [(Int,Int,Int)]
cubes = [ (a,b,c) | a <- [1..30],b <-[1..30],c <- [1..30] ]

filtering :: (Int,Int,Int) -> Bool
filtering (d,f,g) = d == f && f == g && d == g

third :: [(Int,Int,Int)]
third = filter filtering cubes 
或者手动将
-Wall
标志传递给GHC。如果这样做,它将警告您在编译时函数可能不完整。例如

{-# OPTIONS -Wall #-}

将触发警告,因为当
somecondition x
为false时,它没有说明结果应该是什么。

如果f、d、g不完全相同,
过滤应该怎么做?不,不,不……
过滤(“foo”、“bar”、“baz”)
不好用。
如果f,d,g不都一样,过滤应该怎么办?不,不,不。
过滤(“foo”,“bar”,“baz”)
不好用。
如果f,d,g不都一样,过滤应该怎么办?不,不,不。
过滤(“foo”,“bar”,“baz”)
不起作用……如果f、d、g不完全相同,
过滤应该怎么做?不,不,不……
过滤(“foo”、“bar”、“baz”)
不起作用……让我抓狂的一个警告是名称阴影。如果我对全局名称进行阴影处理,我几乎肯定不在乎。如果我对本地名称进行阴影处理,这可能是故意的——我可以使用阴影来保证不会意外地重用循环变量的初始值。让我抓狂的一个警告是e name shadowing one。如果我对全局名称进行阴影处理,我几乎肯定不在乎。如果我对局部名称进行阴影处理,这可能是故意的——我可以使用阴影处理来保证不会意外重用循环变量的初始值。让我发疯的警告是名称阴影处理。如果我对全局名称进行阴影处理,我几乎肯定不会注意。如果我对局部名称进行阴影处理,可能是有意的——我可以使用阴影来保证不会意外地重用循环变量的初始值。让我发疯的警告是名称阴影处理。如果我对全局名称进行阴影处理,我几乎肯定不在乎。如果我对局部名称进行阴影处理,可能是有意的——我可以使用sh确保不会意外重用循环变量的初始值。