Fork me on GitHub
#beginners
<
2019-04-14
>
adam00:04:28

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

zane01:04:32

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

adam01:04:30

Ok, thanks

Vincent Cantin13:04:52

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

porksausages15:04:52

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

porksausages15:04:08

i assume i'm misunderstanding something about how reduce works

Nico15:04:40

why not use filter?

(filter odd? x)

dpsutton15:04:45

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

porksausages15:04:11

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

dpsutton15:04:03

(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?

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

dpsutton16:04:45

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

porksausages16:04:10

derp, thank you

sotrhraven16:04:39

how do you deal with multiple versions of jvm's

Ivan Koz16:04:57

@sotrhraven

: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

sotrhraven16:04:22

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

sotrhraven17:04:29

@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}
  :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}}]})

hipster coder19:04:01

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.

Tangible Dream19:04:11

hmm more cattle then hat

skykanin20:04:33

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

skykanin20:04:57

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!

manutter5120:04:42

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

skykanin20:04:04

[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!

manutter5120:04:00

have you done lein deps after adding them?

manutter5120:04:16

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

skykanin20:04:50

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.

manutter5120:04:30

Are you using cljfx?

manutter5120:04:32

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

manutter5120:04:42

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"]

skykanin20:04:13

[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"]

manutter5120:04:19

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

manutter5120:04:45

Ah, that’s interesting

skykanin20:04:00

seems like I have to import different packages directly

manutter5120:04:01

Maybe that’s a maven vs clojars difference

manutter5120:04:35

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

skykanin21:04:19

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

didibus23:04:04

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

didibus23:04:35

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

didibus23:04:00

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?

seancorfield02:04:05

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

seancorfield03:04:11

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

seancorfield04:04:35

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

seancorfield02:04:05

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.