https://github.com/FujiiMaika/fscd21.git
Revision ee3dc2469cc2dff1b6a00be6c96e8ce51997f219 authored by FujiiMaika on 24 June 2021, 05:34:17 UTC, committed by FujiiMaika on 24 June 2021, 05:34:17 UTC
0 parent
Raw File
Tip revision: ee3dc2469cc2dff1b6a00be6c96e8ce51997f219 authored by FujiiMaika on 24 June 2021, 05:34:17 UTC
first commit
Tip revision: ee3dc24
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