CheckList.hs
isListHasOneEle :: [a] -> Bool isListHasOneEle [] = False isListHasOneEle (x:[]) = True isListHasOneEle (x:xs) = False
Prelude> :load CheckList.hs [1 of 1] Compiling Main ( CheckList.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> isListHasOneEle [] False *Main> isListHasOneEle [1] True *Main> isListHasOneEle [1, 2, 3] False *Main> isListHasOneEle [1..] False *Main> isListHasOneEle [[1, 2, 3]] True *Main>
No comments:
Post a Comment