Browse thread
OO programming
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Tiphaine.Turpin <Tiphaine.Turpin@f...> |
| Subject: | Re: [Caml-list] OO programming |
Dirk Thierbach a écrit :
> On Mon, Feb 25, 2008 at 05:02:22PM +0100, Berke Durak wrote:
>
>> Yes that could be nice but it's no biggie IMHO.
>>
>> let init n f =
>> let s = make n (f 0) in
>> for i=1 to n-1 do
>> set s i (f i);
>> done;
>> s
>>
>> let init : int -> (int -> char) -> string = init
>>
>
> Nice. I hadn't seen this trick before. You don't happen to know a
> similar trick that works with methods?
>
I get the idea. Would the following satisfy your needs (you may place
the code and the type in any order) ?
let _ = object (self)
method init n f =
let s = make n (f 0) in
for i=1 to n-1 do
set s i (f i);
done;
s
method virtual init : int -> (int -> char) -> string
end
Tiphaine Turpin
> - Dirk
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>