From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA05937; Wed, 17 Apr 2002 23:19:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA05933 for ; Wed, 17 Apr 2002 23:19:39 +0200 (MET DST) Received: from maile.telia.com (maile.telia.com [194.22.190.16]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3HLJcb29116 for ; Wed, 17 Apr 2002 23:19:38 +0200 (MET DST) Received: from gateway (h175n2fls34o849.telia.com [217.208.235.175]) by maile.telia.com (8.11.6/8.11.6) with ESMTP id g3HLJb202499; Wed, 17 Apr 2002 23:19:37 +0200 (CEST) From: "Mattias Waldau" To: "'Markus Mottl'" , "'Christophe TROESTLER'" Cc: "'O'Caml Mailing List'" Subject: RE: [Caml-list] The invert Benchmark Date: Wed, 17 Apr 2002 23:19:19 +0200 Message-ID: <001701c1e655$896e9960$0200a8c0@gateway> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 In-Reply-To: <20020417203039.GA3339@fichte.ai.univie.ac.at> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I followed his Python-code, which was much better than his Ocaml-code. /mattias module Ord_string = struct type t = string let compare = compare end ;; module S = Splay.Make(Ord_string) ;; let tab_pattern = (Str.regexp_string "\t") in let b = S.create () in try while true do let line = input_line stdin in match Str.split tab_pattern line with | v :: k :: _ -> (try S.set b k (v :: (S.find b k)) with Not_found -> S.set b k [v]) | _ -> failwith "Not a pair" done with End_of_file -> (); S.iter (fun k vs -> let vs = List.sort compare vs in Printf.printf "%s\t%s\n" k (String.concat "\t" vs)) b ;; ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners