相关疑难解决方法(0)

是否有可能在Haskell中筑巢?

Haskell新手在这里,试图编写代码来解析数学表达式.码:

isDigit :: Char -> Bool
isDigit c = c >= '0' && c <= '9'

parseNumber :: String -> Maybe (String, String)
parseNumber [] = Just ("", "")
parseNumber (h:ls)
    | isDigit h
        | p == Nothing = Just([h], ls)      -- Digit found    <<< ERROR!!
        | otherwise = Just (h:fst d, snd d) -- Ends in a digit
    | h == '.'
        | p == Nothing = Nothing                                -- Ends in a point
        | not ('.' `elem` (snd d)) …
Run Code Online (Sandbox Code Playgroud)

haskell

7
推荐指数
4
解决办法
7810
查看次数

标签 统计

haskell ×1