Revision c2307351f20b1ed3d8532d0db1ec9ece6c6fb8b8 authored by Maika Fujii on 24 June 2021, 05:54:25 UTC, committed by GitHub on 24 June 2021, 05:54:25 UTC
1 parent 583c7de
Raw File
env.ml
type 'a t = 'a list

let empty = []

(* exceptions *)
exception UnboundVariable

(* offset : string -> xs -> int *)
let offset x xs =
  let rec loop xs n = match xs with
      [] -> raise UnboundVariable
    | first :: rest -> if x = first then n else loop rest (n + 1)
  in
  loop xs 0
back to top