プログラミング言語 Scala 6冊目
レス数が950を超えています。1000を超えると書き込みができなくなります。
0962デフォルトの名無しさん
2011/09/02(金) 18:41:19.77let foldl collection init f = collection#foldLeft init f
class type ['a, 'b] hasfoldLeft = object method foldLeft : 'b -> ('b -> 'a -> 'b) -> 'b end
class ['a, 'b] mylist (l : 'a list) =
object (self : ('a, 'b) #hasfoldLeft)
method foldLeft init f = List.fold_left f init l
end
let _ = foldl (new mylist [1; 2; 3]) 0 (+)
で動くわけだが
レス数が950を超えています。1000を超えると書き込みができなくなります。