X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Fsortedby.ml;h=177cf3c034369c70f4c2d819d0ccf91deb4b8a9c;hb=e948a077c64bf1e1fb29cce626e04f2c93a5ba3c;hp=db2258d569974ecd229dcf4c08f4b53f72bd1452;hpb=1cfcea66d7394a785ec439cd6b03497b276918c4;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/sortedby.ml b/helm/ocaml/mathql_interpreter/sortedby.ml index db2258d56..177cf3c03 100644 --- a/helm/ocaml/mathql_interpreter/sortedby.ml +++ b/helm/ocaml/mathql_interpreter/sortedby.ml @@ -20,7 +20,7 @@ * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, - * http://cs.unibo.it/helm/. + * http://www.cs.unibo.it/helm/. *) (* @@ -35,20 +35,28 @@ open Utility;; * implementazione del comando SORTEDBY *) let sortedby_ex alist order afunc = - [List.hd alist] - @ - List.map - (List.tl) - (Sort.list - (fun a b -> - match order with - MQAsc -> (List.hd a) < (List.hd b) - | MQDesc -> (List.hd a) > (List.hd b) - ) - (List.map - (fun l -> [apply_func afunc (List.hd l)] @ l) - (List.tl alist) - ) - ) + let before = Unix.time () in + let res = + let module S = Mathql_semantics in + (Sort.list + (fun {S.extra = e1} {S.extra = e2} -> + match order with + MQAsc -> e1 < e2 + | MQDesc -> e1 > e2 + ) + (List.map + (fun {S.uri = u ; S.attributes = attr} -> {S.uri = u ; S.attributes = attr ; S.extra = (apply_func afunc u)}) + alist + ) + ) + in + let after = Unix.time () + and ll1 = string_of_int (List.length alist) in + let diff = string_of_float (after -. before) in + print_endline + ("SORTEDBY(" ^ ll1 ^ ") = " ^ string_of_int (List.length res) ^ + ": " ^ diff ^ "s") ; + flush stdout ; + res ;;