Skip to content

Latest commit

 

History

History
828 lines (750 loc) · 18.8 KB

Tutor Results.md

File metadata and controls

828 lines (750 loc) · 18.8 KB

1. scope1::warmup_defvar

(defvar x 1)
(defvar y (+ x 2))
x
y
  • (.98 = 99/101) 1 3
  • (.01 = 1/101) 1 2
  • (.01 = 1/101) error

2. scope1::warmup_error

(defvar xyz 173)
abc
  • (.98 = 98/100) error
  • (.01 = 1/100) 173
  • (.01 = 1/100) possibly abc

3. scope1::warmup_fun

(deffun (sum x y z)
  (+ x (+ y z)))
(sum 2 1 3)
  • (.99 = 100/101) 6
  • (.01 = 1/101) 5

4. scope1::local_def_is_possible

(deffun (addy x)
  (defvar y 1)
  (+ x y))
(addy 2)
  • (.97 = 98/101) 3
  • (.03 = 3/101) error

5. scope1::refer_global_is_possible

(defvar y 1)
(deffun (addy x)
  (+ x y))
(addy 2)
  • (.77 = 79/102) 3
  • (.23 = 23/102) error [IsolatedFun]

6. scope1::defs_are_recursive

(deffun (addy x)
  (+ x y))
(defvar y 1)
(addy 2)
  • (.67 = 68/101) error [DeepClosure, IsolatedFun, NestedDef]
  • (.32 = 32/101) 3
  • (.01 = 1/101) 2

7. scope1::shadow_or_overwrite

(defvar y 100)
(deffun (addy x)
  (defvar y 200)
  (+ x y))
(addy 2)
  • (.91 = 92/101) 202
  • (.05 = 5/101) 102
  • (.04 = 4/101) error

8. scope1::shadow_rather_than_overwrite

(defvar y 100)
(deffun (addy x)
  (defvar y 200)
  (+ x y))
(+ (addy 2) y)
  • (.93 = 95/102) 302
  • (.06 = 6/102) 402 [FlatEnv]
  • (.01 = 1/102) error

9. scope1::error_when_refer_to_undefined

(deffun (addy x)
  (defvar y 200)
  (+ x y))
(+ (addy 2) y)
  • (.96 = 98/102) error
  • (.04 = 4/102) 402 [FlatEnv]

10. scope1::what_is_x_1

(defvar x 1)
(deffun (main)
  (defvar x 2)
  (deffun (get-x) x)
  (get-x))

(main)
  • (.85 = 85/100) 2
  • (.09 = 9/100) error [IsolatedFun]
  • (.05 = 5/100) 1
  • (.01 = 1/100) 3

11. scope1::what_is_x_2

(defvar x 1)
(deffun (get-x) x)

(deffun (main)
  (defvar x 2)
  (get-x))
(main)
  • (.70 = 71/102) 1
  • (.29 = 30/102) 2 [FlatEnv]
  • (.01 = 1/102) error [IsolatedFun]

12. scope1::what_is_x_3

(defvar x 1)
(deffun (main)
  (defvar x 2)
  (get-x))
(deffun (get-x) x)

(main)
  • (.76 = 77/101) 1
  • (.14 = 14/101) error [DeepClosure, IsolatedFun, NestedDef]
  • (.10 = 10/101) 2 [FlatEnv]

13. scope1::what_is_x_4

(defvar x 1)
(deffun (main)
  (deffun (get-x) x)
  (defvar x 2)
  (get-x))

(main)
  • (.92 = 93/101) 2
  • (.08 = 8/101) 1 [NestedDef]

14. scope1::define_twice_global

(defvar x 1)
(defvar x 2)
x
  • (.63 = 63/100) 2 [DefOrSet, NestedDef]
  • (.36 = 36/100) error
  • (.01 = 1/100) 1

15. scope1::define_twice_arg

(deffun (f x x)
  (+ x x))
(f 1 2)
  • (.92 = 92/100) error
  • (.07 = 7/100) 3
  • (.01 = 1/100) 2

16. scope2::warmup_error

(/ 1 0)
  • (.97 = 92/95) error
  • (.02 = 2/95) 1
  • (.01 = 1/95) 0

