Fork me on GitHub

@gadfly361 Are there issues with the Sodium dropdown component ? I have a dropdown within a form and when I click an option in the drop down, the options stay visible. Everything else works. The annoying bit is ... it is intermittent and I can't seem to debug why it happens. '[sa/FormSelect {:placeholder "My Selection" :label "Select me" :fluid true :on-change #(set-value! frm-id fld-id (get (-> %2 js->clj) "value")) :options [{:key "hello" :value "hello" :text "Hello"} {:key "hello2" :value "hello2" :text "Hello2"}]}]}])' Looks to me that style is not removed from the html that was generated. <div class="menu transition" style="display: block !important;"> I will do some further test.. but is looks like a bug somewhere


I guess what I am after is a 'long polling' connection.


@mhsmit away from keyboard at the moment, but try converting the options to a JavaScript array clj->js


@gadfly361 I also loaded jQuery and that was setting the element style.


@mhsmit Sodium is a wrapper around soda-ash, which is a wrapper around semantic-ui-react, which depends on semantic ui. I had some troubles using soda-ash because I was using the latest semantic-ui but semantic-ui-react and soda ash had not updated it鈥檚 dependencies. So you might need to check the chain of versions going back through the wrappers

Vincent Cantin03:06:02

What is the most idiomatic way in Clojure to find the index of a value in a (math) partition from a sorted vector of values? For example:

(map find-index [5 14 26 34] [10 20 30])
=> (0 1 2 3)


@vincent.cantin Can you explain what the algorithm is? I'm not sure what you mean by "(math) partition"


(it doesn't sound like a map problem to me)

Vincent Cantin04:06:24

Sorry, I did not formulated it clearly. The problem is to find the index of a number between values of a sorted vector.


You have two sorted vectors -- so I'm not sure what you're saying.

Vincent Cantin04:06:40

I map a linear implementation and wonder if that function exists in the standard library.


Which vector would be the input (numbers) and which vector is your partition? And which one varies most?


Seems like you'd want something like (map (find-index [10 20 30]) [5 14 26 34]), assuming [10 20 30] is the partition and the other vector is the number input.

Vincent Cantin04:06:13

Ah .. yes, I wrote it wrong.


OK, so (map #(find-index % [10 20 30]) [5 14 26 34])?



(defn find-index [sorted-values]
  (fn [val]
    (reduce ...)))
and then
(map (find-index [10 20 30]) [5 14 25 34])

Vincent Cantin04:06:17

the map was just to show the expected behavior on different values.

Vincent Cantin04:06:49

I only need to find the index of 1 value at a time.

Vincent Cantin04:06:29

Using a binary search would work faster, does the standard library have functions for such searches?


Search won't work tho' -- you're not looking for actual values.


@vincent.cantin I am not aware of anything in the Clojure core code that does binary search of an array or vector. Sorted sets and maps are binary (red-black) trees in their implementation under the hood, but I don't recall any functions that return the index/position of the most closely matching value.



(defn find-index [parts] (fn [n] (count (take-while (partial > n) parts))))
(map (find-index [10 20 30]) [5 14 26 34])

Vincent Cantin04:06:23

Nice golf shot.


Took me several goes in the REPL 馃檪


How do I ask the repl for the defined methods on a multimethod?

Karol W贸jcik08:06:44

Hi friends! Is there some magic module which transforms normal math expressions to onp? For instance "3 + 5 * 3" to "(+ 3 (5* 3))"

Karol W贸jcik09:06:01

Ok there is infix library:)


I have a question about protocols / types / records / whatnot.... So I have a protocol IBrush which defines stuff that can be drawn. I have an implementation like this:

(ns brushes.simple
  (:require [brushes.protocol :refer [IBrush]]))

(deftype SimpleBrush [brush-radius]
  (draw [_ state]
    ;; actual drawing code...


But then when I try (let [b (->SimpleBrush 10)] (draw b)) it tells me there's no function draw. Am I misunderstanding something? I thought the methods would get promotoed to the namespace


You mean you thought that there would be a method draw defined in brushes.simple? If so, that's not what happens. You need to use the method from the brushes.protocol ns

Karol W贸jcik14:06:14

Is there any easy way to include some of .jar files to uberjar? Simply put leiningen does not include jar stored in lib folder while uberjaring while on lein run it works as expected. Here is how me project.clj looks like:

(defproject recomputing-with-swapped-operands "0.1.0"
  :description "RESWO (Recomputing with swapped operands)"
  :license {:name "Eclipse Public License"
            :url ""}
  ;; :main reswo-logic.core
  :profiles {:uberjar {:aot :all}}
  :source-paths ["src"]
  :resource-paths ["lib/reswo-designed-uis.jar"]
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [seesaw/seesaw "1.5.0"]])


It's considered "poor practice" to use 3rd party JAR files directly. You could use lein-localrepo to "install" the JAR into your local ~/.m2 cache tho' to get around this (and then treat it as a regular dependency.

Karol W贸jcik21:06:29

Thank you @U04V70XH6.I came up with idea of taking the source of my jar and just putting them in the src/java. I will definitely read the resource. Thanks! 馃檪


Checkout dependencies is another thing you might look into.

Caio Guedes15:06:44

guys, I added a dep on my project.clj (lein), but didn't find the namespace of package... how can I discover that?

Karol W贸jcik15:06:05

Go to the .m2. Search for the package you included. Go to the source code of the package and you got namespace ;)

Caio Guedes15:06:59

yep, I aready found com.twitter.bijection.clojure, but when I try import/require it, Its not found 馃槯

Caio Guedes15:06:32

I'll look at .m2 for more clues

Karol W贸jcik16:06:58

Tell my what youre trying to require and how then I will be bale to help you

Caio Guedes17:06:20

I need create a Bijection from Long to Base64String

Caio Guedes17:06:53

Like in this example... I'm trying interop now...

Karol W贸jcik18:06:37

package com.twitter.bijection.codec; You have to import base64 class I believe

Karol W贸jcik18:06:30

Supposing that you have the the (ns then you have to use :import in that ns like so (ns (:import (com.twitter.bijection.codec Base64)))

Caio Guedes15:06:02

(defproject my-api "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.8.0"]
		 [com.twitter/bijection-clojure_2.12 "0.9.6"]])


I'm writing a library and I'm also relatively new to clojure. I'm still getting used using plugins and profiles. I notice in a lot of plugin installation instructions they show adding it to the user profile, not in the project.clj. However I've been adding most to my project.clj. I'm wondering with something like humane-test-output that makes test output look better, should that be something a contributor should decide on their own to use (in their own user profile) or is it ok to include it in the project.clj? Just wondering best practice here or potential pitfalls like some kind of conflicts with user profiles.