From: Florent Monnier <monnier.florent@gmail.com>
To: Damien Doligez <damien.doligez@inria.fr>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] String.(r)index_from
Date: Tue, 20 Aug 2013 17:23:36 +0200 [thread overview]
Message-ID: <CAE1DttA1oCfa=+uum-qzQjTnKZFmUH1yo6ecnipc3NZUkGkzqA@mail.gmail.com> (raw)
In-Reply-To: <290C776A-0A89-420E-B729-194CEDA07031@inria.fr>
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
next prev parent reply other threads:[~2013-08-20 15:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-12 10:55 Florent Monnier
2013-08-12 12:58 ` Gerd Stolpmann
2013-08-19 18:19 ` Damien Doligez
2013-08-20 15:23 ` Florent Monnier [this message]
2013-08-20 15:53 ` Florent Monnier
2013-08-21 0:42 ` Francois Berenger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAE1DttA1oCfa=+uum-qzQjTnKZFmUH1yo6ecnipc3NZUkGkzqA@mail.gmail.com' \
--to=monnier.florent@gmail.com \
--cc=caml-list@inria.fr \
--cc=damien.doligez@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox