non-exhaustive-patterns

    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

    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); 我知