package minicaml
A simple, didactical, purely functional programming language
Install
Dune Dependency
Authors
Maintainers
Sources
minicaml-0.2.tbz
sha256=66a32a213ce6f668337b1f20d480971cc3532c10dd17c7e28407654278676715
sha512=f7208758c6867c59d74c60d4ad715fe0846ad62d8e4b23f707c13ebdc438826c049df094c9eb67141f84d9ff6dc1be2efb80c41d3225f7fcd005443b30947dd0
doc/src/minicaml/env.ml.html
Source file env.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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
open Types (** Function to generate an empty environment *) let empty_env : unit -> env_type = fun _ -> [] (** Search for a key in an environment (a (string, value) pair) *) let rec lookup (env : env_type) (ident : ide) : evt = if ident = "" then failwith "invalid identifier" else match env with | [] -> raise (UnboundVariable ident) | (i, e) :: env_rest -> if ident = i then e else lookup env_rest ident (** Bind a value to an identifier, returning an environment *) let bind (env: env_type) (ident: ide) (value: evt) : env_type = (ident, value) :: env (** Bind a list of identifiers to a list of values, returning an environment *) let rec bindlist (env: env_type) (ident_list: ide list) (value_list: evt list) : env_type = match (ident_list, value_list) with | ([], []) -> env | (i::ident_rest, v::value_rest) -> bindlist (bind env i v) ident_rest value_rest | _ -> raise WrongBindList (* Non-functional environment (* the empty environment *) let empty_env : unit -> env_type = fun _ -> Hashtbl.create 1000 (* Simple but naive environment lookup *) let lookup (env : env_type) (ident : ide) : expr = if ident = "" then failwith "invalid identifier" else Hashtbl.find env ident (* Bind an identifier to a value *) let bind (env : env_type) (ident : ide) (value: expr) : unit = if ident = "" then failwith "invalid identifier" else Hashtbl.add env ident value let rec bindlist (env : env_type) (ident_list : ide list) (value_list: expr list) : unit = match (ident_list, value_list) with | ([], []) -> () | (ident::ident_rest, value::value_rest) -> bind env ident value; bindlist env ident_rest value_rest | _ -> raise WrongBindList *)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>