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@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? The rest of the changes (implementation and unit tests) LGTM. Thanks, -- Pino Toscano