Fork me on GitHub

I am trying to build some basic functions to manipulate polynomials. Is there a conventional way to implement a function that maps over collections but pads shorter ones with a fill value? Or just one that is perhaps more clever or concise or elegant than this? ↓ Just feel like I’m applying all over the place.


Maybe you could represent polynomials as maps rather than sequences? Then your polynomial add just becomes merge-with +


Ah, I like that. With the powers as keywords? Like (merge-with + {:0 1 :1 4 :3 19} {:1 7 :3 2 :5 3})?


don't make keywords like that


numbers are perfectly fine keys


Ah, right, with numbers as keys, I can do this:


Hi, I'm trying to use the follow java library in clojure


I added (:import [org.ahocorasick.trie Trie Emit] to my code, but I don't understand how to actually build a Trie. I tried (.builder Trie), or (-> Trie .builder) and others


@UGH9KH1DF the builder is a static method in the class and can be accessed like this: (Trie/builder)


(-> (Trie/builder) (.addKeyword "hers") ... (.build))


Thank you very much!

😄 4
Markus Åkerlund Larsson08:04:49

@jarvinenemil Thanks for the offer, thought I managed to track it down myself

👍 4

can you REPL into an already working application?


@twaima if you execute lein repl you will see smth like this:

nREPL server started on port 35043 on host - 
copy that port and lein repl :connect localhost:35043 to connect to that repl


can I have 2 REPLs into same app?


you can connect as many clients as you want to an nREPL server (within reason)


see for launching an nrepl server from within your app

👍 4

is it common to have an app in production with nREPL enabled?


it's not unheard of although I don't think it's common practice. I find it useful for debugging production issues


just don't expose it to the internet 😛


Internet would like it 😂


I'm building a toy project with Fulcro to learn clj/cljs. I'm thinking about what database to back it with. Trying out Datomic seems like to good idea to immerse myself in clojure-y thinking. The issue here is I don't really understand the difference between the free and "1 year free pro" versions. It seems the free version only has an older API that isn't recommended for use anymore. Is that accurate? What would you choose for a toy project?


For a toy project, I might consider datahike


it’s not datomic but it’s a datalog-based db like datomic is, so you’d get a lot of the “immerse myself in clojure-y thinking” bit.


Thanks for the link! Looks interesting and potentially a lot easier to set up and work with. My other option is to just go with monger as I already have a mongo database with some real world data in it. That might be a pain due to the data being designed for a different app however. In your opinion is it worth it to spend time learning datomic/datalog?


I would say so, but I’m biased in favor of learning new stuff all the time 😉


also, there’s value in learning the Mongo/Clojure interface too, so :man-shrugging:


I'm with you on the learning new stuff all the time 😀 I got started on this clojure(script) kick while searching for solutions to problems in my large typescript project


I got sucked in by Hickey's "simple made easy" talk haha


That’s one of my favorite talks.


please suggest good resources to learn core.async 🙂


tim baldridge has some youtube videos on it i think

✔️ 4

he has a great pedagogical style as well


also, this is paid but i think worth the $3 or $4 a month: He has 21 core.async videos there


Is this the best way to append an element to a sequence?

(concat sequence [element])
The confusing part for me is why there isn’t a way to append a single element to the end of a sequence so that I don’t have to wrap the element in a vector to use concat. The code I’m using this in is my implementation of map and filter defined in terms of reduce:
(defn reduce-map
  [function collection]
   (fn [accumulator element]
     (concat accumulator [(function element)]))

(defn reduce-filter
  [predicate collection]
   (fn [filtered element]
     (if (predicate element)
       (concat filtered [element])


that's basically mapv...

Lennart Buit18:04:12

yep, point taken, I’ll remove the snippet to reduce confusion!

Lennart Buit18:04:12

oh, I was actually helping :’). The question was implementing map & filter in terms of reduce


haha, OK - context!

Lennart Buit18:04:05

haha, you made me feel real stupid :’)


oh ... not trying to do that to anybody

Lennart Buit19:04:55

oh no not implying that! Nuance gets lost over the internet ^^!

Lennart Buit18:04:32

uhh yeah you are right — I was solving the question instead of the problem ^^

Lennart Buit18:04:11

so in that particular case it would be (mapv (fn [element] (function element)) collection). That said, its still valuable to know that conj uses the most sensible insertion order.


Slack usage/code of conduct question, if there is a subject specific channel but it is very infrequently in use, should you still wait for responses there or can you ping the main clojure or this channel with one off questions


I know I've found out about some channels because people posted "Hey, I have a question about Fooness over in the #fooness channel, could someone have a look?"


I wouldn't cut and paste the question back into the main channel because sometimes that fragments the discussion and makes it hard to follow, but that may be just a personal preference.


But I think a brief ping now and then is fine (Disclaimer: I'm not an admin, just sharing my personal preferences.)


Right, maybe I'll let the question marinate in the specific channel for a bit and see where it lands. Thanks for the feedback


@mbjarland Which channel wasn't getting you a response? (maybe we can suggest a more active channel that might also help)


This was on #datomic - really the question was about ions and whether ions are suitable for a plain-vanilla ring-type web applications or aimed at api:s and event handlers. I posted it on #clojure after...


Ah... I would have expected #datomic to be the best place to ask... sorry you didn't get a response there 😞