title: Racket language: How to convert string to variable-name
body: <p>I am pretty new in Racket and I have tried to run <a href="https://stackoverflow.com/users/13/chris-jester-young">Chris Jester-Young</a>'s solution (<a href="https://stackoverflow.com/questions/21176956/how-to-convert-string-to-variable-name-in-scheme">How to convert string to variable-name in scheme</a>) to convert string to variable name (and its converse, in other words, conversing variable name to string):</p>
  
  <pre><code>#lang racket
  (define-syntax string-&gt;variable-name
     (lambda (stx)
     (syntax-case stx ()
       ((_ str)
         (string? (syntax-&gt;datum #'str))
           (datum-&gt;syntax #'str (string-&gt;symbol (syntax-&gt;datum #'str)))))))
  
  (define-syntax variable-name-&gt;string
    (lambda (stx)
      (syntax-case stx ()
      ((_ id)
         (identifier? #'id)
           (datum-&gt;syntax #'id (symbol-&gt;string (syntax-&gt;datum #'id)))))))
  </code></pre>
  
  <p>It was fine for <code>variable-name-&gt;string</code>, here an example:</p>
  
  <pre><code>&gt;(define myvar 10)
  &gt;(variable-name-&gt;string myvar)
    "myvar"
  </code></pre>
  
  <p>However, I had no success with <code>string-&gt;variable-name</code>:</p>
  
  <pre><code>&gt;(define (string-&gt;variable-name "myvar2") 4)
      error define: not an identifier, identifier with default, or keyword
      for procedure argument in: "myvar2"
  </code></pre>
  
  <p>I am using <a href="https://racket-lang.org/" rel="nofollow noreferrer">Racket</a> 6.6, linux mint 17.3 64bits.</p>
  
  <p>My main goal is how to convert a string to a variable name (identifier).</p>
  
  <p>I was wondering:</p>
  
  <ol>
  <li>to read a text file;</li>
  <li>to get the name of the variables (string) from that text file; and</li>
  <li>to use <code>define</code> to set the variable names with random integers.</li>
  </ol>
  
  <p>Any help I will appreciate.</p>