0
votes

I am trying to define a kind of dataset for an exercise I was asked to do. This is the code:

#lang racket
(
 (
  (pers(sol nub lluv))
  (tmp numeric)
  (hum numeric)
  (vin (yes no))
  (class (+ -))
  )

 ;Instances
(sol 30 40 no +)
(lluv 24 70 yes -)
(sol 20 80 no +)
)

The problem is when I run this code I get the following message:

pers: unbound identifier in module in: pers

Do I have to define the identifiers in a different way?

Thanks for your answers!

1
And what's pers supposed to be? in the above code there's nothing named pers, hence the error. In fact, none of the lines in the above code seem right, it'll keep failing. Time to go back to the drawing board, and start from the beginning.Óscar López
I answered below. I wanted to go further and run this FILE, which was not the aim of the exercise. That's why it looks bad. Thanks for...helping???Eka

1 Answers

0
votes

Well, actually it is a file so there's no need to write "#lang racket". The thing is that I thought I had to run it but it was ok like that according to the exercise.

The next exercise was to read it and the code was the following:

#lang racket
(define (read-file filename)
(define datafile (with-input-from-file filename read))
datafile
)

;Store file info in a variable
(define fileinfo (read-file "filewithinfo.scm"))

So after running that, on console I could write "fileinfo" to display the file information, which was:

 >fileinfo

'(((pers (sol nub lluv)) (tmp numeric) (hum numeric) (vin (yes no)) (class (+ -))) (sol 30 40 no +) (lluv 24 70 yes -) (sol 20 80 no +))

More info: https://en.wikibooks.org/wiki/Scheme_Programming/Input_and_Output