gltestb.psl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. (glispobjects
  2. (circle (list (start vector) (radius real) (color atom))
  3. prop ((pi (3.14159265))
  4. (diameter (2*radius))
  5. (circumference (pi*diameter))
  6. (area (pi*radius^2)))
  7. adj ((big (area>100))
  8. (small (area<80)))
  9. msg ((grow (area_+100))
  10. (shrink (area_area/2))
  11. (standard (area_100))) )
  12. (student (atom (proplist (name string)
  13. (sex atom)
  14. (major atom)
  15. (grades (listof integer))))
  16. prop ((average student-average)
  17. (grade-average student-grade-average))
  18. adj ((male (sex='male))
  19. (female (sex='female))
  20. (winner (average>=95))
  21. (loser (average<60)))
  22. isa ((winner (self is winner))))
  23. (student-group (listof student)
  24. prop ((n-students length)
  25. (average student-group-average)))
  26. (class (atom (proplist (department atom)
  27. (number integer)
  28. (instructor string)
  29. (students student-group)))
  30. prop ((n-students (students:n-students))
  31. (men ((those students who are male)) result student-group)
  32. (women ((those students who are female)) result student-group)
  33. (winners ((those students who are winner)) result student-group)
  34. (losers ((those students who are loser)) result student-group)
  35. (class-average (students:average))))
  36. )
  37. (dg student-average (s:student)
  38. (prog ((sum 0.0)(n 0.0))
  39. (for g in grades do n _+ 1.0 sum_+g)
  40. (return sum/n) ))
  41. (dg student-grade-average (s:student)
  42. (prog ((av s:average))
  43. (return (if av >= 90.0 then 'a
  44. elseif av >= 80.0 then 'b
  45. elseif av >= 70.0 then 'c
  46. elseif av >= 60.0 then 'd
  47. else 'f))))
  48. (dg student-group-average (sg:student-group)
  49. (prog ((sum 0.0)(n 0.0))
  50. (for s in sg do sum_+s:average n _+ 1.0)
  51. (return sum/n) ))
  52. (dg test1 (c:class)
  53. (for s in c:students (prin1 s:name)
  54. (prin2 '! )
  55. (prin1 s:grade-average) (terpri)))
  56. (dg test2 (c:class)
  57. (for s in c:winners (prin1 s:name)
  58. (prin2 '! )
  59. (prin1 s:average) (terpri)))
  60. (dg test3 (c:class)
  61. c:men:average)
  62. (dg test4 (c:class)
  63. (for s in c:women when s is winner
  64. (prin1 s:name)
  65. (prin2 '! )
  66. (prin1 s:average) (terpri)))
  67. (dg test5 (c:class)
  68. (for s in c:women*c:winners
  69. (prin1 s:name)
  70. (prin2 '! )
  71. (prin1 s:average) (terpri)))
  72. (setq class1 (a class with instructor = "G. Novak" department = 'cs
  73. number = 102 students = (list
  74. (a student with name = "John Doe" sex = 'male major = 'cs
  75. grades = '(99 98 97 93))
  76. (a student with name = "Fred Failure" sex = 'male major = 'cs
  77. grades = '(52 54 43 27))
  78. (a student with name = "Mary Star" sex = 'female major = 'cs
  79. grades = '(100 100 99 98))
  80. (a student with name = "Doris Dummy" sex = 'female major = 'cs
  81. grades = '(73 52 46 28))
  82. (a student with name = "Jane Average" sex = 'female major = 'cs
  83. grades = '(75 82 87 78))
  84. (a student with name = "Lois Lane" sex = 'female major = 'cs
  85. grades = '(98 95 97 96)) )))
  86. (glispobjects
  87. (physical-object anything
  88. prop ((density (mass/volume))))
  89. (sphere anything
  90. prop ((volume ((4.0 / 3.0) * 3.1415926 * radius ^ 3))))
  91. (planet (listobject (mass real)(radius real))
  92. supers (physical-object sphere))
  93. (ordinary-object anything
  94. prop ((mass (weight / 9.88)))
  95. supers (physical-object))
  96. (parallelepiped anything
  97. prop ((volume (length*width*height))))
  98. (brick (object (length real)(width real)(height real)(weight real))
  99. supers (ordinary-object parallelepiped))
  100. (bowling-ball (atomobject (type atom)(weight real))
  101. prop ((radius ((if type='adult then 0.1 else 0.07))))
  102. supers (ordinary-object sphere))
  103. )
  104. (dg dplanet (p:planet) density)
  105. (dg dbrick (b:brick) density)
  106. (dg dbb (b:bowling-ball) density)
  107. (setq earth (a planet with mass = 5.98e24 radius = 6.37e6))
  108. (setq brick1 (a brick with weight = 20.0 width = 0.06 height = 0.04
  109. length = 0.16))
  110. (setq bb1 (a bowling-ball with type = 'adult weight = 60.0))