17. scope2::defvar_binding_cause_evaluation

(defvar x (/ 1 0))
42
  • (.71 = 67/95) error
  • (.29 = 28/95) 42 [Lazy]

18. scope2::funcall_binding_cause_evaluation

(deffun (f x)
  42)
(f (/ 1 0))
  • (.92 = 87/95) error
  • (.08 = 8/95) 42 [Lazy]

19. scope2::good_order

(defvar x 1)
(defvar y (+ x 2))
x
y
  • (.99 = 93/94) 1 3
  • (.01 = 1/94) error

20. scope2::bad_order

(defvar y (+ x 2))
(defvar x 1)
x
y
  • (.57 = 54/95) 1 3 [Lazy]
  • (.43 = 41/95) error

21. scope2::order_and_funcall_warmup

(deffun (getx)
  x)
(defvar x 12)
(defvar y (getx))
y
  • (.76 = 72/95) 12
  • (.24 = 23/95) error [DeepClosure, IsolatedFun, NestedDef]

22. scope2::order_and_funcall_1

(deffun (getx)
  x)
(defvar y (getx))
(defvar x 12)
y
  • (.63 = 60/95) error
  • (.37 = 35/95) 12 [Lazy]

23. scope2::order_and_funcall_2

(defvar x 2)
(deffun (main)
  (deffun (getx)
    x)
  (defvar y (getx))
  (defvar x 3)
  y)

(main)
  • (.60 = 56/94) 2 [DefOrSet, NestedDef]
  • (.28 = 26/94) error
  • (.13 = 12/94) 3 [Lazy]

24. mut-vars1::scope_review_1

(defvar x 0)
(defvar y x)
(defvar x 2)
x
y
  • (.86 = 78/91) error
  • (.13 = 12/91) 2 0 [DefOrSet, NestedDef]
  • (.01 = 1/91) 2 2

25. mut-vars1::scope_review_2

(deffun (foo)
  y)
(defvar y 1)
(foo)
  • (.81 = 74/91) 1
  • (.19 = 17/91) error [DeepClosure, IsolatedFun, NestedDef]

26. mut-vars1::scope_review_3

(defvar x 1)
(deffun (gety)
  (defvar y x)
  (defvar x 2)
  y)
(gety)
  • (.65 = 59/91) error
  • (.30 = 27/91) 1 [DefOrSet, NestedDef]
  • (.05 = 5/91) 2 [Lazy]

27. mut-vars2::warmup_setbang

(defvar rent 100)
(set! rent (* 100 2))
rent
  • (.99 = 91/92) 200
  • (.01 = 1/92) 2000

28. mut-vars2::update_undefined

(set! foobar 2)
foobar
  • (.85 = 79/93) error
  • (.15 = 14/93) 2 [DefOrSet]

29. mut-vars2::not_aliased_by_defvar_1

(defvar x 12)
(defvar y x)
(set! x 0)
x
y
  • (.85 = 79/93) 0 12
  • (.12 = 11/93) 0 0 [DefByRef]
  • (.02 = 2/93) error
  • (.01 = 1/93) depends on implementation

30. mut-vars2::not_aliased_by_defvar_2

(defvar m 40)
(defvar n m)
(set! n 22)
m
n
  • (.99 = 92/93) 40 22
  • (.01 = 1/93) 40 11

31. mut-vars2::not_aliased_by_defvar_3

(defvar x 1)
(defvar y (+ x 100))
(set! x 2)
x
y
  • (.99 = 92/93) 2 101
  • (.01 = 1/93) 2 102

32. mut-vars2::remote_update_possible

(defvar x 12)
(deffun (f)
  (set! x 0))
(f)
x
  • (.89 = 83/93) 0
  • (.05 = 5/93) 12 [DeepClosure, DefOrSet]
  • (.05 = 5/93) error [IsolatedFun]

33. mut-vars2::not_aliased_by_funarg_1

(defvar x 12)
(deffun (f x)
  (set! x 0))
(f x)
x
  • (.52 = 48/93) 12
  • (.41 = 38/93) 0 [CallByRef, FlatEnv]
  • (.08 = 7/93) error

