google / lisp-koans

Common Lisp Koans is a language learning exercise in the same vein as the ruby koans, python koans and others. It is a port of the prior koans with some modifications to highlight lisp-specific features. Structured as ordered groups of broken unit tests, the project guides the learner progressively through many Common Lisp language features.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem not solvable in special-forms.lsp

edi9999 opened this issue · comments

Altough I'm not 100% confident, it doesn't seem possible to make this test pass by just writing inside the __

(define-test write-your-own-let-statement
    "fix the let statement to get the tests to pass"
  (setf a 100)
  (setf b 23)
  (setf c 456)
  (let ((a 0)
        (b __)
        (c __))
    (assert-equal a 100)
    (assert-equal b 200)
    (assert-equal c "Jellyfish"))
  (let* ((a 0))
    (assert-equal a 121)
    (assert-equal b 200)
    (assert-equal c (+ a (/ b a)))))

Well, it's named "write-your-own-let-statement", so maybe it's the whole point. It's the koans after all.

@edi9999
I don't get the point. This test is confusing.

@bileschi @edi9999 @tryer3000 Difference between let and let* is that let* performs binding sequentially; you can use names being bound directly inside bindings. More interesting let* form would be something like this:

(let* ((a (+ 98 b))
       (b (- __ a)) ; correct value for __ is 321
       (c (+ a (/ b a)))
  (assert-equal a 121)
  (assert-equal b 200)
  (assert-equal c (+ a (/ b a))))

In binding for a an old value of b is used. In binding for b a new value of a is used. In binding for c only new bindings are being used.