This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aleph (1)
- # announcements (3)
- # aws (36)
- # babashka (41)
- # beginners (29)
- # cider (14)
- # clj-kondo (3)
- # clojure (154)
- # clojure-europe (8)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-serbia (1)
- # clojure-uk (133)
- # clojurescript (36)
- # cursive (15)
- # data-science (7)
- # datomic (16)
- # fulcro (34)
- # immutant (9)
- # jackdaw (5)
- # jobs (1)
- # leiningen (39)
- # off-topic (25)
- # pathom (42)
- # planck (13)
- # play-clj (1)
- # re-frame (18)
- # reagent (6)
- # reitit (3)
- # remote-jobs (1)
- # ring-swagger (16)
- # shadow-cljs (67)
- # sql (23)
- # testing (1)
- # uncomplicate (2)
- # vim (21)
- # vscode (6)
This might have already been mentioned here but I can't seem to find anything that is like the standard. I'm looking for the standard lib to connect to a db like postgres. I'm coming from C# that has Entity Framework and Elixir that has Ecto what is the Clojure equivalent?
Clojure doesn't do "ORMs" because it doesn't bother with "objects", just raw data. So you read a vector of hash maps from a database, and you insert hash maps into a database. Happy to follow up in #sql for a deep dive @jdwoodsy1
Hi, what would be an easy way to conditionally memoize-ify a
fn? I am implementing a
fn int -> int where I only want prime inputs to be memoized. Do I have to roll my own with an
@hindol.adhya That seems a pretty strange requirement but, yeah, I think you'd have to implement your own memoization function. But
clojure.core.cache might be worth looking at since you can build custom caches with it.
To be more specific, I am defining the kempner function which for a non-prime is the max of (kempner of each prime factor and its power). Memoizing composites as well will consume too much memory.
Here is where I am,
(def kempner #_(memoize) (fn ([^long x] (apply max (for [[p e] (frequencies (prime-factorize x))] (kempner p e)))) ([p e] (let [xf (comp (map second) (map prime-factorize) (map count))] (* p (inc (count (take-while #(< % e) (->> (multiples-of p) (eduction xf) (reductions +))))))))))
You could copy the implementation of memoize from Clojure, probably give it a different name, and modify it by adding your custom condition.
@hindol.adhya you could also: 1. decompose your function into calling a separate function with only prime inputs, and take another code path for the rest 2. memoize the new function that now accepts only prime inputs.
That's what I was thinking but I am not finding a good name for the inner function, :man-shrugging:
(Noob question incoming). How often in day-to-day coding do you run into situation where you forget to use (`into …` ) to convert your data structure back into what you need (map/vector/whatever)? I’m curious because it looks like a thing I’ll be forgetting to do all the time.
@peb.brzezinski it happens rarely for me, but occasionally as I was learning the language. I think one insight that helps prevent the problem is that most clojure functions aren't generic (conj and
into which is effectively
(partial reduce conj) in vanilla usage being exceptions)
:args part of an
fdef, how do I apply a spec to only the second argument (of two)?
I thought using
(s/cat :key ::key-spec) would map it based on keywording the arg name, but my understanding is wrong
I’m continuing to work through a clojure book and I just created a project using
lein new app fwdp and in core.clj I’ve got
now when I try to M-x cider-jack-in-clj I get an error
(ns fwdp.core) (defn -main "I don't do a whole lot ... yet." [& args] (println "Hello world!")) (def filename "suspects.csv")
did I make some wierd typo?
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. Exception in thread "main" Syntax error compiling at (/private/var/folders/sx/qt3tl5w958xgjdp7yt458h500000gn/T/form-init12838498358722132617.clj:4353:33). ....
^ nevermind my question. For some reason it worked after I removed
main definition ¯\(ツ)/¯
also I seem to recall recent complaints about cider startup time, there might be an issue right now(?)