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 XAA18016; Mon, 17 Feb 2003 23:57:52 +0100 (MET) 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 XAA18017 for ; Mon, 17 Feb 2003 23:57:51 +0100 (MET) Received: from epexch01.qlogic.org ([63.170.40.3]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1HMvof22136 for ; Mon, 17 Feb 2003 23:57:50 +0100 (MET) Received: from epmailtmp.qlogic.org ([10.20.33.254]) by epexch01.qlogic.org with Microsoft SMTPSVC(5.0.2195.5329); Mon, 17 Feb 2003 16:56:38 -0600 Received: from [10.20.33.146] ([10.20.33.146]) by epmailtmp.qlogic.org with Microsoft SMTPSVC(5.0.2195.4905); Mon, 17 Feb 2003 16:56:38 -0600 Date: Mon, 17 Feb 2003 17:07:38 -0600 (CST) From: Brian Hurt X-X-Sender: Reply-To: Brian Hurt To: Issac Trotts cc: OCaml List Subject: Re: [Caml-list] Re: "ocaml_beginners"::[] string to list In-Reply-To: <3E5167D3.8060203@ucdavis.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 17 Feb 2003 22:56:38.0247 (UTC) FILETIME=[D3F9C770:01C2D6D7] Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 17 Feb 2003, Issac Trotts wrote: > Christian Schaller wrote: > > >Hi everyone! > > > >I'm trying to find a built in function for converting a string to a list of > >characters, similar to SML's explode. Is something like this available? > > > >Thank you! > > > >- Chris > > > # let explode s = > let n = String.length s in > let rec aux k = if k = n then [] else s.[k] :: aux (k+1) in > aux 0;; > val explode : string -> char list = > # explode "foo";; > - : char list = ['f'; 'o'; 'o'] > let explode s = let n = String.length s in let rec aux k accum = if k = n then (List.rev accum) else aux (k+1) (s.[k] :: accum) in aux 0 [] ;; See previous discussion. Brian ------------------- 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