Fork me on GitHub
Drew Verlee01:06:16

Whats the best way to search for stuff in clojure (ideas, concepts, libs)? I currenty go to it seems better then google


@drewverlee I don't use CrossClj much -- I've used Bing for all my technical searches for several years and I find everything I need that way. I've seen several people say Bing seems better than Google these days for technical searches.


I think CrossClj is great when you have a library -- or a few choices of library -- and want to see which is more widely used and how it is used.


Hi all, I am attempting to iterate through the chars of a string, and so far I have this: (doseq [i (count "letters")] (.charAt "letters" i)) this is giving me this error: Don't know how to create ISeq from: java.lang.Integ i'm not exactly sure what to change the doseq to in order to get the behavior that I need? suggestions?


@marlenefdez You鈥檇 want to use range in that case

(doseq [i (range (count "letters"))] (println (.charAt "letters" i)))
But you could just seq right over the letters:
(doseq [c "letters"] (println c))

馃幆 4

I suppose you could also use dotimes

(dotimes [i (count "letters")] (println (.charAt "letters" i)))
but that seems a little odd, FWIW.


@marlenefdez doseq requires a sequence and binds the symbol you provide as each member of that sequence in turn. count will return a number. so mike here is either using the string as the sequence or getting a same-length sequence of numbers.


@marlenefdez you can also map over a string


I鈥檓 having difficulty using a 3rd party Java library in Clojure. I can successfully add [com.clarifai.clarifai-api2/core "2.4.0"]] to my Lein project.clj and retrieve it (it shows up in lein deps :tree), but I can鈥檛 seem to import it in the REPL.


e.g. I want to import the ClarifaiBuilder class as seen in


@chris_ just checking: did you restart your REPL?


Perhaps I鈥檓 getting the Java package name wrong?


e.g. (import com.clarifai.clarifai-api2.ClarifaiBuilder) doesn鈥檛 work


nor does (import com.clarifai.clarifai-api2.core.ClarifaiBuilder)


this worked: (import clarifai2.api.ClarifaiBuilder)


beat me to it 馃槃


danke mg 馃檪


can鈥檛 always assume that the organization in a dependency atom is in the package path the same way

馃憤 4
Karol W贸jcik18:06:02

Hello I got a question about programatic access to java variables. Supposing that I got (def name-of-java-variable "var1") how can I access the property of obj programmatically using name-of-java-variable?


Depending on what kind of thing it is, you can access it with Class/forName or some sort of reflective access.

Karol W贸jcik18:06:30

ok but what with cljs?


it's much simpler in cljs, you can use js/foo instead of foo for anything globally accessible


since js actually has a global scope used for arbitrary values

Karol W贸jcik18:06:09

yup but what if I got an object like var obj = { prop: 'blabla' } and a string which is 'prop'. How can I programatically access that property using a string. In plain js I would do

var nameOfProperty = 'prop'


oh, in that case you would use goog.object (or you can use aget - there's code that does this but it has problems that are fixed by using the goog.object library instead)


goog comes with cljs

Karol W贸jcik18:06:45

Thank you very much 馃檪


is there any benefit to doing that instead of just (get jsobj key)


the fact that it actually works

ljs.user=> (let [m #js{:foo :bar}] (println) (println "get:" (get m "foo")) (println "goog:" (.get js/goog.object m "foo")))

get: nil
goog: :bar


get is a function on clojure hash-maps, not js objects generally. There's a hack where aget accidentally does the right thing but if you look at the code being emitted and why it works it should be clear that goog.object/get is the better choice


oh interesting. seems like it should just emit the right code. maybe it can鈥檛 figure it out.


i think aget will always work in javascript. i thought the issue is that there was some interesting in doing some runtime type checking


i do wish the doc string was a bit more specific about get鈥檚 acceptable usages


aget works on js objects that aren't arrays because someone realized it worked, it only worked because of an implementation detail, and now that implementation detail can't be changed because it would break so much code


but I don't think that's a good justification for using aget on objects in new code


and yes, the most pragmatic difference is that you can get better error messages in some cases (I forget the particulars at the moment)


actually, did get work for you? I forgot that the reason it works for me is that i implemented ILookup on object


it really shouldn鈥檛 work


oh no it didn鈥檛 work for you. i misread your initial response


I鈥檓 having difficulty accessing a method of a class. I鈥檓 trying to follow this Getting Started example:

(def client (.buildSync (ClarifaiBuilder. clarifai-api-key)))

(def general-model (.generalModel (.getDefaultModels client)))

(import clarifai2.dto.input.ClarifaiInput)

(def my-input (ClarifaiInput/forImage ""))

(.predict general-model)
;;=> #object[clarifai2.api.request.model.PredictRequest 0x6cd93f00 "clarifai2.api.request.model.PredictRequest@6cd93f00"]
PredictRequest has the public withInputs method, per the Getting Started docs and source code: But that鈥檚 exactly where I鈥檓 running into trouble:
(.withInputs (.predict general-model) my-input)

java.lang.IllegalArgumentException: No matching method found: withInputs for class clarifai2.api.request.model.PredictRequest
Any idea what鈥檚 going wrong? Any pointers?


@chris_ what鈥檚 my-input?



;;=> #object[clarifai2.dto.input.AutoValue_ClarifaiInput 0x7359950c "ClarifaiInput{id=null, createdAt=null, inputValue=ClarifaiURLImage{crop=Crop{top=0.0, left=0.0, bottom=1.0, right=1.0}, url=}, _metadata={}, concepts=[], geo=null}"]


A ClarifaiInput object is what PredictRequest鈥檚 withInputs method expects.


@chris_ try wrapping that in a vector. According to the source link, that method takes either ClarifaiInput... which in clojure java interop means you鈥檇 need to supply an array, or Collection<ClarifaiInput> which is nice of it, because that means you can wrap it in a generic collection

鉂わ笍 4
馃挴 4
馃挅 4



the ... is a nice bit of Java syntax that, unfortunately, doesn鈥檛 translate as nicely into interop


Okay, yes; I definitely missed what that means in Java


thanks again @michael.gaare

馃憤 4

does anyone know how to build a minified clojurescript app with lein?


I can't seem to find the right switches to flip to make it do what I want it to do.