Fork me on GitHub

How can I make the / in (clojure.string.replace s #"(.+?)(\/+)$" "$1")) taken from a variable?


Have a look at clojure.core/re-pattern!


Ok, thanks

Vincent Cantin13:04:52

Where can I find the list of type hints which can be used in a .cljc file?


i cant figure out why this doesn't work, x is a collection of numbers and i'm trying to return all of the odd numbers


i assume i'm misunderstanding something about how reduce works


why not use filter?

(filter odd? x)


you build things up in a but if b is not odd you throw it away since when returns nil if the condition is not met


didn't know about filter, i'm doing clojurecademy and it hasn't covered that yet so i'm assuming it kinda meant for me to use reduce like the previous problem


(reduce  (fn [acc x]
             (when (odd? x)
               (conj acc x)))
i've renamed some things here for you. but what does this return when x is not odd?

Ivan Koz15:04:04

a b better be named acc v or x right

Ivan Koz16:04:43

if odd? conj acc x else acc


reduce expects the reduction function to return the "accumulation" value each time. so you need to return acc or (conj acc x). if you return nil you are wiping out your previous results


derp, thank you


how do you deal with multiple versions of jvm's

Ivan Koz16:04:57


:java-cmd "path/to/java"
in your lein profile

Ivan Koz16:04:12

its also possible to create multiple profiles and setup different versions of dependencies


cool thanks, Is there a page on profiles. also the :java-cmd should help

Ivan Koz16:04:18

i think there is also LEIN_JAVA_CMD envar

Ivan Koz16:04:48

search for :java-cmd


@nxtk that worked, thanks 😊

Tangible Dream18:04:27

Hello everybody.

hipster coder19:04:48

My first thought is that dependencies could have changed since 2015

hipster coder19:04:12

looking at your code line by line…

hipster coder19:04:53

Call to clojure.core/ns did not conform to spec

hipster coder19:04:00

(:require-macros [cljs.core.async.macros :refer [go]])

hipster coder19:04:19

It looks like it hasn’t been touched in 6 years. So I’d take a look at your Clojure version matching if it can compile that library

hipster coder19:04:15

The compiler is failing enfocus on the very first line where the ns namespace is setup

hipster coder19:04:06

You have to ask someone more experienced with Clojure… if namespaces have changed in last 6 years.. how they are setup and used. Because all my Clojure code closes the ns with an ) and then uses it

Tangible Dream18:04:07

I’m working through Ch7 of living clojure and I think I’m getting tangled up in version dependencies

Tangible Dream18:04:21

The book is written circa 2015

Tangible Dream18:04:57

pardon the length of this output

Tangible Dream18:04:30

my cheshire-cat.core file

Tangible Dream18:04:50

(ns cheshire-cat.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [clojure.browser.repl :as repl]
            [cljs-http.client :as http]
            [cljs.core.async :refer [<!]]
            [enfocus.core :as ef]))

(defn ^:export init []
  (repl/connect "")
  (go (let [response (<! (http/get "/cheshire-cat"))
            body (:body response)]
        (ef/at "#cat-name" (ef/content (:name body)))
        (ef/at "#status" (ef/content (:status body))))))

Tangible Dream18:04:24

my project version dance

Tangible Dream18:04:12

(defproject cheshire-cat "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [ring/ring-json "0.5.0-beta1"]
                 [org.clojure/clojurescript "1.10.520"]
                 [cljs-http "0.1.46"]
                 [org.clojure/core.async "0.4.490"]
                 [enfocus "2.1.1"]]
  :plugins [[lein-ring "0.12.5"]
            [lein-cljsbuild "1.1.7"]]
  :ring {:handler cheshire-cat.handler/app}
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}}
  :cljsbuild {
      :builds [{
          :source-paths ["src-cljs"]
          :compiler {
            :output-to "resources/public/main.js"
            :optimizations :whitespace
            :pretty-print true}}]})

hipster coder19:04:01

Does anyone know if namespace have changed over the past several Clojure versions? In how they are setup at the top of your code. I didn’t start out on earlier Clojure versions so I don’t know.

