File: list1.ml

package info (click to toggle)
janest-base 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,896 kB
  • sloc: ml: 37,596; ansic: 251; javascript: 114; makefile: 21
file content (19 lines) | stat: -rw-r--r-- 347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
open! Import
include List0

let is_empty = function
  | [] -> true
  | _ -> false
;;

let partition_map t ~f =
  let rec loop t fst snd =
    match t with
    | [] -> rev fst, rev snd
    | x :: t ->
      (match (f x : _ Either0.t) with
       | First y -> loop t (y :: fst) snd
       | Second y -> loop t fst (y :: snd))
  in
  loop t [] []
;;