0

how to calculate the GPA in clips after reading from the file the file is: a 10 9 13 7

b 12 3 10 14

c 8 10 12 10

d 15 8 14 9

output: a (10 9 13 7) 9.75

b (12 3 10 14) 9.75

foloo
  • 1
  • 3

1 Answers1

0

Use the open function to open the file. You can use the readline function to grab a line of data and then use the explode$, nth$, and rest$ functions to grab the name and list of grades. Here's an example reading from standard input rather than a file:

         CLIPS (6.4 2/9/21)
CLIPS> (bind ?i (readline))
a 10 9 13 7
"a 10 9 13 7"
CLIPS> (bind ?i (explode$ ?i))
(a 10 9 13 7)
CLIPS> (nth$ 1 ?i)
a
CLIPS> (bind ?grades (rest$ ?i))
(10 9 13 7)
CLIPS>
Gary Riley
  • 10,130
  • 2
  • 19
  • 34