From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 6DA33820A1 for ; Tue, 20 Aug 2013 17:23:36 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of monnier.florent@gmail.com) identity=pra; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of monnier.florent@gmail.com designates 209.85.212.173 as permitted sender) identity=mailfrom; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f173.google.com) identity=helo; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="postmaster@mail-wi0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApECAGiJE1LRVdStjWdsb2JhbABahAu/WYEaCBYOAQEBAQcLCwkSBiSCJAEBBAFAARsdAQMBCwYFCw0uIgERAQUBHAYbh3UBAwkGll6MUIMChDoKGScNZIEWAQUMkEkHhBQDl2WKKYVIFimERDo X-IPAS-Result: ApECAGiJE1LRVdStjWdsb2JhbABahAu/WYEaCBYOAQEBAQcLCwkSBiSCJAEBBAFAARsdAQMBCwYFCw0uIgERAQUBHAYbh3UBAwkGll6MUIMChDoKGScNZIEWAQUMkEkHhBQDl2WKKYVIFimERDo X-IronPort-AV: E=Sophos;i="4.89,921,1367964000"; d="scan'208";a="29865991" Received: from mail-wi0-f173.google.com ([209.85.212.173]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 20 Aug 2013 17:23:35 +0200 Received: by mail-wi0-f173.google.com with SMTP id en1so4479815wid.12 for ; Tue, 20 Aug 2013 08:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6nX89e+UdmexeL3Yw4GgyxtrLHrgcUIYQ356giw7NqY=; b=ZZsTOfPRRLkED5I73tyJKpVzpukv9X8zKKqnV/qjm76bNiYOkOS0chRDwCTy4gLFTc BI4CnBna5WTYAAjnFiQAF859bR6exjE6Dj9c3TUc/C4d1EOlRnaD8mc93qlrZ7hbcgpn fvavgD9dq9xwP4cAXIcYyoCC/sVBRviyzJe7T/S4iSoFAlsnpXS8tRJqPgnTRexKmSVq wxu7mrziBOZQ0AkPFVhGyD+8d2Bb1+XwKubeXhCMstOrW+QxNhi8F/m6YZz7TM65wr1G vIOICJBQmPOFN/MehkQWIzp6FZJrbelbAanHBQS1+nBEphKlNO7t2SUwYYQv17kQ9eTB KD3A== MIME-Version: 1.0 X-Received: by 10.180.37.140 with SMTP id y12mr1702668wij.50.1377012216045; Tue, 20 Aug 2013 08:23:36 -0700 (PDT) Received: by 10.194.16.5 with HTTP; Tue, 20 Aug 2013 08:23:36 -0700 (PDT) In-Reply-To: <290C776A-0A89-420E-B729-194CEDA07031@inria.fr> References: <1376312292.29133.3.camel@e130> <290C776A-0A89-420E-B729-194CEDA07031@inria.fr> Date: Tue, 20 Aug 2013 17:23:36 +0200 Message-ID: From: Florent Monnier To: Damien Doligez Cc: caml users Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: monnier.florent@gmail.com Subject: Re: [Caml-list] String.(r)index_from 2013/08/19, Damien Doligez wrote: > Hi, Hi, > Indeed, it was carefully designed this way. When you're doing > index_from s 3 '3', you're looking for the character 3 in the empty > string. OK, I do understand now that the offsets don't really point to cells but on the interval (or separations) between cells. So 0 points to the left part of the first char, and the offset = length points to the right part of the last char, but I still don't catch the logic for the functions that operates from right to left: # let s = "012";; val s : string = "012" # String.rindex_from s 0 '0' ;; - : int = 0 # String.rindex_from s (-1) '0' ;; Exception: Not_found. # String.rcontains_from s 0 '0' ;; - : bool = true # String.rcontains_from s (-1) '0' ;; Exception: Invalid_argument "String.rcontains_from". For the functions that operates from left to right, the ranges are then consistently always the same, but not for the functions that operates from right to left. -- Regards