package ppx_deriving_madcast

  1. Overview
  2. Docs
Library deriving cast functions based on their types

Install

Dune Dependency

Authors

Maintainers

Sources

v0.2.tar.gz
md5=bca83dbf5a6fb47ced07756c6cab1d9a
sha512=f2f604685649d8fc0c750adfb89d997ea62f2fd09f383dc38b4580fdbb7f96e45a637745f1f06aa1b529d6abcfea6691ef309eb32e423c780c2370aff4678950

doc/src/ppx_deriving_madcast.api/extList.ml.html

Source file extList.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

let foldi_left f x l =
  snd (
      List.fold_left
        (fun (i, x) e ->
          (i+1, f i x e))
        (0, x) l
    )

let foldi_right f l x =
  snd (
      List.fold_right
        (fun e (i, x) ->
          (i-1, f i e x))
        l
        (List.length l - 1, x)
    )

let rec bd = function
  | [] -> failwith "bd"
  | [_] -> []
  | h ::q -> h :: bd q

let rec ft = function
  | [] -> failwith "ft"
  | [e] -> e
  | _ :: q -> ft q
OCaml

Innovation. Community. Security.