// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

var Caml_obj = require("bs-platform/lib/js/caml_obj.js");
var Pervasives = require("bs-platform/lib/js/pervasives.js");

function range(param) {
  var u = param[1];
  var l = param[0];
  if (l > u) {
    return /* [] */0;
  } else if (l === u) {
    return {
            hd: u,
            tl: /* [] */0
          };
  } else {
    return {
            hd: l,
            tl: range([
                  l + 1 | 0,
                  u
                ])
          };
  }
}

function inRange(param, x) {
  if (Caml_obj.caml_lessequal(param[0], x)) {
    return Caml_obj.caml_lessequal(x, param[1]);
  } else {
    return false;
  }
}

function index(p, x) {
  if (inRange(p, x)) {
    return x - p[0] | 0;
  }
  throw Pervasives.invalid_arg("Ix.index: Index out of range.");
}

function rangeSize(param) {
  var u = param[1];
  var l = param[0];
  if (l <= u) {
    return (u - l | 0) + 1 | 0;
  } else {
    return 0;
  }
}

exports.range = range;
exports.inRange = inRange;
exports.index = index;
exports.rangeSize = rangeSize;
/* No side effect */
