non-exhaustive-patterns

    1热度

    1回答

    你好,我是新来的ML和写一个树形图功能,以下数据类型: datatype tree = NIL | CONS of (tree * tree) | LEAF of int; 这是我的树形图功能: fun treemap f = fn LEAF x => LEAF (f x) | CONS(y,z) => CONS (treemap f y, treemap f z); 我知

    2热度

    2回答

    的筛非详尽的模式我想使用埃拉托色尼的筛的这段代码从该页面:http://en.literateprograms.org/Sieve_of_Eratosthenes_(Haskell)#chunk DEF:primes_naive 只有一点修改,所以它只显示了素数高达数: primes :: Integral a => a -> [a] primes m = sieve [2..m] w

    2热度

    1回答

    我在Haskell中编写了一个程序,它可以很好地打印表格并对其执行基本查询。下面的函数是打印表格中的代码的一个片段: printTable :: Table -> [String] printTable [email protected](header:rows) = [addLine] ++ addHeader ++ [addLine] ++ addRows rows ++ [addLine]

    1热度

    1回答

    我想知道是否有人可以帮助我确定haskell代码中非详尽的部分?我看不出列表末尾没有遇到基本情况。 非常感谢 强尼 type Rule = (Char, String) type Rules = [Rule] type System = (Float, String, Rules) cross, triangle, arrowHead, peanoGosp

    1热度

    1回答

    我不知道为什么我的函数不起作用。我已经浏览了所有关于非详尽功能的帖子,但是我的功能尽可能地实现了所有可能的选项。 ascending :: [Int] -> Bool ascending [] = error "Empty list given" ascending [x] = True ascending [x,y] | y>=x = True | x<y

    0热度

    1回答

    我有一个Evol类,并希望将distanceMatrix的一个实例应用到我的类型MolSeq的列表中。函数molseqDistMat按照需要工作,但我无法理解尝试运行distanceMatrix [Molseq]时得到的错误。我明白错误是什么,但我找不到例外。这是错误。 *F2> distanceMatrix l *** Exception: lab2.hs:79:3-43: Non-exhau

    0热度

    1回答

    sumAllDigits :: [ Int ] -> Int sumAllDigits (x:xs) |(x:xs) == [] = 0 |x >= 10 = sumDigits x + sumAllDigits xs |x< 10 = x + sumAllDigits xs REPORT: *递归> sumAllDigits [22,33] ***异常:Rec

    0热度

    1回答

    trace :: String -> Float -> Colour -> [ColouredLine] trace (c:cs) angle colour = trace' (c:cs) angle colour (0.0,0.0) where trace' "" angle colour intvertex = [] trace' (c:cs) angle c

    7热度

    2回答

    我明天正在为测试进行培训,以完成我对函数式编程的介绍,但有一件事我不明白。 每当我有这样一个程序: test [] = [] test (x:xs) = test (xs) 他所做的是,他采取的第一个元素淘汰之列,并与其余部分继续。每当只剩下一个时,xs应该是[],而这又应该触发test [] = []。但是每当我运行这个算法,我得到一个错误。 Exception: <interactive

    0热度

    1回答

    我在实施以下功能的困难: type Tabuleiro = [String] type Comandos = String type Comando = String type Coordenadas = String novaCoord :: Tabuleiro -> Comandos -> Coordenadas -> Coordenadas novaCoord l (cmd:x