Thanks to the use of the Unix module, this needs to be linked with unix.cma at compile time (or run in an interpreter which has unix.cma loaded).
type 'qtype taskqueue =
{queue: 'qtype;
dotask: unit -> unit;
target: float;
mutable error: float}
let itertask taskqlist =
let starttime =
Unix.gettimeofday()
and nextq =
List.fold_left
(fun a b -> if a.error > b.error then a else b)
(List.hd taskqlist)
taskqlist
in let nextqerror = nextq.error
in
nextq.dotask();
let tasktime =
Unix.gettimeofday() -. starttime in
List.iter
(fun q -> if q = nextq then
q.error <- q.error -. nextqerror +. (tasktime /. nextq.target) )
taskqlist;;
on the road
ReplyDeleteWITH ME!!! =D
i hate driving, let's never do that again
btw you still supposed to be teaching me javascript.
ReplyDelete