This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (8)
- # beginners (22)
- # calva (42)
- # cider (2)
- # clj-kondo (1)
- # cljdoc (3)
- # clojure (63)
- # clojure-chicago (1)
- # clojure-uk (29)
- # clojurescript (16)
- # clojureverse-ops (2)
- # core-matrix (6)
- # cursive (1)
- # datomic (23)
- # emacs (1)
- # heroku (2)
- # luminus (1)
- # off-topic (47)
- # pathom (1)
- # planck (3)
- # re-frame (4)
- # reitit (1)
- # rewrite-clj (5)
- # shadow-cljs (47)
Pretty disappointed that http://exercism.io doesn't seem to have any active Clojure mentors
@kamuela I asked about this on Reddit recently and someone who responded to a similar comment I made promptly signed up to be a mentor and approved my first exercise. So there is at least one person. But in the time between opening the thread (which was about programming challenge sites in general) that eventually led to that comment, and the approval, I lost interest in exercism.
(defn fib  (lazy-seq (cons 0 (cons 1 (map + (fib) (rest fib))))))
why is it not possible to define a lazy fibonacci sequence like this?
just a small tweak and it works - you have to put the
map which I think defaults to evaluating in chunks of 32
yup, also notice that this method is really inefficient and has to recalculate (fib) twice with each additional element
check this out 🙂
(declare fibs) (def fibs (#(list* 0N 1N (lazy-seq (map + fibs (next fibs))))))
it’s a little subtle because it’s mostly used for keeping state around when you are re-evaluating things from the repl.
When working with a DB, is it more common to pass the connection object as a arg to every function that makes db calls or to have a global connection object?
or maybe make a function that returns the connect object and call that function inside every function that makes a db call
I prefer passing the connection as an argument. I personally do lifecycle management with Stuart Sierra’s component library, which works badly with global ‘state’.
Having no global ‘state’ or connection makes testing easier too, can just mock the first argument
I think it’s more commonly idiomatic these days to pass in explicit args absent other considerations, but there is a principled minority in the
mount camp that don’t eschew storing state in vars. Among the constraints of the latter is that you’re locking yourself into only having one e.g. connection, at least at a time, which many find problematic but can be a reasonable choice for many projects.
I’m in the
component camp myself in general.