兩個函數digits
和firstDigit
定義如下:添加一個firstDigit - 哈斯克爾
digits :: String -> String
digits st = [ ch | ch <- st , isDigit ch ]
firstDigit :: String -> Char
firstDigit st
= case (digits st) of
[] -> '\0'
(x:_) -> x
不過,我將如何去定義一個函數,增加了一到這個firstDigit
,然後返回結果。
P
你到目前爲止嘗試過什麼? StackOverflow可以爲作業提供幫助,而不是作業回答。 – stusmith
我嘗試以下: – user832488
firstDigitPlusOne ::字符串 - 的 []>字符 firstDigitPlusOne ST =情況下(位ST) - > '\ 0' (X:_) - > X + 1 – user832488