On Thu, 22 Dec 2016 18:35:24 +0100
Pino Toscano <ptoscano(a)redhat.com> wrote:
On Sunday, 18 December 2016 23:16:31 CET Tomáš Golembiovský wrote:
> Added two new optional arguments to nsplit:
>
> * noempty: if set to false empty elements are not stored in the returned
> list. The default is to keep the empty elements
>
> * count: specifies how many splits to perform; negative count
> (the default) means do as many splits as possible
>
> Added tests for nsplit.
>
> Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
> ---
> mllib/common_utils.ml | 12 +++++++++---
> mllib/common_utils.mli | 12 ++++++++++--
> mllib/common_utils_tests.ml | 26 ++++++++++++++++++++++++++
> 3 files changed, 45 insertions(+), 5 deletions(-)
>
> diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
> index f948dce..b6f3046 100644
> --- a/mllib/common_utils.ml
> +++ b/mllib/common_utils.ml
> @@ -130,15 +130,21 @@ module String = struct
> done;
> if not !r then s else Bytes.to_string b2
>
> - let rec nsplit sep str =
> + let rec nsplit ?(noempty = true) ?(count = -1) sep str =
Shouldn't the default value of noempty be false, matching the current
behaviour, and the documentation added?
'true' means to keep the empty elements. The name is probably confusing.
Tomas
--
Tomáš Golembiovský <tgolembi(a)redhat.com>