34. mut-vars2::funs_remember_vars_not_vals

(defvar x 1)
(deffun (getx)
  x)
(deffun (setx new-val)
  (set! x new-val))
(getx)
(setx 2)
(getx)
  • (.78 = 73/93) 1 2
  • (.20 = 19/93) 1 1 [DeepClosure, DefOrSet]
  • (.01 = 1/93) 1 2 1

35. mut-vars2::not_aliased_by_funarg_2

(defvar x 12)
(deffun (set-and-return y)
  (set! y 0)
  x)
(set-and-return x)
  • (.78 = 73/93) 12
  • (.11 = 10/93) error [IsolatedFun]
  • (.10 = 9/93) 0 [CallByRef]
  • (.01 = 1/93) 23

36. mut-vars2::not_aliased_by_funarg_3

(defvar x 12)
(deffun (set-and-return y)
  (set! x 0)
  y)
(set-and-return x)
x
  • (.80 = 74/92) 12 0
  • (.07 = 6/92) 12 12 [DeepClosure, DefOrSet]
  • (.07 = 6/92) error [IsolatedFun]
  • (.03 = 3/92) 0 0 [CallByRef]
  • (.03 = 3/92) 12

37. vectors1::warmup_mvec

(defvar n 3)
(deffun (f x)
  (+ x 1))
(mvec n (f n))
  • (.97 = 89/92) #(3 4)
  • (.02 = 2/92) error
  • (.01 = 1/92) #(n (f n))

38. vectors1::vec_hetero

(mvec (mvec 1 2) 3)
  • (.96 = 88/92) #(#(1 2) 3)
  • (.02 = 2/92) error
  • (.01 = 1/92) #(#(1 2) #(3))
  • (.01 = 1/92) #(#(3 1) 2)

39. vectors1::vec_print

(mvec (mvec 123) (mvec 4 5))
  • (.91 = 84/92) #(#(123) #(4 5))
  • (.05 = 5/92) #('#(123) '#(4 5))
  • (.02 = 2/92) error
  • (.01 = 1/92) #('#(231) '#(4 5))

40. vectors1::warmup_veclen

(defvar v (mvec 1 2 3 4))
(vec-len v)
  • (.99 = 90/91) 4
  • (.01 = 1/91) error

41. vectors1::veclen_nested

(vec-len (mvec 4 (mvec 5 6)))
  • (.95 = 86/91) 2
  • (.03 = 3/91) 3
  • (.01 = 1/91) 1
  • (.01 = 1/91) error

42. vectors1::warmup_vecref

(defvar v (mvec (mvec 10 20) (mvec 30 40)))
(vec-ref (vec-ref v 1) 0)
  • (.81 = 74/91) 30
  • (.11 = 10/91) 10
  • (.04 = 4/91) 20
  • (.02 = 2/91) error
  • (.01 = 1/91) 1

43. vectors1::warmup_vecset_1

(defvar x (mvec 2 3))
(vec-set! x 0 100)
x
  • (.87 = 79/91) #(100 3)
  • (.13 = 12/91) 100 3

44. vectors1::warmup_vecset_2

(defvar x (mvec 2))
(vec-set! x 0 100)
x
  • (.97 = 88/91) #(100)
  • (.03 = 3/91) 100

45. vectors1::mpairs_are_mvec

(defvar mv (mvec 4 5))
(left mv)
  • (.87 = 79/91) 4
  • (.13 = 12/91) error

46. vectors1::vector_not_flatten

(defvar m (mvec 1 2))
(vec-set! m 1 (mvec 3 4))
(vec-ref m 2)
  • (.93 = 84/90) error
  • (.02 = 2/90) 2
  • (.02 = 2/90) 4
  • (.01 = 1/90) #(3 4)
  • (.01 = 1/90) 3

47. vectors2::alias_with_defvar

(defvar x (mvec 100))
(defvar y x)
(vec-set! x 0 200)
y
  • (.67 = 62/92) #(100) [DefsCopyStructs]
  • (.30 = 28/92) #(200)
  • (.01 = 1/92) #(300)
  • (.01 = 1/92) error

48.

vectors2::alias_with_funcall

