Skip to content

Commit 1c69a5a

Browse files
committed
crook
1 parent 066b56f commit 1c69a5a

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

iniquity-plus/env.rkt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#lang racket
2+
(provide lookup ext)
3+
4+
;; Env Variable -> Answer
5+
(define (lookup env x)
6+
(match env
7+
['() 'err]
8+
[(cons (list y i) env)
9+
(match (symbol=? x y)
10+
[#t i]
11+
[#f (lookup env x)])]))
12+
13+
;; Env Variable Value -> Value
14+
(define (ext r x i)
15+
(cons (list x i) r))
16+

iniquity-plus/interp.rkt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
(provide interp-env)
44
(require "ast.rkt")
55
(require "interp-prim.rkt")
6+
(require "env.rkt")
67

78
;; type Value =
89
;; | Integer
@@ -142,15 +143,3 @@
142143
(cons (list x y)
143144
(zip xs ys))]))
144145

145-
;; Env Id -> Value
146-
(define (lookup r x)
147-
(match r
148-
[(cons (list y val) r)
149-
(if (symbol=? x y)
150-
val
151-
(lookup r x))]))
152-
153-
;; Env Id Value -> Env
154-
(define (ext r x v)
155-
(cons (list x v) r))
156-

knock-plus/env.rkt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#lang racket
2+
(provide lookup ext)
3+
4+
;; Env Variable -> Answer
5+
(define (lookup env x)
6+
(match env
7+
['() 'err]
8+
[(cons (list y i) env)
9+
(match (symbol=? x y)
10+
[#t i]
11+
[#f (lookup env x)])]))
12+
13+
;; Env Variable Value -> Value
14+
(define (ext r x i)
15+
(cons (list x i) r))
16+

knock-plus/interp.rkt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(provide interp-match-pat)
55
(require "ast.rkt")
66
(require "interp-prim.rkt")
7+
(require "env.rkt")
78

89
;; type Value =
910
;; | Integer
@@ -167,15 +168,3 @@
167168
(cons (list x y)
168169
(zip xs ys))]))
169170

170-
;; Env Id -> Value
171-
(define (lookup r x)
172-
(match r
173-
[(cons (list y val) r)
174-
(if (symbol=? x y)
175-
val
176-
(lookup r x))]))
177-
178-
;; Env Id Value -> Env
179-
(define (ext r x v)
180-
(cons (list x v) r))
181-

0 commit comments

Comments
 (0)