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 RAA13027; Thu, 8 Apr 2004 17:04:29 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA13171 for ; Thu, 8 Apr 2004 17:04:27 +0200 (MET DST) Received: from sark.cc.gatech.edu (sark.cc.gatech.edu [130.207.7.23]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i38F5Kjq010079 for ; Thu, 8 Apr 2004 17:05:21 +0200 Received: from gaia.cc.gatech.edu (gaia.cc.gatech.edu [130.207.3.8]) by sark.cc.gatech.edu (8.12.10/8.12.8) with ESMTP id i38F4N8E012099; Thu, 8 Apr 2004 11:04:23 -0400 (EDT) Received: (from fernando@localhost) by gaia.cc.gatech.edu (8.12.10/8.12.8) id i38F4N1D007893; Thu, 8 Apr 2004 11:04:23 -0400 (EDT) Date: Thu, 8 Apr 2004 11:04:23 -0400 From: Fernando Alegre To: John Goerzen Cc: Brian Hurt , Issac Trotts , Ocaml Mailing List Subject: Re: [Caml-list] Dynamically evaluating OCaml code Message-ID: <20040408150423.GA5879@gaia.cc.gatech.edu> References: <20020104004356.GA1672@mev> <20040408133727.GC29195@excelhustler.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040408133727.GC29195@excelhustler.com> User-Agent: Mutt/1.4.2.1i X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alegre:01 gatech:01 caml-list:01 dynamically:01 2004:99 python:01 val:01 val:01 ocaml:01 ocaml:01 int:01 int:01 partially:02 string:03 string:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Keywords: X-UID: 146 On Thu, Apr 08, 2004 at 08:37:27AM -0500, John Goerzen wrote: > Basic string processing is also more difficult than a language such as, > say, Python, where I can say, for instance: > > y = x[2:-1] > > In OCaml, I would write -- I think: > > let y = String.sub x 2 ((String.length x) - 3)) > You can always use the ability of Ocaml to create new operators to partially overcome this problem: # let ($<) s i = String.sub s 0 i;; val ( $< ) : string -> int -> string = # let ($>) s i = String.sub s (String.length s - i) i;; val ( $> ) : string -> int -> string = # "hello, world" $< 5 $> 3;; - : string = "llo" # "hello, world" $> 5 $< 3;; - : string = "wor" Fernando ------------------- 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