(defvar x (mvec 1 0))
(deffun (f y)
  (vec-set! y 0 173))
(f x)
x
  • (.90 = 83/92) #(173 0)
  • (.10 = 9/92) #(1 0) [CallsCopyStructs]

49. vectors2::alias_var_in_mvec

(defvar x 3)
(defvar v (mvec 1 2 x))
(set! x 4)
v
  • (.67 = 62/92) #(1 2 3)
  • (.24 = 22/92) #(1 2 4) [StructByRef]
  • (.09 = 8/92) error

50. vectors2::alias_mvec_in_mvec

(defvar x (mvec 3))
(defvar v (mvec 1 2 x))
(vec-set! x 0 4)
v
  • (.84 = 77/92) #(1 2 #(4))
  • (.14 = 13/92) #(1 2 #(3)) [DefsCopyStructs, StructsCopyStructs]
  • (.02 = 2/92) error

51. vectors2::alias_mvec_in_mvec_trick

(defvar x (mvec 3))
(defvar v (mvec 1 2 x))
(set! x 4)
v
  • (.48 = 44/92) error
  • (.43 = 40/92) #(1 2 #(3))
  • (.08 = 7/92) #(1 2 #(4))
  • (.01 = 1/92) #(1 2 3)

52. vectors2::alias_mvec_in_mpair

(defvar v (mvec 1 2 3))
(defvar vv (mpair v v))
(vec-set! (right vv) 0 100)
(left vv)
  • (.80 = 74/92) #(100 2 3)
  • (.18 = 17/92) #(1 2 3) [DefsCopyStructs]
  • (.01 = 1/92) error

53. vectors2::warmup_circularity

(defvar x (mvec 1 0 2))
(vec-set! x 1 x)
(vec-len x)
  • (.76 = 70/92) 3
  • (.14 = 13/92) error [NoCircularity]
  • (.09 = 8/92) run out of memory or time.
  • (.01 = 1/92) +inf

54. vectors2::circularity_and_alias

(defvar v (mpair 10 7))
(set-left! v v)
(set-right! v 42)
(right (left (left v)))
  • (.60 = 55/92) 42
  • (.30 = 28/92) error [NoCircularity, StructsCopyStructs]
  • (.07 = 6/92) 10
  • (.03 = 3/92) 7

55. lambda1::smol_quiz_var_as_arg

(defvar x 12)
(deffun (f x)
  (set! x 0))
(f x)
x
  • (.88 = 79/90) 12
  • (.12 = 11/90) 0 [CallByRef, FlatEnv]

56. lambda1::smol_quiz_seemingly_alias_a_var

(defvar x 5)
(deffun (set1 x y)
  (set! x y))
(deffun (set2 a y)
  (set! x y))
(set1 x 6)
x
(set2 x 7)
x
  • (.66 = 59/90) 5 7
  • (.24 = 22/90) 5 5 [DeepClosure, DefOrSet]
  • (.09 = 8/90) 6 7 [CallByRef, FlatEnv]
  • (.01 = 1/90) error

57. lambda1::smol_quiz_aliasing_mvec_in_mvec

(defvar x (mvec 1 7 3))
(defvar pr (mpair x x))
(vec-set! (right pr) 0 100)
pr
  • (.93 = 84/90) #(#(100 7 3) #(100 7 3))
  • (.07 = 6/90) #(#(1 7 3) #(100 7 3)) [DefsCopyStructs]

58. lambda1::smol_quiz_circularity

(defvar x (mvec 2 3))
(set-right! x x)
(set-left! x x)
x
  • (.63 = 57/90) #0='#(#0# #0#) ;; an mpair whose elements refer back to itself
  • (.23 = 21/90) #(#(2 3) #(2 3))
  • (.08 = 7/90) #(#(2 #(2 3)) #(2 3)) [StructsCopyStructs]
  • (.06 = 5/90) error [NoCircularity]

59. lambda1::warmup_hof

(deffun (get) 42)
(defvar f get)
(defvar g f)
(g)
  • (.99 = 88/89) 42
  • (.01 = 1/89) error [FunNotVal]

60. lambda1::fun_as_parameter

(deffun (twice f x)
  (f (f x)))
