Fork me on GitHub

Yes, that's it!


And you can use get-in to navigate into the job hash map to pull out the pieces you need: (get-in job ["new_job" "id"]) -- since it looks like your hash maps have string keys, not keywords?


yes, that is exactly what I need, I suppose to generate the value I could do something like:

{:type (get-in job ["new_job" "type"]) :urgent (get-in job ["new_job" "id"])}


there is definitely a more general way for the value, I will figure out


I can just use dissoc for id


@brnbraga95 You might also want to look at select-keys


it is incredible how much can be achieved with so little code


althought it is indeed hard to read (for beginners at least)


Clojure's conciseness is both a strength and a weakness. Learning to write (concise) idiomatic Clojure takes time. I look back at some of my early Clojure code (which is still in production) and I shudder. My recent Clojure code looks much cleaner and easier to read (albeit likely requiring more experience of the readers).


I got started learning Clojure back in 2010 and we first started using it in production at work in 2011.


awesome, the closest I have been from such a funcional programming was with some javascript functions, which is not considered a functional language but some libraries provide it. Now I am working on a project that runs heavily with Clojure, so I am getting ahead and doing my share of study, clojure with datomic are the main things on this project, I feel like I am changing my way of thinking in terms of programming because of all these funcional programming and these immutability concepts..sure is very different for someone new.

Russ Olsen12:03:50

Take heart, in the not too distant future you will find yourself wondering what all the fuss was about. It's one of the things that makes functional programming hard to explain is that the idea are actually very simple, it's getting used to the fact that you can get so much done with so little that takes time.


@brnbraga95 Yeah, getting into a Functional Programming frame of mind can be hard, especially for folks whose only programming experience is something like Java -- where it's nearly all about stuffing data into objects and mutating it to get work done. Often you have to "unlearn" a whole bunch of (bad) habits in order to really get comfortable with FP. I really like this style -- but I was lucky to have studied it back at university in the early 80's, even tho' I had to learn C, COBOL, and later C++ in order to be employable 🙂


Some people get the functional mindset easier than others. I had a Haskell course in college where almost everybody failed because they did not get it. I’m not sure how the little Haskell made it easier to get to Clojure.


functional programming is often taught in the wrong way same goes for programming to be honest, I've had it in my vocational school and practically nobody who didn't program before "got" it


by the way, what do you use to store data on the disk? text files? SQLite? something else?


We use MySQL very heavily. We also use MongoDB a bit. We've also experimented with Amazon's DynamoDB. And we are starting to use Redis quite a bit (for a few, very specific things).


I'd love to find a place for Datomic in our stack at work but we don't fit its use cases, for the most part. A lot of our tables are very high write and/or append-only but very large.


Datomic would be a good fit for our e-commerce subsystem, I suspect, and possibly for our member-profiles, but very little else in our system -- so it's not worth the complexity of introducing a whole new DB stack just for a couple of subsystems (when we already have those subsystems working satisfactorily with MySQL).


After reading Eric Normand's wonderful take on this whole paradigm/mindset thing: I think that a lot of newcomers on FP such as myself finds it hard to fully understands FP because we tend to get stranded to "easier to understand" but cliche explanation on FP (immutable vars, higher order function, pure function, etc.), instead of what FP paradigm really means (use function to produce a solution).


The Haskell Book also is a wonderful FP resource


We use MySQL very heavily. We also use MongoDB a bit. We've also experimented with Amazon's DynamoDB. And we are starting to use Redis quite a bit (for a few, very specific things).


re-find should boolean right?


it returns a string or nil which you could treat as truthy or falsey values -


re-find returns a full match string if no regex captures, else a vector of captures, else nil


so there is no function to which we can pass regex and string that will return 'true' or 'false' if matches and not matches resp?

Russ Olsen17:03:42

I think if you are looking for an explicit true or false you can always wrap the boolean function around what you are doing: (boolean 1) => true

Russ Olsen17:03:26

But if you are just working in a Clojure context then the truthy logic works just the way you want it to.


yeah got it. I wrapped that function to boolean finally. Thanks:grinning:

Russ Olsen17:03:42

I think if you are looking for an explicit true or false you can always wrap the boolean function around what you are doing: (boolean 1) => true


why is (-> 3 identity) evaluates to 3 but (-> 3 (fn [x] x)) we get Error?


compare (macroexpand '(-> 3 identity)) with (macroexpand '(-> 3 (fn [x] x)))


@U051SA920 @U61HA86AG Thank you! when I put symbol to fn it expands, but the when I put the fn it throws error when when it expands. I forgot it’s a macro!


the right way would be I guess (-> 3 ((fn [x] x)))


yep! -> (and the other arrow macros), are just dumb code transforms; -> merely writes the value into the first position of the lists/symbols you pass it


so (-> 3 (fn [x] x)) becomes (fn 3 [x] x) which isn't valid 🙂


and yeah, wrapping it with parens means it becomes ((fn [x] x) 3) instead


Thank you 🙂

lambdalove 4

@sifou935 Try macroexpanding


do you ever use if alone instead of if some? when checking if a given thing exists? why does this implicit nil to false conversion even exist?


I believe it is very common among Clojure programmers to do (if <expression> ...) where they rely on <expression> returning nil being treated as false.

Alex Miller (Clojure team)21:03:13

also, it’s not a conversion rather the definition of logical truth in the language


what if you want to check if it exists and it's false? :thinking_face: I mean yeah, use if some? but one can get carried away


(if (= false <expression> ...) would work, as would (if (false? <expression> ...)

Alex Miller (Clojure team)21:03:05

then you can use the predicate false? to check specifically for a false value


:thinking_face: okay

Alex Miller (Clojure team)21:03:50

but practically speaking, Clojure leans heavily on its notion of logical truth everywhere


what do you think about this post


Regarding the first point, I think there are many people who would agree about avoiding "use", but still find :refer palatable, because at least with an explicit :refer, the text of the code still lets you see where the :refer'd name came from.

Alex Miller (Clojure team)21:03:03

I agree with some of that and disagree with some of that post (like the nil parts :)


I've seen expanded opts everywhere

Russ Olsen21:03:20

@mailmeupinside The whole 'nil and false is treated as falsy' has a history that predates Clojure by decades. It's a different way of looking at things but my experience has been that it works fine.


alright, if it's working I'm ok with it :)

Russ Olsen21:03:28

Sorry, that's not how these things are supposed to go! You are supposed to tell me I'm crazy and I make some snarky comment back and then... and then...


uhh but types

Michael Fiano21:03:12

Are there any other video tutorials for a small project in Clojure such as Parens of the Dead? I read a few books, and I think I'm ready to jump in with a little guidance.

Russ Olsen21:03:28

@mailmeupinside On the other hand I am a fan of the name things in a series of let bindings vs mashing them together in a single expression style.


I used to mash them, but today I tried that let approach and it's actually a lot more convenient and readable, yeah

Michael Fiano21:03:31

I'm kind of looking for something that focuses on the reference types, and bonus points for applications in concurrency.


thanks all for the input 🙏