Fork me on GitHub

Hey, is there a function that checks for the truthiness of a function and when falsey it sets the result to nil ?


@urbanslug: Can you make an example? A function is always truthy. Or do you mean the result of a call? when does return nil for falsey.


rauh: yeah like when but when true I want the when to return true


Currently what I have is: (when (bool-returning-function) true)


@urbanslug: I'd say that's as short as it gets and it's very idiomatic. At least I can't think of anything shorter.


@rauh: I was hoping there’s something in the standard libs for it 😄


I guess clojure macros save the standard libs a lot of bloat.


Slightly off topic but need recommendations for a good book to learn Java. Something modern/new and not for first time programmers. The only decent recommendation I've gotten so far is Thinking in Java (4ed) which was released quite a long back.


(or (bool-returning-function) nil) ?


@roberto: Let me check that out


Looks kinda obscure


it actually isn’t for lisps


and is the same way


I was hoping (func (bool-returning-function)


this is standard in other lisps


Not sure where to ask this but .. I was just wondering, I’m used to the Apache/PHP mix where you’ve a public_html dir and something in Apache will call the index.php to kick things off - is there an equivalent in Clojure? I’ve seen httpkit/jetty are these meant to be the http server replacements for apache?


yes, clojure apps (and java apps) are not deployed to apache’s http server


traditionally they were deployed to a container like Apache Tomcat


nowadays, it is common to have an embedded server like jetty or netty(httpkit) in the application


@bones I deploy an uber jar with an embedded jetty that runs via a systemd startup script and is fronted by nginx for SSL/TLS. The luminus deploy docs actually give several good examples of deployment options:

Chris O’Donnell14:04:41

That's what I do, as well.


For example, when a piece matches a

the next piece need to be added as a new key
for all waypoints until the next match

Chris O’Donnell19:04:39

@audaxion: could you give a small example of input and desired output data?


@codonnell: with the first snippet i uploaded as inputs, this is what i’d expect the output to look like

Chris O’Donnell19:04:46

so if the waypoint string shows up in your list at the bottom, you add the key :airway with value equal to the string following it?


and also to every waypoint following it until i hit another match

Chris O’Donnell19:04:19

but then there is some special behavior for the ...'s?


the .. indicates the next string is another waypoint name, instead of an airway name

Chris O’Donnell19:04:19

The first thing to do in my opinion is to convert your string into a better data structure.

Chris O’Donnell19:04:47

I'm not sure exactly how your ...'s behave, but for the waypoint : airway pairs, it seems natural to store them in a map

Chris O’Donnell19:04:23

for example, the first few would be {"MMMX" "PTJ5A", "PTJ5A" "PTJ", ...}

Chris O’Donnell19:04:39

that way given a waypoint, you have an efficient way of finding its airway


something wrong with grimoire? can I run it in an offline mode?


Hi everyone. I'm working through the Getting Started chapter in Brave Clojure ( and I'm getting an error when trying to run the jar file created from the lein uberjar command:

Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Var
        at clojure_noob.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: clojure.lang.Var
        at Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Any ideas what could be causing the issue? (Not sure if I asked this last time I was working through this chapter)


@codonnell: how would you recommend i go about splitting up the string to create the map?


@audaxion: (apply hash-map (.split (str (clojure.string/replace myinput ".." " none ") " none") " "))


wher myinput is your input string


(also a beginner, seeing this as a good exercise, let me know if I'm doing this clumsily)


@yogidevbear It looks like you are not running the -standalone.jar file

Chris O’Donnell20:04:50

I think there needs to be a (partition 2 1 coll) in there somewhere

Chris O’Donnell20:04:14

and another split

Chris O’Donnell20:04:48

For example, you want to split "A B C..D" first into ["A B C", "D"]

Chris O’Donnell20:04:04

Then you want to get all of the pairs out of "A B C", so you want to turn that into [["A" "B"], ["B" "C"]]

Chris O’Donnell20:04:12

And the hash-map function will convert that seq into a hash map.

Chris O’Donnell20:04:46

Try to focus on doing each of those steps individually, then figure out how to string them together.

Chris O’Donnell20:04:16

You should need string/split, partition, mapcat, and hash-map.


@curtis.summers: Thank you. I didn't notice on first glance that two jars were created. :thumbsup:


thanks @codonnell i’ll see what i can come up with

Chris O’Donnell20:04:43

No problem. If you have more questions, feel free to ping me.


@yogidevbear: Yes, it's gotten me many times before. I don't think I've ever used the other jar it creates. I wonder if there's a way to prevent it from creating both to begin with.


@curtis.summers: it uses the foo.jar as an input to the process that makes foo-standalone.jar


I mean you could change it so it just creates foo.jar in memory, or puts it in a tmp file or whatever


@roberto, @curtis.summers so instead of “deploying” your PHP files to a folder where the Apache can run them, when you say “embed” a server into your app, when you deploy, you’re deploying the whole thing web server and all?


If you want multiple applications on the same box how do they not all fight over port 80?


Again, complete beginner here, thanks for your help and patience


No, nginx handles port 80 and 443, and my virtual host for uses a proxy to my jetty process running on a localhost port.


Ah! so it does a DNS-like thing and you tell it what local ports your apps are living on and what requests get forwarded to them?


so is nginx acting like a reverse proxy in that case?


Yes, that's basically it. It's very common to let nginx or Apache handle the virtual host, port 80, and TLS/SSL.


Cool, thanks very much