Tangible Dream19:04:11

hmm more cattle then hat


So I’m trying to import JavaFX stuff to do interop, but for some reason I’m getting a ClassNotFoundException on javafx.scene.Scene and I’m not sure why. I’m running OpenJDK 11.0.2 and Clojure 1.10.0 if that matters.

Lennart Buit20:04:56

JavaFX has been split out of the std library

Lennart Buit20:04:02

so you will have to include it as a library


oh, can I include javaFX in the same way I include clojure projects?

Lennart Buit20:04:26

I am trying to find resources for you, but end up empty handed

Lennart Buit20:04:02

yeah, there was a recent JavaFX library for clojure, but I lost its name 😢

Lennart Buit20:04:34

yeah that one, thanks!


I haven’t played with that yet, but I’ve been meaning to soon

Lennart Buit20:04:52

But yes; you appear to be able to include javafx via maven, just like clojure deps


[org.openjfx/javafx-controls "11.0.3"]
                 [org.openjfx/javafx-base "11.0.3"]
                 [org.openjfx/javafx-graphics "11.0.3"]
                 [org.openjfx/javafx-media "11.0.3"]
                 [org.openjfx/javafx-web "11.0.3"]
added these to my lein project.clj but it can’t find the artifacts.

Lennart Buit20:04:45

sorry, this is as far as my knowledge goes, so I hope someone else knows!


have you done lein deps after adding them?


If that doesn’t work by itself, try lein clean ; lein deps


ok, I changed my deps to this [org.openjfx/javafx "12"] after looking at this but I’m still getting the same error when running lein clean ; lein deps which is

Retrieving org/openjfx/javafx/12/javafx-12.pom from central
Could not find artifact org.openjfx:javafx:jar:12 in central ()
Could not find artifact org.openjfx:javafx:jar:12 in clojars ()
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.


Are you using cljfx?


You might want to try that, I know some people are using it to play around with JavaFX stuff successfully.


You may be able to remove the [org.openjfx/javafx-controls "11.0.3"] etc dependencies, and just replace them with [cljfx "1.2.6"]


[org.openjfx/javafx-base "12"]
                 [org.openjfx/javafx-graphics "12"]
                 [org.openjfx/javafx-controls "12"]
                 [org.openjfx/javafx-media "12"]
                 [org.openjfx/javafx-web "12"]


Also there’s a #cljfx channel with people who are more experienced with it than I am


Ah, that’s interesting


seems like I have to import different packages directly


Maybe that’s a maven vs clojars difference


You might want to ask on the #cljfx channel if that’s how people are doing it.


So I’m testing out java interop through JavaFX and I’m trying to draw a basic circle, but for some reason it can’t find the class collijion.core when I run the launch method. I’ve tried setting :name in gen-class, but that didn’t work either


@nicholas.jaunsen Gen-classes need to be AOT compiled


Basically, see if you can use proxy or reify instead in your case.


And if you can't. You will need to compile your code with AOT turned on. And then it will work. But in the REPL, it won't be available, unless you run compile and then make sure your compile path is in the path for your REPL, and you start the REPL after compilation.

hipster coder23:04:46

has anyone had to downgrade or upgrade readline on osx for clojure to work?


You didn't seem to get an answer to this... No, I have not, and I don't recall reports of anyone else having to down/up-grade readline on OS X / macOS for any sort of Clojure REPL to work.

hipster coder03:04:49

Lein is working fine. I only receive a readline missing error if I try to run clj from command line


Oh, you mean rlwrap? Yes, that's an optional O/S level dependency for clj. You can use clojure instead (`clj` is basically just an rlwrap wrapper around clojure to make the REPL experience better).

hipster coder03:04:16

ahhh wow. clojure works. instead of clj. Ya, it was trying to use rlwrap. You saved my day


Ya, rlwrap is optional. It just provides a better REPL experience with history etc.


You didn't seem to get an answer to this... No, I have not, and I don't recall reports of anyone else having to down/up-grade readline on OS X / macOS for any sort of Clojure REPL to work.