Arrays 从第二个列表中删除出现在一个数组中的字符串(如果它们存在于OCaml/ReasonML中)

Arrays 从第二个列表中删除出现在一个数组中的字符串(如果它们存在于OCaml/ReasonML中),arrays,filter,ocaml,reason,Arrays,Filter,Ocaml,Reason,我必须创建如下所示的日期数组: let slots = [| "2014-08-11T10:00:00-04:00", "2014-08-11T10:30:00-04:00", "2014-08-11T11:00:00-04:00", "2014-08-11T11:30:00-04:00", "2014-08-11T12:00:00-04:00", "2014-08-11T12:30:00-04:00", "2014-08-11T13:00:00-04:00" |];

我必须创建如下所示的日期数组:

let slots = [|
  "2014-08-11T10:00:00-04:00",
  "2014-08-11T10:30:00-04:00",
  "2014-08-11T11:00:00-04:00",
  "2014-08-11T11:30:00-04:00",
  "2014-08-11T12:00:00-04:00",
  "2014-08-11T12:30:00-04:00",
  "2014-08-11T13:00:00-04:00"
|];
let badSlots = [|
  "2014-08-11T11:00:00-04:00",
  "2014-08-11T11:30:00-04:00",
  "2014-08-11T12:00:00-04:00",
|];
我如何从第一个数组中删除出现在第二个数组中的项,以便得到以下结果:

result [
  '2014-08-11T10:00:00-04:00',
  '2014-08-11T10:30:00-04:00',
  '2014-08-11T12:30:00-04:00',
  '2014-08-11T13:00:00-04:00'
]
到目前为止,我已经尝试了这个理由,似乎找到了匹配,但结果格式是完全错误的

let checkBool = s => Belt.Array.map(badSlots, bs => s !== bs);
let check = s =>
  Belt.Array.keepMap(badSlots, bs =>
    if (s !== bs) {
      Some(s);
    } else {
      None;
    }
  );
let checkBoolResult = Belt.Array.map(slots, s => checkBool(s));
Js.log2("checkBoolResult", checkBoolResult);
let checkResult = Belt.Array.keepMap(slots, s => Some(check(s)));
Js.log2("checkResult", checkResult);

哪些日志:

checkBoolResult [
  [ true, true, true ],
  [ true, true, true ],
  [ false, true, true ],
  [ true, false, true ],
  [ true, true, false ],
  [ true, true, true ],
  [ true, true, true ]
]
checkResult [
  [
    '2014-08-11T10:00:00-04:00',
    '2014-08-11T10:00:00-04:00',
    '2014-08-11T10:00:00-04:00'
  ],
  [
    '2014-08-11T10:30:00-04:00',
    '2014-08-11T10:30:00-04:00',
    '2014-08-11T10:30:00-04:00'
  ],
  [ '2014-08-11T11:00:00-04:00', '2014-08-11T11:00:00-04:00' ],
  [ '2014-08-11T11:30:00-04:00', '2014-08-11T11:30:00-04:00' ],
  [ '2014-08-11T12:00:00-04:00', '2014-08-11T12:00:00-04:00' ],
  [
    '2014-08-11T12:30:00-04:00',
    '2014-08-11T12:30:00-04:00',
    '2014-08-11T12:30:00-04:00'
  ],
  [
    '2014-08-11T13:00:00-04:00',
    '2014-08-11T13:00:00-04:00',
    '2014-08-11T13:00:00-04:00'
  ]
]

任何语法方面的指导都将不胜感激。谢谢。

通过reason discord论坛:

此解决方案的工作原理是:

let x = Js.Array.filter(x => !Array.mem(x, badSlots), slots);

//output
x [
  '2014-08-11T10:00:00-04:00',
  '2014-08-11T10:30:00-04:00',
  '2014-08-11T12:30:00-04:00',
  '2014-08-11T13:00:00-04:00'
]