내가 하스켈 프로그래밍 초보자입니다 매우 자주 오류를하스켈 - 형식 문제
xxx.hs:30:1: parse error on input `xxx'
를 얻을 수 그리고 종종 형식의 해결책을 가지고 노는 조금이있다. 그것의 동일한 코드와 동일하게 보이지만 주위에 놀고 나면 오류가 사라졌습니다. 내가 그 코드 후 오류
LookupAll.hs:30:1: parse error on input `lookupAll'
있어 순간
:
lookupOne :: Int -> [(Int,a)] -> [a]
lookupOne _ [] = []
lookupOne x list =
if fst(head list) == x then snd(head list) : []
lookupOne x (tail list)
-- | Given a list of keys and a list of pairs of key and value
-- 'lookupAll' looks up the list of associated values for each key
-- and concatenates the results.
lookupAll :: [Int] -> [(Int,a)] -> [a]
lookupAll [] _ = []
lookupAll _ [] = []
lookupAll xs list = lookupOne h list ++ lookupAll t list
where
h = head xs
t = tail xs
하지만 바로 내 생각에 모든 것을 수행했다. 탭이 없거나 비슷한 것이 없습니다. 항상 4 칸. 이 문제에 대한 일반적인 해결책이 있습니까? 지금 메모장을 사용하고 있습니다. ++.
감사합니다.
당신은'else' 절이 Haskell의'if' 표현식의 선택적 부분이 아니라는 것을 잊었을 것입니다. –