You seem to have the correct understanding, it's just not how the lazy-seq function works here is a typical example:
user> (lazy-seq (cons 4 (range 5))) (4 0 1 2 3 4)
lazy-seq almost always takes a cons statement, where the first argument is the first element in the sequence, and the second argument is the code to compose the rest of the list. Faithful people rarely have to use lazy-seq directly on Clojure day, using forms like map reduce , filter , etc. much more common.
the code in the function to create the rest of the sequence also contains to be able to compile, in your case you can also delay compilation using eval , although I would recommend not using eval for such things in code that needs to be read by others; does for a lot of learning though; -)
user> (def myvar (lazy-seq (cons 1 (eval '(prn undefined-var))))) ; don't do this at work #'user/myvar user> myvar ; Evaluation aborted. user>
source share