0
給出一個字符串,我需要一個函數,它返回一個由原始字符串中的每個字符替換字母表中每個小寫字母形成的字符串列表。例如"car"
- >["aar","bar","dar",....,"cbr","ccr",...]
。 我嘗試這樣做:用所有字母字符替換字符串中的所有字符的函數Haskell
replaced1 :: String -> [String]
replaced1 [] = []
replaced1 (x:xs) = [h ['a'..'z'] : map (x:) (replaced1 xs)
where h[] = []
h c= head c (h(tail c))
,但它在where
給我解析錯誤。我只是在學習Haskell,所以我沒有使用這種錯誤。我該如何解決這個問題?
解析錯誤。 – chaosmasttter
謝謝,但現在我仍然在輸入「=」在最後一行得到一個解析錯誤 –
你是混合標籤和空格嗎?嘗試只使用空格。 – chaosmasttter