這是我定義的函數任何」 any' :: (t -> Bool) -> [t] -> Bool
any' f = foldl' step False
where step :: Bool -> t -> Bool
step b x | f x = True
| otherwise = b
我擁抱時加載此錯誤: ERROR "folds.hs":6
我正在閱讀「Learn You Haskell」一書。 我想定義這個簡單的函數,但編譯器正在吐出它。這可能是一些很基本的,簡單的,但我是一個完整的Haskell新手: GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loadin
我剛剛偶然發現了一個我不明白的東西。 如果我使用GHCI和使用getLine我得到以下 Prelude> a <- getLine
Test<Backspace>oo<CR> -- the Backspace action results in a '^?'
Prelude> a
"Test\DELoo"
如果我在一個Haskell寫相同文件 module Main where
ma
有了這個: data Rectangle = Rectangle Height Width
data Circle = Circle Radius
class Shape a where
area :: a -> Float
perimeter :: a -> Float
instance Shape Rectangle where
area (Rectan