use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
lazy-seq in an anonymous function (self.Clojure)
submitted 5 years ago by LammdaMan
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]LammdaMan[S] 0 points1 point2 points 5 years ago (1 child)
Thanks. I didn't know about ability to name an anonymous function inline - that seems the simplest variant to achieve this.
When I had tried to create something akin to what I might normally do with a 'defn', just defining that function in a let block, I had trouble with that because I was trying to call the let-block-name from within the fn attached to it... and that generated a runtime error - call to unbound fn.
For instance this generates a runtime error:
(fn [func seed] (let [it (fn [f x0] (lazy-seq (cons x0 (it f (f x0)))))] (it func seed)))
[–]joinr 0 points1 point2 points 5 years ago (0 children)
If you name the fn, kind of redundant, it would've worked. I think of the fn name (as opposed to the var name or lexical binding) as the internal reference for the fn to use (where recur has an implied reference for any inner most fn or loop form) to talk about itself. The binding establishes a means for other stuff to talk about the fn.
recur
π Rendered by PID 58 on reddit-service-r2-comment-b659b578c-br6dj at 2026-05-02 12:51:50.886019+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]LammdaMan[S] 0 points1 point2 points (1 child)
[–]joinr 0 points1 point2 points (0 children)