2011-05-17 158 views
2

當試圖定義函數不在範圍內 'foldrl'

maximum' :: (Ord a) => [a] -> a 
maximum' = foldrl (\x acc -> if x > acc then x else acc) 

ghci的報告錯誤:

Not in scope: `foldrl' 
Failed, modules loaded: none. 
Ubuntu 10.04 
$ ghci --version 
The Glorious Glasgow Haskell Compilation System, version 6.12.1 

爲什麼不在範圍內的功能foldrl

+4

爲什麼你相信一個叫做'功能存在foldrl'? – 2011-05-17 15:07:20

+0

在SO上搜索'foldrl'並沒有發現任何其他相關的東西,所以我添加了一個真正的問題,以防其他人嘗試這樣做。 – 2011-05-17 15:58:10

回答

11

哦~~,你想不foldr1foldrl,最後一個字符是一個1,不是l

+0

這是foldrl http://learnyouahaskell.com/higher-order-functions#folds – wenlong 2011-05-17 15:09:43

+0

,對不起,那是foldr1!現在沒問題。謝謝! – wenlong 2011-05-17 15:11:37

3

我想你的意思foldr1(最後一個字符是數字1),不foldrl