If I have two variables, for example
(define x 10)
(define y 20)
And I want to create a new variable, using the values of x and y to create the name, how would I go about doing so?
For example let's say I want to make a new variable called variable-x-y
(define variable-x-y "some-value")
In this case, x would be 10 and y would be 20.
Basically to summarize everything, I want to be able to enter variable-10-20 and have it return "some-value"
I'm sorry if this sounds like a novice question. I'm quite new to Racket.
EDIT: Also, how would I go about retrieving the values if just given the values of x and y (within the program)?
For example, let's say that somehow I was able to define the following:
(define variable-10-20 "some-value")
(define x 10)
(define y 20)
Is there a way for me to write variable-x-y and get back "some-value"?
EDIT 2 Here is the simplified code of what I'm trying to implement. What it does is it recursively reads each individual element into a local variable which can then be used after it's all been "read in". I'm sure if you tweak the code using the method found here it should work just fine.
(define (matrix->variables matrix)
(local [(define (matrix2->variables/acc matrix2 x y)
(cond
[;; the entire matrix has "extracted" it's elements into variables
(empty? matrix2)
#|This is where the main program goes for using the variables|#]
[;; the first row has "extracted" it's elements into variables
(empty? (first matrix2))
(matrix2->variables/acc (rest matrix2) 0 (add1 y))]
[else (local [(define element-x-y "some-value")]
;; Here is where I got stuck since I couldn't find a way to
;; name the variable being created (element-x-y)
(matrix2->variables/acc
(cons (rest (first matrix2)) (rest matrix2))
(add1 x) y))]))]
(matrix2->variables/acc matrix 0 0)))