haskell

    2熱度

    3回答

    我正在使用Fortify代碼分析工具。在我的代碼,我從XML獲取字符串並解析它加倍 a= Double.parseDouble(b); 工具給我 The program calls a method that parses doubles and can cause the thread to hang. 我怎樣才能提高我的代碼?

    1熱度

    2回答

    我有一些點,並且每個點的座標都有差異。它存儲在陣列中(僅舉例): x <- c(1, 2, 3, 4, 5) y <- c(1, 2, 3, 4, 5) dx <- c(0.1, 0.1, 0.1, 0.1, 0.1) dy <- c(0.1, 0.1, 0.1, 0.1, 0.1) 並且每個點的座標是(x +/- dx,y +/- dy)。 我想用行y = k * x來擬合它,並得到結

    4熱度

    1回答

    從Ninety-Nine Haskell Problems: Question 23:提取從列表中隨機選擇的元件的給定數目。 這是部分解決方案。爲了簡單起見,這段代碼只是從列表中選擇一個元素。 import System.Random (randomRIO) randItem :: [a] -> IO a randItem xs = do i <- randomRIO (0,len

    0熱度

    2回答

    我想用Haskell Turtle做一些CSV文件處理,但是我在使用選項解析器中的Turtle.FilePath時遇到了問題。 下面是一個exampple: {-# LANGUAGE OverloadedStrings #-} module Main where import Lib import Control.Applicative import qualified Data.By

    -1熱度

    1回答

    我想實現一個函數,我有兩個列表,第一個是任何類型,第二個是布爾,我希望它只返回第一個列表,如果它是等於true。例如: pickIt [1, 2, 3] [True, False, True] returns [1, 3] 這裏是我的代碼: pickIt :: [a] -> Bool -> [a] pickIt (x:xs) (y:ys) = (x, y) : pickIt xs ys p

    1熱度

    1回答

    我從來沒有在#1見過這個具體問題和其他問題沒有幫助我(我以前試過開)。 當我嘗試打印二叉樹這種方式如下: data BinTree a = ET | Branch (BinTree a) a (BinTree a) deriving Show ejC:: BinTree a -> String ejC ET = "" ejC (Branch x y z) = (ejC x) ++ "|-"

    0熱度

    1回答

    我在Haskell中編寫了一個cgi腳本。 我只限於使用擁抱/ runhugs。 #!/opt/local/bin/runhugs module Main where main = do putStrLn ("content-type: text/plain\n") putStrLn ("Hello, Server!") 到目前爲止好。 但現在我想獲得服務器的環

    0熱度

    1回答

    我試圖按照the servant tutorial,我跑入驚天動地錯誤Unknown fields: build-tool-depends。這是我tutorial.cabal文件(我得到這個從servant's github repo): name: tutorial version: 0.10 synopsis: The servant tutorial homepage:

    1熱度

    1回答

    當我運行這段代碼: test1 :: Int -> String test1 x = do if x == 1 then "Hello" 我得到以下錯誤: test-if.hs:4:21: error: parse error (possibly incorrect indentation or mismatched brackets) 我不知道這是爲什麼

    1熱度

    2回答

    我在編寫Haskell中的簡單函數時遇到了麻煩......它意在計算從1到n的數字之和。我不允許使用if語句,因爲我的老師希望我們專注於函數式編程。任何幫助,將不勝感激。謝謝! summation :: Integer -> Integer summation n | n > 1 = n + summation(n-1) | n == 1 = 1 這是GHCI輸出: cl