(deffun (double x)
  (+ x x))
(twice double 1)
  • (.83 = 75/90) 4
  • (.11 = 10/90) error [FunNotVal]
  • (.04 = 4/90) 2
  • (.01 = 1/90) 8

61. lambda1::fun_as_output

(deffun (add1 x) (+ x 1))
(deffun (g) add1)
(defvar f (g))
(f 100)
  • (.71 = 64/90) 101
  • (.29 = 26/90) error [FunNotVal, IsolatedFun]

62. lambda1::fun_in_vectors

(deffun (add1 n)
  (+ n 1))
(defvar v (mvec add1))
((vec-ref v 0) 2)
  • (.78 = 70/90) 3
  • (.12 = 11/90) error [FunNotVal]
  • (.08 = 7/90) 2
  • (.02 = 2/90) 1

63. lambda2::read_local1

(deffun (make-getter)
  (defvar x 1)
  (deffun (get-x) x)
  get-x)
(defvar get-x (make-getter))
(get-x)
  • (.91 = 82/90) 1
  • (.09 = 8/90) error [FunNotVal, IsolatedFun]

64. lambda2::read_local2

(deffun (make-getter x)
  (deffun (get-x) x)
  get-x)
(defvar get-a (make-getter 1))
(defvar get-b (make-getter 2))
(get-a)
(get-b)
  • (1.00 = 89/89) 1 2

65. lambda2::fun_ref_env

(deffun (make-addy y)
  (deffun (addy x)
    (+ x y))
  addy)
(defvar f (make-addy 10))
(defvar g (make-addy 50))
(f 2)
(g 2)
  • (.74 = 66/89) 12 52
  • (.25 = 22/89) error [FunNotVal, IsolatedFun]
  • (.01 = 1/89) 12 12

66. lambda2::state

(defvar x 1)
(deffun (make-f)
  (deffun (addx y)
    (+ x y))
  addx)
(defvar f (make-f))
(set! x 2)
(f x)
  • (.50 = 45/90) 4
  • (.30 = 27/90) 3 [DeepClosure]
  • (.16 = 14/90) error [FunNotVal, IsolatedFun]
  • (.04 = 4/90) 2

67. lambda2::counter

(deffun (make-counter count)
  (deffun (counter)
    (set! count (+ count 1))
    count)
  counter)
(defvar f (make-counter 0))
(defvar g (make-counter 0))

(f)
(f)
(g)
  • (.77 = 69/90) 1 2 1
  • (.11 = 10/90) 1 2 3 [FlatEnv]
  • (.08 = 7/90) 1 1 1 [DeepClosure]
  • (.01 = 1/90) 1 1 2
  • (.01 = 1/90) 2 3 2
  • (.01 = 1/90) 3 1 2
  • (.01 = 1/90) error [DefOrSet, FunNotVal, IsolatedFun]

68. lambda2::syntax_pitfall

(deffun (f a b) a + b)
(f 5 10)
  • (.58 = 52/90) 15
  • (.32 = 29/90) error [FunNotVal]
  • (.09 = 8/90) 10
  • (.01 = 1/90) 5 + 10

69. lambda3::curry_lambda

(deffun (f x)
  (lambda (y) (+ x y)))
(defvar x 0)
((f 2) 1)
  • (.94 = 85/90) 3
  • (.03 = 3/90) error [FunNotVal, IsolatedFun]
  • (.01 = 1/90) 1
  • (.01 = 1/90) 2

70. lambda3::lambda_remembers_env

(defvar x 1)
(defvar f
  (lambda (y)
    (+ x y)))
(set! x 2)
(f x)
  • (.86 = 77/90) 4
  • (.10 = 9/90) 3 [DeepClosure]
  • (.03 = 3/90) error [IsolatedFun]
  • (.01 = 1/90) lambda

71. lambda3::counter_lambda

(deffun (make-counter count)
  (lambda ()
    (set! count (+ count 1))
    count))
(defvar f (make-counter 0))
(defvar g (make-counter 0))

(f)
(f)
(g)
  • (.99 = 89/90) 1 2 1
  • (.01 = 1/90) 1 2 3 [FlatEnv]