11159Re: Module parameterization by ints
- Jul 1, 2009--- In firstname.lastname@example.org, Phil Tomson <rubyfan@...> wrote:
> Following up on this question: I need to do something very similar toGood starting points:
> the original poster's question but the answer given isn't quite clear
> to me.
> I would like to create a FIFO that is limited to N slots. I'd like to
> create a FIFO module that can be parameterized by an integer (N) so
> that I can create a FIFO of a specific size. How would I go about
> doing this?
- if you accept an imperative FIFO : module Queue of the standard library
- if you want a functional FIFO : module Fqueue of Jane Street's Core library (http://ocaml.janestreet.com/?q=node/13, also available with Godi)
- finally module Squeue of Jane Street's Core library seems to do kinda what you want
This last module's signature contains the following:
(** [create maxsize] returns a synchronized queue bounded to have no more than
[maxsize] elements. *)
val create : int -> 'a t
Then you can apply the previous answers (but maybe it is this last point which is the problem ?).
- << Previous post in topic Next post in topic >>