This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-14
Channels
- # announcements (2)
- # beginners (88)
- # calva (17)
- # cider (25)
- # cljdoc (22)
- # cljs-dev (10)
- # clojure (194)
- # clojure-italy (1)
- # clojure-nl (8)
- # clojurescript (24)
- # data-science (11)
- # datomic (1)
- # fulcro (6)
- # jobs (1)
- # leiningen (4)
- # nyc (1)
- # off-topic (70)
- # pedestal (6)
- # quil (4)
- # shadow-cljs (59)
- # vim (8)
How can I make the /
in (clojure.string.replace s #"(.+?)(\/+)$" "$1"))
taken from a variable?
Where can I find the list of type hints which can be used in a .cljc
file?
I think I found it: https://clojure.org/reference/java_interop#TypeAliases
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
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)))
#{}
coll)
i've renamed some things here for you. but what does this return when x
is not odd?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
ahh i see now
derp, thank you
how do you deal with multiple versions of jvm's
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
Thanks
@sotrhraven also this https://github.com/technomancy/leiningen/blob/master/sample.project.clj
@nxtk that worked, thanks 😊
Hello everybody.
My first thought is that dependencies could have changed since 2015
looking at your code line by line…
Call to clojure.core/ns did not conform to spec
(:require-macros [cljs.core.async.macros :refer [go]])
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
The compiler is failing enfocus on the very first line where the ns namespace is setup
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
Thanks!
I’m working through Ch7 of living clojure and I think I’m getting tangled up in version dependencies
The book is written circa 2015
pardon the length of this output
my cheshire-cat.core file
core.cljs
(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))))))
my project version dance
(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}
:profiles
{: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}}]})
Does anyone know if namespace https://clojuredocs.org/clojure.core/ns 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.
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.
JavaFX has been split out of the std library
so you will have to include it as a library
I am trying to find resources for you, but end up empty handed
yeah, there was a recent JavaFX library for clojure, but I lost its name 😢
yeah that one, thanks!
I haven’t played with that yet, but I’ve been meaning to soon
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.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 https://search.maven.org/artifact/org.openjfx/javafx/12/pom 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
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.
sorry, this is as far as my knowledge goes, so I hope someone else knows!
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
See: https://stackoverflow.com/questions/42617678/gen-class-in-clojure-and-use-it-immediately
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.
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.
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).
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.