[obsidian] vault backup: 2025-12-24 11:39:01[
All checks were successful
Build / build (push) Successful in 10m37s
All checks were successful
Build / build (push) Successful in 10m37s
This commit is contained in:
@@ -186,5 +186,49 @@ persistentである時点でcode型が現れないかのチェックをする必
|
|||||||
単なる置き換えだと、includeしたファイルの定義によってその下のステージが変わってしまう可能性がある?
|
単なる置き換えだと、includeしたファイルの定義によってその下のステージが変わってしまう可能性がある?
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
[[OCaml]]で書いてみてる
|
||||||
|
|
||||||
|
```ocaml
|
||||||
|
type expr = NumLit of float
|
||||||
|
| Var of string
|
||||||
|
| App of expr * expr
|
||||||
|
| Lam of string * expr
|
||||||
|
| Delay of int * expr * expr
|
||||||
|
| Feed of string * expr
|
||||||
|
| Quote of expr
|
||||||
|
| Splice of expr
|
||||||
|
| Tuple of expr list
|
||||||
|
| Proj of expr * int
|
||||||
|
type bound = string * value
|
||||||
|
and env = bound list
|
||||||
|
and value = Real of float
|
||||||
|
| OpenFn of string * expr * int
|
||||||
|
| Closure of string * expr * env
|
||||||
|
| Code of expr
|
||||||
|
type state = float list
|
||||||
|
type stage = int
|
||||||
|
type stateptr = int
|
||||||
|
|
||||||
|
let lookup: string->env->value =
|
||||||
|
fun name env -> let finder = fun (n,v) -> n == name in
|
||||||
|
let (_n,v) = List.find finder env in
|
||||||
|
v
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let rec contain_freevars: string -> expr -> env -> bool =
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
let rec eval : stage -> expr -> env ->value =
|
||||||
|
fun stage e env -> match e with
|
||||||
|
| NumLit(n) -> Real(n)
|
||||||
|
| Var(name)-> lookup name env
|
||||||
|
|
|
||||||
|
|_ -> raise (Failure "not implemented yet")
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user