Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That second <code>(list ...)</code> in your <code>else</code> clause is what's screwing you up. It's nesting each successive call deeper and deeper. The recursion will naturally create the list; you don't need to wrap it again.</p> <p>Try:</p> <pre><code>(define get-ivars (λ (ivars num) (if (null? ivars) '() (cons (list (car ivars) `(nth args ,num)) (get-ivars (cdr ivars) (+ num 1)))))) </code></pre> <p>Regarding the <code>get-ivars</code> caller code, the parentheses surrounding the unquoted call to <code>get-ivars</code> are what's giving you the trouble you mention in the comments. With them, this code:</p> <pre><code>`(define ClassName (lambda (args) (let (,(get-ivars '(iVar1 iVar2 iVar3) 1)) ;; your method-getting code ))) </code></pre> <p>Gives you this:</p> <pre><code>(define ClassName (lambda (args) (let (((iVar1 (nth args 1)) (iVar2 (nth args 2)) (iVar3 (nth args 3)))) ;; method-getting code ))) </code></pre> <p>Which, as you can see, gives you an extra set of parentheses around the assignments in the let.</p> <p>So you want to do this:</p> <pre><code>`(define ClassName (lambda (args) (let ,(get-ivars '(iVar1 iVar2 iVar3) 1) ;; your method-getting code ))) </code></pre> <p><code>get-ivars</code> is returning a list of lists, which is exactly what you want for the assignments in the <code>let</code>, so you don't need to wrap or (as I had it earlier) splice it. Just use the unquote on its own, and the result is:</p> <pre><code>(define ClassName (lambda (args) (let ((iVar1 (nth args 1)) (iVar2 (nth args 2)) (iVar3 (nth args 3))) ;; method-getting code ))) </code></pre> <p>Which should do the trick.</p> <p>Incidentally, I found it helpful to leave off the <code>eval</code> when I was playing around with this; one can then visually inspect the result to make sure its syntax is okay. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload