#clojure log - Dec 01 2014

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:13 kenrestivo: i'm starting to get annoyed by constant Exception in thread "main" java.io.FileNotFoundException: target/309e3ecd48b135658c89389e9b614f8af44cd3ea-init.clj (No such file or directory) when running lein trampoline

0:14 i have to rm -rf target/trampolines before running every time, to avoid this error

0:27 rritoch: Can anyone explain the intended usage of cat? The documentation says it is supposed to catenate input, but the only thing I could get it to do is wrap a function ##((cat inc) 1)

0:27 lazybot: java.lang.RuntimeException: Unable to resolve symbol: cat in this context

0:27 rritoch: ,((cat inc) 1)

0:27 clojurebot: 2

0:58 justin_smith: (doc cat)

0:58 clojurebot: "([rf]); A transducer which concatenates the contents of each input, which must be a collection, into the reduction."

0:58 justin_smith: rritoch: so it's a transducer, meaning that you wrap some other function(s) and then use sequence or transduce or whatever to get the result

0:59 $grim clojure.core/cat

0:59 lazybot: http://grimoire.arrdem.com/1.6.0/clojure.core/cat

0:59 justin_smith: grimoire doesn't have that clojure version yet, sadly

1:00 rritoch: justin_smith: I read the documentation, but I don't see how to use it anywhere

1:01 justin_smith: For the most part I understand the transducers for map, filter, and mapcat, but I'm stuck on cat because it doesn't seem to do anything

1:01 justin_smith: ,(sequence (comp cat (map inc)) [[0 1 2] [3 4 5]])

1:01 clojurebot: (1 2 3 4 5 ...)

1:01 justin_smith: it does that

1:02 you use it in combination with another transducer

1:02 of course you would just use mapcat for that example

1:03 rritoch: Thanks, that is what I was looking for. In my tests I wasn't combining functions, I figured it would be easier to learn looking at the behavior with single functions

1:03 justin_smith: ,(sequence (comp cat (filter even?)) [[1 2 3] [4 5 6] [7 8 9]])

1:03 clojurebot: (2 4 6 8)

1:04 justin_smith: note that here I could not have used mapcat

1:04 without an ugly anonymous function

1:04 yeah, cat makes no sense by itself

1:04 it only makes sense with other functions I think...

1:04 hmm

1:05 &(sequence cat '[[a b c] [d e f]])

1:05 lazybot: java.lang.RuntimeException: Unable to resolve symbol: cat in this context

1:05 justin_smith: ,(sequence cat '[[a b c] [d e f]])

1:05 clojurebot: (a b c d e ...)

1:05 justin_smith: note that here, it acts just like (apply concat)

1:05 but it's a transducer, not a lazy seq

1:09 rritoch: justin_smith: Well, eventually the differences should probably be resolved for common cases

1:09 justin_smith: I don't understand what you mean by that

1:10 rritoch: I'm trying to find the example, but I found a case where I had to cast to seq before casting to vec

1:10 justin_smith: the point here is we want something that acts like concat, but isn't a lazy-seq

1:10 for perf reasons

1:12 rritoch: Ahh, here's the case I ran into

1:12 justin_smith: you may want something other than sequence for that though

1:12 (doc sequence)

1:12 clojurebot: "([coll] [xform coll] [xform coll & colls]); Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence nil) yields (), When a transducer is supplied, returns a lazy sequence of applications of the transform to the items in coll(s), i.e. to the set of first items of each coll, followed by the set of second items in each coll, until any one of the colls is exhausted. Any

1:12 rritoch: ,(def a (map (partial * 2)))

1:12 clojurebot: #'sandbox/a

1:12 rritoch: ,(def c (eduction a [1 2 3]))

1:12 clojurebot: #'sandbox/c

1:13 rritoch: ,(vec c)

1:13 clojurebot: #<RuntimeException java.lang.RuntimeException: Unable to convert: class clojure.core.Eduction to Object[]>

1:13 rritoch: ,(seq (vec c))

1:13 clojurebot: #<RuntimeException java.lang.RuntimeException: Unable to convert: class clojure.core.Eduction to Object[]>

1:13 justin_smith: interesting

1:13 rritoch: mm

1:13 Hmm

1:13 justin_smith: you probably want (vec (seq c))

1:13 that may be a bug?

1:13 rritoch: yeah, lol

1:13 ,(vec (seq c))

1:13 clojurebot: [2 4 6]

1:13 justin_smith: ,(into [] c)

1:13 clojurebot: [2 4 6]

1:14 justin_smith: or that

1:14 rritoch: That was an unusual case I ran into that should probably be automated in vec

1:14 justin_smith: I think using into is canonical with transducers in general

1:14 rritoch: Sure, there are easier ways, but it seems wierd that you can't cast the eduction result to a vector

1:15 With the vec function that is...

1:15 To be clearer, vec should be made transducer aware

1:19 So what about these "transducer processes", are there examples of that someplace? The documentation was a bit vague

1:20 kenrestivo: is there any other way to avoid constant Exception in thread "main" java.io.FileNotFoundException: target/309e3ecd48b135658c89389e9b614f8af44cd3ea-init.clj (No such file or directory) when running lein trampoline, other than rm -rf target/trampolines before running every time?

1:57 allenj12: yea i tried converting that answer into what i needed and it didnt work.. i posted some code that makes it more clear http://pastebin.com/9AaX74vx

1:59 the :recursions is the layers i mentioned above

3:55 fairuz: hmm using liberator and compojure, I have :allowed-methods [:get] in one of my resource. I expect it to block any request coming from cross-domain since :options http method is not allowed. But when I test from a different domain (only port differs), the request still get through. Any suggestions? Thanks

4:00 daniel: fairuz: i would have thought you restrict cross domain access at the webserver level, not in liberator

4:04 fairuz: daniel: I did enable cors. If I don't enable it, I will get the usual cross domain error

4:05 I'm thinking to put :options alongside :get in the allowed-methods. So just wondering why it still works even it's not allowed

4:06 daniel: i didnt know options was meant to restrict cross domain access

4:06 fairuz: No, it's not for restricting access

4:07 When a cross origin request is made, the browser will send a preflight request to the server

4:07 This preflight request is using OPTIONS http method

4:07 So basically the browser is sending 2 requests instead of one

4:15 daniel: i see fairuz

4:16 don't know the answer then, would be interested as well

4:28 fairuz: ohh.. it's just that I'm doing a simple request, that will not make the browser send the preflight

4:28 I'm seing it's blocked now with a proper request

4:28 *seeing

4:28 pllx: fairuz did you just have an epiphany

4:49 sveri: Hi, Is there a way to get the line ending character that is used in a file programmatically?

4:51 llasram: sveri: ##(System/getProperty "line.separator")

4:51 lazybot: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "line.separator" "read")

4:51 llasram: Gee, thanks lazybot

4:51 Anyway, on JVM Clojure that should hook you up

4:57 sveri: llasram: hm, but AFAIR the line ending may be a different one in a specific file?

4:58 llasram: sveri: What you are looking for is known as "magic"

4:58 I suggest sacrificing a goat. That usually works.

4:59 Yeah, maybe there's some heuristic method akin to character-encoding detection. It does seem like it would be somewhat straightforward.

4:59 I do not however know of any library which implements such detection

5:14 sveri: llasram: well, I sacrificed that goat, its still not working :D

5:15 llasram: however, I have not found one either

5:16 llasram: sveri: Well, the obvious algorithm should be pretty easy try out on your data

5:16 Poor goat...

5:25 sveri: llasram: Well, actually no goat was harmed during the sacrification, they only got drugged

5:29 What I want is to read a csv file with one of the two libs I found, now, I downloaded some random csv file and it has the \r line ending which is not autodetected by both of them, yea, I know I have to solve it myself, just wanted to give some context :-)

5:30 llasram: kk; good luck! :-)

6:16 CookedGryphon: anybody got any hints for testing things involving timeouts in core.async?

6:52 tsdh: Hi. I have a set of regexes which all share some common parts. Is there some way to compose regexes other than defining them as strings first?

7:04 Oh, it seems I can do just (let [common #"foo", special (re-matcher (str common #"bar"))...]...)

7:15 mearnsh: tsdh: re-matcher should be avoided because the Matcher object it returns mutates in a non-thread-safe way

7:16 clgv: tsdh: there is `re-pattern`

7:16 mearnsh: yeah that's what you want

7:16 clgv: ,(re-pattern "bla")

7:16 tsdh: clgv: Ah, yes, I actually use re-pattern. Just a typo.

7:16 clojurebot: #"bla"

7:16 tsdh: Thx

8:22 dysfun: does anyone know of any way of efficiently serialising simple tree transforms?

9:11 ordnungswidrig: dysfun: what do you mean by "tree transforms"?

9:17 dysfun: ordnungswidrig: imagine i wanted to do om in clojurespace. i would have to keep a websocket connection open and transmit updates over it back to clojure. om widgets are just a tree on which a number of operations can be performed

9:18 so how do i a take a bunch of transforms over a tree (in this case actually html directly, not om) and transmit them to clojure to manipulate its tree? is there some library that simplifies dealing with this? it seems like a thing people might want to do

9:20 ordnungswidrig: I see. What are those "simple transforms"?

9:20 dysfun: things like "element foo had child added" (with attached information). or "element bar child 3 (textnode) mutated"

9:20 gfredericks: (inc TEttinger)

9:20 lazybot: ⇒ 31

9:21 dysfun: wherein we presume i've solved the problem of uniquely identifying elements

9:23 gfredericks: dysfun: this reminds me of my haystack library, but that's aimed at debugging two things that are different when they're supposed to be the same

9:23 * dysfun looks

9:25 dysfun: gah, firefox is so damn slow since i updated

9:25 gfredericks: I'm pondering whether it would be productive to try to solve both problems at once

9:26 dysfun: or to split it into two phases?

9:26 gfredericks: well if it were structured as a pair of multimethods

9:26 diff and patch

9:26 ordnungswidrig: dysfun: how far can you go with "update-in"?

9:27 gfredericks: diff :: A -> B -> Diff; Patch :: A -> Diff -> B

9:27 dysfun: hrm, i wonder how many primitives i'd actually need

9:28 gfredericks: perhaps less useful for my purposes, where I like being able to look at single individual differences even if there are a lot of them

9:29 dysfun: i'd just model it as two functions tbh

9:49 hellofunk: what is the idiomatic way to the get the nth item in a lazy-seq? the (drop .. (take .. )) seems clunky

9:51 justin_smith: hellofunk: nth?

9:51 hellofunk: ah, ha ha justin_smith i didn't realize that a lazy seq qualified as a collection for nth.

9:52 i see that seq is not considered a collection, while a lazy-seq is. that's interesting.

9:52 justin_smith: and I would use (first (drop ...)) as the alternative, over (drop ... (take ...))

9:53 ,(nth (seq [0 1 2 3]) 2)

9:53 clojurebot: 2

9:53 hellofunk: ,(coll? (seq [1 2]))

9:53 clojurebot: true

9:53 hellofunk: well i'll be.

9:53 thanks mang.

9:53 justin_smith: nth works on all kinds of stuff

9:54 ,(nth "hello" 2)

9:54 clojurebot: \l

9:54 justin_smith: (coll? "hello")

9:54 ,(coll? "hello")

9:54 clojurebot: false

9:54 hellofunk: you are the mang, mang!

10:00 sveri: hellofunk: what is a mang?

10:00 hellofunk: sveri http://www.urbandictionary.com/define.php?term=Mang

10:01 sveri i prefer definition 3

10:05 sveri: hellofunk: thank you, I see, I am getting to old :D

10:06 hellofunk: sveri well, scarface was quite a long time ago!

10:06 sveri but for a more recent example, terrence howard says it a lot in Hustle and Flow also

10:09 sveri: hellofunk: ah, I see, I thought this was some new stuff, anyway, I never heard of both of them

10:11 hellofunk: sveri scarface was a class Al Pacino movie about Miami drug wars

10:11 *classic

10:12 sveri: hellofunk: jeez, I remember having seen a documentation where it was mentioned

10:19 hellofunk: good movies

10:22 SagiCZ1: hi.. what is the best way to disregard a parameter in #() function?

10:22 ,(#(println "hey") 42)

10:22 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval25/fn--26>

10:23 SagiCZ1: ,((fn [_] (println "hey")) 42)

10:23 clojurebot: hey\n

10:23 SagiCZ1: like this?

10:24 stuartsierra: SagiCZ1: you can't. #() produces a function with an arity based on the %-arguments you used inside #()

10:24 SagiCZ1: stuartsierra: i see

10:32 hyPiRion: well...

10:33 You are a horrible person if you do this, but

10:33 justin_smith: fun in reverse engineering nethack-lisp: since the default nethack command for the letter "b" as input is "gosouthwest", in order to select item b from a popup menu, you need to send "gosouthwest"

10:33 wat

10:33 talk about fixing something in the wrong place...

10:33 hyPiRion: ,((-> [_] #(println "hey")))

10:33 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval25/fn--26>

10:33 hyPiRion: ,((-> [_] #(println "hey")) 1)

10:33 clojurebot: hey\n

10:34 justin_smith: marginally less terrible? #(do % (println "hey"))

10:34 but really, just use fn

10:49 OK, lol. to pick item "a" from a menu, I need to send the string "apply", and to pick item "c" I need to send the string "close". I think I will make a hash map out of the elisp file and never think of this braindamaged nonsense again.

10:49 clojurebot: It's greek to me.

10:49 hyPiRion: I think you missed #emacs and hit #clojure again

10:49 justin_smith: hyPiRion: this is a clojure program using nethack-lisp as a backend

10:50 hyPiRion: oh

10:50 justin_smith: it sends me all my data as sexps

10:50 which is the nice part

10:52 martinklepsch: I'm currently writing a leiningen template and would like to auto-indent a target file after it's been generated — is something like that possible?

10:54 manually indenting feels like being thrown back into stoneage ;)

11:03 justin_smith: can't you make the template such that the substition in-template won't change the indenting?

11:04 martinklepsch: justin_smith: only if there are no multiline substitions if I understood your suggestion correctly

11:07 justin_smith: clojure.pprint has a code dispatch, but I recall hearing bad things about it

11:09 clgv: fipp?

11:26 SagiCZ1: does anybody have any experience with seesaw? i would like to make button bindable.. i guess it has no value, so i would like to bind something to the action function that gets called when button is pressed

11:27 clgv: SagiCZ1: just listen to :action

11:28 SagiCZ1: clgv: button brings up file chooser and i would like to bind some label text to the file name the user chooses

11:29 i guess i dont need to use bind for that

11:29 clgv: SagiCZ1: yeah

11:29 right tool for the job ;)

11:29 SagiCZ1: yeah i am new to this, so im kinda lost

11:30 clgv: I didnt use those binding features - they didn't seem that battle proof

11:31 SagiCZ1: i saw them here, looked neat https://github.com/franks42/clj-ns-browser/blob/master/src/clj_ns_browser/browser.clj

11:34 schmir: SagiCZ1: why don't you use javafx?

11:35 SagiCZ1: schmir: because seesaw uses swing?

11:35 schmir: and you consider that an advantage?

11:36 clgv: schmir: seesaw is an advantage, yes

11:36 SagiCZ1: schmir: i consider the api a huge advantage over swing or interop javafx yes

11:36 clgv: schmir: afaik there is nothing similar to seesaw for javafx

11:38 martinklepsch: clgv: fipp seems like a good option, I just wonder how you would integrate this into leiningens template stuff — would I just render to files that contain {{{profile-clj-contents}} ?

11:38 schmir: ok. I'm just asking. I also develop a gui application and I decided to use javafx instead of seesaw

11:38 clgv: martinklepsch: no idea, I didnt try to write any templates

11:39 schmir: maybe you can steal some of seesaws idea and build a better frontend for javafx ;)

11:40 schmir: well, there's https://github.com/zilti/clojurefx...but I generally just use java interop..the javafx api is fine

11:42 SagiCZ1: clgv: did you find yourself using a lot of atoms in seesaw? for example if user changes some settings, i need to save it to an atom usually

11:44 i think i will find a way around

11:52 clgv: SagiCZ1: In my last GUI with seesaw I had one atom containing all of the state

12:00 EvanR: ,(rest [1])

12:00 clojurebot: ()

12:00 EvanR: ,(rest [])

12:00 clojurebot: ()

12:00 bocaj_: cemerick: What resources are out there to build out ACL (with friend or another library)?

12:03 clgv: EvanR: you want nil? then use `next`, e.g. ##(next [])

12:03 lazybot: ⇒ nil

12:03 EvanR: ,(next [1 2 3])

12:03 clojurebot: (2 3)

12:05 nullptr: ,(let [[h & t] [1]] [h t])

12:05 clojurebot: [1 nil]

12:05 bocaj_: \nick bocaj

12:07 clgv: ,(macroexpand-1 '(let [[h & t] [1]] [h t]))

12:07 clojurebot: (let* [vec__124 [1] h (clojure.core/nth vec__124 0 nil) t ...] [h t])

12:07 clgv: &(macroexpand-1 '(let [[h & t] [1]] [h t]))

12:07 lazybot: ⇒ (let* [vec__20645 [1] h (clojure.core/nth vec__20645 0 nil) t (clojure.core/nthnext vec__20645 1)] [h t])

12:07 jonathanj: hrm

12:08 where does clojure.java.jdbc/with-connection come from?

12:10 java.lang.RuntimeException: No such var: j/with-connection

12:10 nullptr: jonathanj: try clojure.java.jdbc.deprecated?

12:11 context: http://stackoverflow.com/a/22591628/18636

12:12 jonathanj: oh it's deprecated

12:12 bocaj: I'm looking for resources about Access Control Lists or person(identity) and field-level permissions.

12:12 jonathanj: what supersedes it? with-db-connection?

12:13 clgv: jonathanj: passing db explicitely?

12:13 jonathanj: clgv: i'm attempting to make this work: https://github.com/juxt/joplin/blob/master/example/joplin/seeds/sql.clj

12:13 clgv: err db connection ;)

12:32 martinklepsch: when a function prints something, how can I capture that as a string? (asking about https://github.com/brandonbloom/fipp specifically)

12:33 gfredericks: (doc with-out-str)

12:33 clojurebot: "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."

12:33 martinklepsch: gfredericks: thank you!

12:33 gfredericks: np

12:33 martinklepsch: that was also crazy fast :)

12:33 gfredericks: I just happened to be xmonad-channel-surfing

12:33 mearnsh: gfredericks: i'm playing with qubits. is there a better way to get an n (=5) qubit system than this https://www.refheap.com/94244

12:36 (i'm trying to implement grover's algorithm)

12:38 justin_smith: mearnsh: I am halfway disappointed that grover's algorithm isn't based on searching for items by splitting them into NEAR and FAR

12:39 mearnsh: took me a second there

12:42 gfredericks: mearnsh: I don't think merge-systems is necessary to call

12:42 it's sort of an impl detail

12:42 * engblom would need suggestion for a fun one evening project... He is trying to write one such project a week and now it has gone a whole week since last project.

12:42 gfredericks: mearnsh: qubits become part of the same system implicitly as the operate on them

12:43 s/the/you/

12:43 mearnsh: ah

12:45 gfredericks: mearnsh: the whole .data namespace shouldn't be necessary

12:46 mearnsh: ah i see, merge-systems! should do the trick then

12:47 gfredericks: huhwhat?

12:47 oh I see

12:47 clojurebot: excusez-moi

12:48 gfredericks: no even that shouldn't be necessary

12:48 I should make those private

12:48 or make an API namespace or something

12:49 mearnsh: hm, not sure how to get an n-qubit system then

12:49 gfredericks: mearnsh: just make the qubits

12:49 no extra steps necessary

12:49 they communicate with each other in the background implicitly like a good OOP lib

12:51 spooky action at a distance as a service

12:54 mearnsh: well say i have n-qubits all in superpositions (H foo), and i want to know the probability of getting n zeros

12:56 gfredericks: hmm

12:56 at worst you can do the experiment repeatedly

12:57 that sounds tricky to implement in a general way, given the way the code is designed to let you casually introduce new qubits

12:57 i.e., systems are not static

12:58 mearnsh: this gives the exact result https://www.refheap.com/94245

12:59 ok, i see, i'm definitely thinking in terms of a fixed system

12:59 gfredericks: the systems merge and split on demand

13:00 e.g., if you observe one qubit it will remove itself from whatever larger system it was in since it's no longer entangled

13:01 martinklepsch: I was thinking of using with-out-str here to capture somestuff from fipp: https://github.com/technomancy/leiningen/blob/master/src/leiningen/new/templates.clj#L132

13:02 It seems though that leiningen does expect something different. Whenever I do that I get a one line file containing a bunch of \n

13:05 https://gist.github.com/martinklepsch/e43002fa9f2f009f7343

13:06 that's what I currently have. at first I though it might just print it all in one line because it sees it as a single string but removing the quotes didn't help

13:09 EvanR: ,(str "a" nil "b")

13:09 clojurebot: "ab"

13:09 EvanR: is there a way to get not empty string when attempting to show something that might be nil

13:09 gfredericks: ,(str "a" (or nil "not empty string") "b")

13:09 clojurebot: "anot empty stringb"

13:09 justin_smith: ,(pr-str "a" nil "b")

13:10 clojurebot: "\"a\" nil \"b\""

13:10 EvanR: ,(str "a" false "b")

13:10 clojurebot: "afalseb"

13:11 EvanR: ,(str "a" (or false "NIL") "b")

13:11 clojurebot: "aNILb"

13:11 octe_: what would be the most idiomatic to find the index of an object in a list?

13:12 gfredericks: octe_: .indexOf can work; most people will suggest you're probably using the wrong data structure

13:12 octe_: it's not equal

13:12 there's some other criterias..

13:12 EvanR: ,(get 3 [1 2 3 4]

13:12 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

13:12 EvanR: ,(get 3 [1 2 3 4])

13:12 clojurebot: nil

13:13 justin_smith: EvanR: get looks up an index, but your args are reversed

13:13 nullptr: octe_: http://www.mail-archive.com/clojure@googlegroups.com/msg34159.html

13:13 justin_smith: ,(get [:a :b :c] 1)

13:13 clojurebot: :b

13:13 EvanR: ,(get 3 1)

13:13 clojurebot: nil

13:13 EvanR: why doesnt it crash ?

13:13 justin_smith: get is very easy-going

13:14 EvanR: ,(get nil nil)

13:14 clojurebot: nil

13:14 jonathanj: is anyone familiar with joplin?

13:14 octe_: nullptr, thanks, that looks interesting

13:14 where di seq-utils go?

13:16 nullptr: octe_: that i don't know ... don't see any obvious refs

13:17 EvanR: ,doc get

13:17 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)>

13:17 kungi: Why am I getting this exception when I try to run my uberjar compiled clojure project "Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn". project.clj here: https://gist.github.com/2790da0b5c35eb625696

13:18 EvanR: what interface does get use

13:18 gfredericks: ILookup I think

13:18 I think also explicitly supports java.util.Map

13:18 justin_smith: (doc get)

13:18 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

13:18 justin_smith: $source get

13:18 lazybot: get is http://is.gd/WaC1li

13:20 octe_: nullptr, i found keep-indexed

13:20 seems right.

13:20 EvanR: clojure.lang.RT

13:22 gfredericks: &(re-matches #"[ab]" "&")

13:22 lazybot: ⇒ nil

13:22 gfredericks: &(re-matches #"[a&b]" "&")

13:22 lazybot: ⇒ "&"

13:22 gfredericks: &(re-matches #"[a&&b]" "&")

13:22 EvanR: https://github.com/clojure/clojure/blob/clojure-1.7.0-alpha1/src/jvm/clojure/lang/RT.java#L686 first tries ILookup, then checks for null, then checks for Map, then checks for IPersistentSet, checks for String or Array, else null

13:22 lazybot: ⇒ nil

13:22 gfredericks: &(re-matches #"[a&&&b]" "&")

13:23 lazybot: ⇒ "&"

13:23 gfredericks: &(re-matches #"[a&&&&b]" "&")

13:23 lazybot: ⇒ nil

13:23 gfredericks: &c

13:23 lazybot: java.lang.RuntimeException: Unable to resolve symbol: c in this context

13:23 gfredericks: lazybot: I just meant to say "etc."

13:23 EvanR: ill get on coming up with a type for get immediately

13:23 gfredericks: ,(get "abc" 0)

13:23 clojurebot: \a

13:23 gfredericks: huh.

13:24 EvanR: ,(get #{1 2 3 4} 0)

13:24 clojurebot: nil

13:24 EvanR: ,(get #{1 2 3 4} 1)

13:24 clojurebot: 1

14:03 razum2um: anyone knows, why I'm getting "Caused by: java.net.ConnectException: Connection refused" when I route all my traffic via VPN and run "lein repl"? What does it connect to?

14:04 justin_smith: razum2um: lein repl uses nrepl, which opens a port, then it runs an nrepl client connecting to that port

14:04 hellofunk: does anyone use a clj ide that offers argument and arity hints for your own functions that you write? cider does this for core functions but not custom functions

14:05 justin_smith: razum2um: so maybe the vpn or proxy settings interferes with that internal connectint-to-itself logic?

14:05 hellofunk: if your namespaces are loaded properly, they should get hinted in cider, that's been the case for a long time now

14:05 razum2um: justin_smith: but I can connect to localhost via browser, anyway local traffic shouldn't go via vpn

14:06 justin_smith: razum2um: yeah, that was just a guess

14:06 is there any stack trace printed with that exception to show what it was trying to do?

14:07 also, see if "lein run -m clojure.main" gets that error - it will give you a plain clojure repl (not nrepl)

14:07 hellofunk: justin_smith ah, i see that now with a clj file; i use emacs a lot for cljs though and there is no such thing to help with that, i guess.

14:08 justin_smith: hellofunk: yeah, cljs integration is probably going to only work well in lighttable, of the existing environments

14:09 hellofunk: justin_smith i've tried lt many times. i want to like it but mac support is buggy

14:09 justin_smith: razum2um: I think the lein run -m clojure.main approach may avoid the exception you are getting, because nrepl is the only thing in a standard repl that I know of opening sockets

14:10 razum2um: justin_smith: ok, thanks :)

14:15 justin_smith: I mean other than the dep finding thing lein will do for all tasks of course...

14:19 bocaj: ,(+ 1 1)

14:19 clojurebot: 2

14:33 angusiguess: So I'm trying to come up with a plausible example wherein I might use the part of alts! in core.async that puts a value on a channel should there be no available values for consumption.

14:33 Has anyone done such a thing?

14:37 nullptr: angusiguess: yes -- in a toy example though

14:38 (let [[val port] (alts!! [intern-ch t] :default :not-started)] (assert (= val :not-started )))

14:38 above, i'm making sure the intern hasn't started working prematurely (don't ask) -- so i want to make sure that there is nothing on the channel

14:38 t is just a timeout chan for the whole sequence of stuff

14:39 it's a unit test scenario (the intern isn't supposed to start working until told)

14:44 angusiguess: nullptr: thanks!

14:56 edw: ,(+ 1 1)

14:56 clojurebot: 2

15:12 justin_smith: ,(+ (+) (+))

15:12 clojurebot: 0

15:12 justin_smith: ,(+ (*) (*))

15:12 clojurebot: 2

15:21 leandro1: can any pious soul tell me if this way of coding is canonical in clojure? https://www.refheap.com/94249

15:22 llasram: leandro1: Significant heresy I am afraid

15:22 leandro1: i guessed so, llasram :/

15:22 llasram: leandro1: `def` and friends create namespace-level vars, so should not be nested in normal code

15:23 You want `let`

15:23 Bronsa: more likely he needs a loop

15:23 llasram: Your `require`s should be integrated into your `ns` form

15:23 Bronsa: probably that too

15:24 leandro1: And you should eschew `use` for `(require ... :as ...)`

15:24 leandro1: ok about the requires

15:24 Bronsa: leandro1: clojure's vars are not the variables you're used to in other languages

15:24 dbasch: other things: you want a case instead of chain of ifs, nil? instead of = nil, etc

15:24 llasram: dbasch: I think that'll somewhat fall out as part of fixing the `def` thing

15:24 edw: ,(Math/exp (* Math/PI (Math/sqrt (- (+) (*)))))

15:24 clojurebot: NaN

15:25 edw: clojurebot needs to learn about complex numbers.

15:25 dbasch: system/exit in the middle is terrible too

15:25 kenrestivo: o_0

15:25 leandro1: i'm just starting, but my sensation about `let` is i can't access it outside ... so i put those def

15:25 llasram: dbasch: Maybe be a bit softer on the newbies :-)

15:26 dbasch: llasram: ok, System/exit in the middle of a function is usually not the best idea :)

15:26 llasram: leandro1: You cannot, but that's good. If you have things you actually want to persist and use across multiple definitions, then `def` is fine, but should be at top-level, not nested

15:27 leandro1: As is, your `def`s will re-run every time `-main` is called.

15:27 kenrestivo: i've heard from a few java people who are used to making a program that starts, does stuff, then exits. then they do that in clojure, wait 20 minutes for the program to load, go "meh, clojure is too slow", and leave. getting into the mindset of repl-driven development might be better.

15:27 dbasch: leandro1: in this particular case you don’t need any state

15:27 Bronsa: leandro1: I'd encurage you to read some introductory guide on clojure to get used to avoid mutable state

15:28 kenrestivo: leandro1: and, just try running lein repl, and playing around in the repl, experimenting, interactively. might take some getting used to but, i find, well worth it.

15:29 leandro1: i think i must start by avoiding changing state

15:29 gotta read about that

15:41 thank you all

15:45 kenrestivo: is there a way to avoid stuttering in a loop/recur where the initial state needs to be populated the same way the recur does? i.e. (loop [data (get-data)] (do-stuff data).... (recur (get-data)))

15:46 that just smells funny to me

15:46 Bronsa: (loop [] (let [data (get-data!)] .. (recur)))

15:49 kenrestivo: hmm, well, my example isn't complete. i meant (loop [prev (get-data)] (let [cur (get-data)] (do-stuff prev cur).... (recur cur))

15:50 i'm being OCD. there's probably no way around it.

15:50 jonathanj: is there somewhere i can specify project-wide settings that i can read from anywhere in my project?

15:50 for example, i need to specify my database URI for various environments for joplin in project.clj

15:51 kenrestivo: jonathanj: i use environ, but there may be other ways

15:51 https://github.com/weavejester/environ

16:04 seangrove: (doc mapcat)

16:04 clojurebot: "([f] [f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection. Returns a transducer when no collections are provided"

16:07 jonathanj: kenrestivo: thanks, that looks useful

16:08 kenrestivo: if i needed something out of the environ to specify in a map in project.clj, how would i achieve this?

16:09 kenrestivo: i'm not sure i understand that.

16:09 jonathanj: so joplin seems to require me to add a :joplin key to the project macro, that key needs to contain the database URI

16:10 i'm not sure how i refer to a value from environ at that point

16:10 kenrestivo: oh, joplin is opinionated about where it gets its config from? hmm.

16:11 yeah, environ might not help in that case

16:11 i think the solution is to hack joplin to accept its config from places other than project.clj :-/

16:12 because, what, are you going to commit your database passwords to git in your project.clj? it seems kind of inflexible to me.

16:12 jonathanj: that's what i was wondering too

16:14 kenrestivo: most db's i've used accept config as args to a setup function. you can then go get that config from anywhere: a conf file, lein environ, etc. i don't know why joplin is tightly coupled to project.clj. maybe it supports other ways

16:14 might want to look at the source and see how exactly it fishes that config out of the project map. there might be an undocumented function you can use to pull config from elsewhere instead

16:16 or, you know, use a different library, that's usually an option

16:23 justin_smith: remember that other files are merged into project.clj

16:23 and more can be

16:24 for example I have certain credentials in my ~/lein/profiles.clj that are then visible to projects

16:24 jonathanj: how do you access data in project.clj from somewhere else?

16:25 in other words, when your ~/.lein/profiles.clj is merged into project.clj, how do you make use of that data?

16:25 SagiCZ1: i want to do an expensive computation in seesaw, i have a function which returns some data.. do i use clojures future? the ui thread must not be blocked

16:26 justin_smith: SagiCZ1: yeah, future is a convenient way to do it. It uses a thread pool too, which is nice.

16:26 SagiCZ1: so i call the function wrapped in future.. i get the reference which i can deref.. but when derefing in ui thread it would block it right?

16:26 justin_smith: (doc realized?)

16:26 clojurebot: "([x]); Returns true if a value has been produced for a promise, delay, future or lazy sequence."

16:27 justin_smith: don't deref until it is done

16:27 mindbender1: can't core.async be used here?

16:27 justin_smith: it could, but it doesn't seem neccessary

16:27 SagiCZ1: justin_smith: and whats the common construct with realized? infinite loop?

16:27 justin_smith: ?

16:27 realized? tells you if a future is done

16:28 SagiCZ1: what if it says its not done

16:28 justin_smith: so you could poll, for example

16:28 yeah, poll and sleep in a loop

16:28 not infinite though

16:29 something like (loop [] (if (realized? f) (do-something @f) (do (Thread/sleep 100) (recur))))

16:29 littleli_: I don't think this helps

16:29 justin_smith: but if you are looping, you may as well block

16:29 SagiCZ1: isnt there some more idiomatic way to do this? like hooking some listener to the future?

16:29 littleli_: I would point at SwingUtilities.invokeLater

16:29 justin_smith: SagiCZ1: the action you want can be part of the future

16:29 SagiCZ1: littleli_: invoke later blocks the ui thread

16:30 justin_smith: hey thats a good idea

16:30 at the end of the future, i will just call on the ui thread to update the gui

16:31 (inc justin_smith)

16:31 justin_smith: "the end of the future" sounds pretty ominous

16:31 lazybot: ⇒ 151

16:32 littleli_: justin_smith: yeah :)

16:34 dbasch: justin_smith: the “end of history” sounded the same way, yet it turned out to be meaningless

16:34 justin_smith: heh

16:39 kenrestivo: am i reading the docs to when-let right, that it'll take an optional test?

16:39 i.e. i'd love to have (when-let [foo some-map] (not (empty? foo) (do-stuff...))

16:40 gfredericks: no

16:40 llasram: kenrestivo: I'm afraid not. You'd want the maybe monad (which IMHO should have an in-core specialized version like we do with the sequence monad...)

16:40 kenrestivo: because (let [foo (some-map)] (when (not (empty? foo)) (do-stuff ...)) is bugging me in the OCD mood i'm in

16:41 gfredericks: ,(doc not-empty)

16:41 clojurebot: "([coll]); If coll is empty, returns nil, else coll"

16:41 kenrestivo: well, yeah, thanks, but it's still a (let ... (when

16:42 qerub: kenrestivo: What about (when-let [foo some-map] (when (seq foo) (do-stuff …)))?

16:42 kenrestivo: funny "empty?" but it's not "not-empty?"

16:42 justin_smith: kenrestivo: maybe (some-> ...)

16:42 edw: kenrestivo: No, it returns the original non-empty object.

16:42 justin_smith: ,(some-> "hello" .getBytes)

16:42 clojurebot: #<byte[] [B@16fbaff>

16:42 kenrestivo: oh! cool

16:42 justin_smith: ,(some-> nil .getBytes)

16:42 clojurebot: nil

16:42 edw: so: (when-let [foo (not-empty some-map)] (blah...))

16:43 kenrestivo: not-empty is perfect, thanks!

16:43 edw: kenrestivo: Yeah, the absence of the question mark makes all the difference!

16:46 kenrestivo: it's an interesting function, seems specifically designed for use with if-let and when-let

16:46 edw: If you find yourself writing ugly code, write a function to make it not ugly.

16:47 Wishful thinking is an essential part of writing beautiful code.

16:48 kenrestivo: heh, when i find myself writing ugly code, i start looking around for what i might be doing wrong

16:49 which usually means looking for a funciton that someone else wrote that'll make it not ugly

17:06 joobus: does anyone have any insight on using clojure-android? maybe an example app or a tutorial I could look at?

17:07 I want to instantiate a webview, but need to set a couple properties on it before displaying. The neko ui stuff isn't so clear.

17:20 SagiCZ1: whats the shortest way to avoid repeating foo here?

17:20 (if (= (foo) 0) 42 (foo))

17:22 gfredericks: I think just let

17:23 SagiCZ1: gfredericks: thats what i figured, ok

17:23 gfredericks: ,(defn foo [] 0)

17:23 clojurebot: #'sandbox/foo

17:23 gfredericks: naw nevermind

17:27 Bronsa: SagiCZ1: I like `fix` from useful.fn

17:28 it lets you write (fix (foo) zero? 42 identity)

17:28 SagiCZ1: Bronsa: what does it do in general? and where is useful.fn?

17:28 Bronsa: actually looks like you could drop the identity

17:29 SagiCZ1: https://github.com/amalloy/useful

17:31 SagiCZ1: Bronsa: thank you very much

17:42 kenrestivo: joobus: i wrote one http://github.com/kenrestivo/spazradioapp

17:46 stain: kenrestivo: sweet

17:49 kenrestivo: why was this one Java class needed..? https://github.com/kenrestivo/spazradioapp/blob/master/src/java/org/spaz/radio/SplashActivity.java

17:49 ah, it loads clojure :)

17:50 kenrestivo: yeah, that's to cover for the loooonnnnnggg load time

17:50 stain: instead of compiling it?

17:50 kenrestivo: clever hack that the clojure-android guys created

17:50 well, it's compiled

17:50 the whole app is aot'ed

17:50 stain: ah.. but just kickstarting the RT takes forever on a phone?

17:50 kenrestivo: but.... clojure takes forever to load, that's a well-documented problem

17:51 stain: can't we do some kind of caching or something

17:51 kenrestivo: https://www.youtube.com/watch?v=8NUI07y1SlQ , fyi

17:51 yeah, there's an effort, which is rich-blessed, to create a lean runtime that loads faster

17:51 i don't know the status of it tho

17:53 stain: I can imagine you could do similar to Windows and some linux distros.. if it's the same runtime files and environment as last time, just preload the saved state (.classes and whatever)

17:53 kenrestivo: just reading that code for the first time in a while, lol, bitcoin, that's so 2013.

17:53 stain: EVERYTHING needs bitcoins!

17:53 I never got a bitcoin :(

17:53 kenrestivo: it did in 2013

17:53 stain: didn't even experience the crash

17:53 kenrestivo: it was a wild ride for a while

17:54 now everyone has as many tulips as they need, i suppose

17:54 stain: well, you wouldn't get an actual bitcoin could you.. it's like £241

17:54 exactly.. the drug dealers have enough to have their economy going

17:54 kenrestivo: http://en.wikipedia.org/wiki/Tulip_mania

17:54 stain: yet still we have tulips..

17:56 kenrestivo: anyway, there's an example android app in clojure. it was a lot of fun.

18:05 teahauz: do source maps get cached at all for cljs...or is chrome making a call to retrieve the latest source map every time?

18:11 hodlr: anyone have experience with instrumenting clojure with new relic?

18:13 TEttinger: new relic is that expensive site analytic that had very misleading results on heroku for some time?

18:13 x1337807x: TEttinger: Yup, though expensive is relative. :)

18:14 hodlr: I found a bunch of blog posts by googling 'clojure new relic' and this project seems promising: https://github.com/TheClimateCorporation/clj-newrelic

18:15 TEttinger: http://genius.com/James-somers-herokus-ugly-secret-annotated it seems rather expensive for one of heroku's larger customers

18:16 justin_smith: TEttinger: I made some progress on that nethack-lisp client - I was able to hack together some code that extracts the key / command bindings from elisp (that whole thing where to send "b" to select barbarian from the character creation menu, you need to send the string "gosouthwest" since b means sw in the game) https://github.com/noisesmith/nethacker/blob/master/src/org/noisesmith/nethacker/keys_wat.clj

18:16 hodlr: x1337807x: Im actually using that right now. My agent "works" fine it just doesbn't log anything like web requests and exceptions. when I use the clj-newrelic trace macro to trace functions it works fine but I was looking for a little bit more

18:17 TEttinger: nice justin_smith, starred

18:18 justin_smith: using the clojure reader to get data from elisp feels ugly as fuck - but it works!

18:20 x1337807x: hodlr: Someone at NR recently wrote up some experimental clojure instrumentation for his innovation day project. I've summoned him to the channel, he should be here shortly.

18:20 hodlr: x1337807x: rockin!

18:21 x1337807x: The code he wrote isn't necessarily something we can make available but I'd be he'll at least have some advice.

18:21 hodlr: nice

18:30 Balveda: anyone have any experience with play-clj.g3d?

18:51 david234567: Hello! I'm looking for some advice on a server/client project. I'm confused

18:51 Guest81432: how so?

18:52 david234567: I have a project where I need to send information to a server but I'm totally confused how to approach making a server and client (data is sent over the internet)

18:52 Guest81432: um. i have the strangest nick today. this requires some looking into.

18:52 --jkj

18:53 david234567: All I want is to be able to have a thread I can shit text into which can be read at the other end, unless there's a better way

18:54 {blake}: RabbitMQ?

18:56 david234567: That seems a bit too heavy for what I need to do

18:59 {blake}: Lamina?

18:59 It's kind of a broad question.

18:59 TEttinger: even ##(doc slurp) can read from URLs

18:59 lazybot: ⇒ "([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."

19:00 TEttinger: not lazily

19:08 david234567: Sorry if it's a little broad. I have several servers all over the place I want to coordinate by implementing a client/server on each physical server to manage tasks

19:09 I don't really know what's the best way to accomplish this

19:09 What I thought I could do was establish websockets between each server and read/write to that socket

19:09 but I don't know if that's a thing that I can do, or if that's the best way

19:12 dbasch: david234567: without any further context, that’s what distributed message queues are for

19:16 david234567: Thank you dbasch, I googled around and there's a couple libraries floating around for this sort of thing.

19:57 afhammad: Is there the equivilent of a ruby * splat in clojure?

19:59 nullptr: What does it do in ruby?

20:00 afhammad: it unwraps the array and passes the elements as arguments. for example hello(1, *[2,3]) is like saying hello(1,2,3)

20:01 nullptr: You could write a macro for that, but I'm not aware of one that exists.

20:02 afhammad: basically i want to do [:something (splat [1 2])] and get the same result as (concat [:something] [1 2])

20:02 dbasch: afhammad: in clojure, that would be (apply hello 1 [2 3])

20:02 (doc apply)

20:02 clojurebot: "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."

20:03 afhammad: i keep forgetting about apply, thanks. I think that works in the function all scenario but not the vector one I mention above

20:04 call*

20:09 TEttinger: afhammad, well a function can only return one value, so what would splat return?

20:10 it can return a sequence or vector, but that's what you started with

20:11 afhammad: TEttinger, ur right, dont see how it would be possible in clojure

20:11 TEttinger: you could still do what apply does and have splat be before the rest of the stuff you want in one sequence

21:09 rritoch: Hi, does anyone know how to set the classloader for namespaces loaded using clojure.core/load-reader? I have set the thread current context loader, and the Compiler/LOADER but that didn't change the result of (.getClassLoader (class (find-ns 'my-ns)))

21:10 hiredman: rritoch: have you looked at the value of (class (find-ns 'my-ns)) ?

21:10 (it may surprise you)

21:11 rritoch: hiredman: Yes, and it is still returning the application class loader instead of the dynamic class loader that I've set

21:11 hiredman: rritoch: no no, no the class loader bit

21:11 (class (find-ns 'my-ns))

21:12 namespaces are instances of a class clojure.lang.Namepsace, a class loaded when the clojure runtime is loaded (likely with the application class loader)

21:13 they are not instances of their own class

21:14 rritoch: hiredman, I'm aware that they're all clojure.lang.Namespace, so how do I get load-reader to use a clojure.lang.Namespace class from a specific class loader?

21:15 hiredman: rritoch: what is it you actually want to do?

21:16 rritoch: hiredman: This is for an OSGi implementation. I am registering the namespace as an OSGi service, and it needs to have the appropriate class loader so that when I make calls to that service I can use the classloader of the service to set the appropriate classloaders when calling methods on that service.

21:18 hiredman: rritoch: it is unlikely that you are actually registering the namespace as an osgi service, I don't know osgi, but my guess is you have a to register a class

21:18 namespaces are not classes

21:18 rritoch: hiredman: In OSGi you don't register classes as services, you register objects

21:19 I've setup the following to make calls on those services

21:19 https://github.com/rritoch/clj-grid-kernel/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/kernel.clj#L788-L806

21:19 jkjd: wouldn't be too surprised if clojure was a bit short on the enterprisey java class loader goodness. clojure software tends to be very simple on that front compared to glassfish and sorts

21:20 hiredman: rritoch: given that clojure is already loaded, clojure.lang.Namespace is already loaded as part of the clojure runtime, so the namespace "object" representing the namespace is going to be an instance of that clojure.lang.Namespace

21:21 the objects that represent clojure namespaces as values all are instances of the same class, clojure.lang.Namespace

21:22 if you want to load multiple different classes named clojure.lang.Namespace then you need multiple isolated clojure runtimes

21:22 jkjd: can have only one clojure?

21:22 hiredman: you can have multiple clojure runtimes, but you need to isolate each one via classloader monkeying

21:23 which osgi should be able to do

21:23 rritoch: hiredman: That seems to be exactly what I'm trying to do. I want each bundle to be running in it's own environment, with it's own set of dependencies and namespaces.

21:23 hiredman: the thing to keep in mind is, it will be an isolated runtime, so you will basically need to do interop/serialization to communicate

21:23 rritoch: have you looked at the existing clojure osgi stuff?

21:24 rritoch: I'm setting these classloaders, and calling load-reader from within the OSGi activator class's start method.

21:24 hriedman: No, I didn't know there was any, I've been learning this with just trial and error.

21:24 hiredman: rritoch: you are calling load-reader from the wrong runtime

21:25 you need to call it from the runtime that is in the isolated classloader

21:27 rritoch: my understanding is there have been many attempts and people tend to give up, because 1. no one in the larger clojure community cares much about osgi so accolades are in short supply and 2. osgi is very static and clojure is less so so the match up leaves one unsatisfied

21:27 that is just my observation from hanging out in #clojure, like I said I don't know osgi

21:28 rritoch: hiredman: Well, I've been working on this system for months, and previously when I was using gen-classes things were going much smoother. To make the system more dynamic I'm switching the platform from gen-class to namespace based, hense why I'm registering namespaces as OSGi services.

21:29 But how do I switch runtimes?

21:29 Would eval work?

21:30 hiredman: rritoch: you have to get a copy of the clojure.lang.RT class from the classloader, then use reflection to call its .var method to get vars, and use reflection to invoke them

21:30 not entirely unlike https://github.com/hiredman/polycosm/blob/master/src/polycosm/primus.clj#L95-L115

21:30 rritoch: hiredman: Thanks :) I'm fairly sure I can do that, and I can see how that would work

21:31 (inc hiredman)

21:31 lazybot: ⇒ 64

21:31 jkjd: I'd probably start with a java facade and have java call clojure rt on the edges until I get it... also having some debugging to figure out which class loader you are dealing with might be useful

21:31 put it also in sfl4j MDC or something

21:33 supersym: public final class UrlEscapers, static Escaper urlFragmentEscaper (or any other of those static methods) can anyone tell me what the correct form is?

21:33 dot-form, or do I need a proxy for that? I never quite seem to know when to use what yet with regards to interop

21:33 TEttinger: supersym: UrlEscapers/urlFragmentEscaper perhaps?

21:33 ,Math/PI

21:33 clojurebot: 3.141592653589793

21:34 supersym: my first try... then tried about all combo's I think :S

21:34 TEttinger: PI should also be a static member, of the Math class

21:34 oh

21:34 it isn't public is it

21:34 is there a getter?

21:34 supersym: oh

21:34 wait... I see, I shouldnt pass it any args ofc

21:37 I need to dig a bit deeper/better in those API docs, since the type it implements has the escape method

21:37 so I'm good, thanks :)

21:45 wildnux: hi,

21:45 how can i check if the passed argument is a sequence or a single element?

21:46 justin_smith: wildnux: ##(doc coll?)

21:46 lazybot: ⇒ "([x]); Returns true if x implements IPersistentCollection"

21:46 clojurebot: Gabh mo leithscéal?

21:46 TEttinger: wildnux: sequential? may be useful too

21:46 (doc sequential?)

21:46 clojurebot: "([coll]); Returns true if coll implements Sequential"

21:46 TEttinger: ,(sequential? (java.util.ArrayList.))

21:46 clojurebot: false

21:46 wildnux: what is the difference between sequential? , seq? and coll?

21:47 TEttinger: ,(sequential? (doto (java.util.ArrayList.) (.add 1))

21:47 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

21:47 TEttinger: ,(sequential? (doto (java.util.ArrayList.) (.add 1)))

21:47 clojurebot: false

21:47 TEttinger: hm

21:47 ,(coll? (doto (java.util.ArrayList.) (.add 1)))

21:47 clojurebot: false

21:47 TEttinger: ,(seq? (doto (java.util.ArrayList.) (.add 1)))

21:47 clojurebot: false

21:47 TEttinger: ,(seq (doto (java.util.ArrayList.) (.add 1)))

21:47 clojurebot: (1)

21:48 jzp113: hi

21:48 TEttinger: hey jzelinskie

21:48 justin_smith: wildnux: coll? is for persistent data structures in general, sequential? is for the ones that are ordered, and seq? tests if it is specifically a seq

21:48 TEttinger: jzp113, rather

21:48 jzp113: i think clojure is fun

21:48 justin_smith: &(map seq? [[] () ""])

21:48 lazybot: ⇒ (false true false)

21:48 wildnux: justin_smith: thanks,

21:48 jzp113: but lt's hard to start

21:48 wildnux: one more question, (seq? '()) returns true

21:48 ,(seq? '())

21:48 clojurebot: true

21:48 justin_smith: right, but (seq? []) is false

21:49 TEttinger: jzp113, indeed. it took me a while, but it got easier. have you tried Brave Clojure and going through 4clojure problems?

21:49 justin_smith: because () is a seq (an empty one)

21:49 &(type ())

21:49 lazybot: ⇒ clojure.lang.PersistentList$EmptyList

21:49 TEttinger: ,(seq '())

21:49 clojurebot: nil

21:49 TEttinger: ,(seq [])

21:49 clojurebot: nil

21:49 TEttinger: ,(seq [1])

21:49 clojurebot: (1)

21:49 TEttinger: ,(seq '(1))

21:49 clojurebot: (1)

21:49 TEttinger: ,(seq 1)

21:50 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

21:50 TEttinger: hm

21:50 wildnux: justin_smith: i am trying to write a function, which will take a sequence or just a single item, and then recursively work on each item if sequence is passed, how do i know the end of sequence in this case?

21:50 TEttinger: seqable is a common extension thing

21:51 justin_smith: ,(map not-empty [{} () {:a 0} [1] '(a b c)]) ;; wildnux

21:51 clojurebot: (nil nil {:a 0} [1] (a b c))

21:51 jzp113: TEttinger, yeah ,I was new

21:52 TEttinger, yeah ,I don't know how to start.just find a book of clojure then read it?

21:52 justin_smith: wildnux: not-empty will give you nil for empty inputs, and then nil is helpfully falsey

21:52 &(if nil :wat :ok)

21:52 lazybot: ⇒ :ok

21:52 wildnux: justin_smith: if i had to check for single item or a non-empty list?

21:52 TEttinger: jzp113, brave clojure may be your best shot for now, it's a good starting place

21:54 wildnux: (if (single-item? x) :single-item :non-empty-seq)

21:54 this is what i am trying to do

21:54 x can be '(1 2 3 4)

21:54 or x can be 1 as well

21:54 justin_smith:

21:54 ,(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello"]) ;; lets see if this works

21:54 clojurebot: (nil nil {:a 0} [1] (a b c) ...)

21:55 jzp113: TEttinger,how to download the pdf?

21:55 justin_smith: wildnux: something like the above would be a start

21:55 the part clojurebot truncated was the non-collections coming through unmodified

21:56 TEttinger: jzp113: the book is a paid thing, but the site will always be free. of course you could just download each page's html and save it for offline use.... http://www.braveclojure.com/

21:56 &(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello"])

21:56 lazybot: ⇒ (nil nil {:a 0} [1] (a b c) a "hello")

21:57 TEttinger: &(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.ArrayList.)])

21:57 lazybot: ⇒ (nil nil {:a 0} [1] (a b c) a "hello" [])

21:57 TEttinger: that's odd

21:57 &(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.HashMap.)])

21:57 lazybot: ⇒ (nil nil {:a 0} [1] (a b c) a "hello" {})

21:57 justin_smith: TEttinger: ArrayList isn't a persistent collection

21:57 TEttinger: I was just not sure why it showed [] and {}

21:57 justin_smith: coll isn't just for collections, it's for persistent ones

21:58 TEttinger: how would you check if something implements the Collection interface?

21:58 justin_smith: ,(java.util.HashMap.)

21:58 clojurebot: {}

22:00 justin_smith: &(contains? (supers (class (java.util.ArrayList.))) java.util.Collection) ;; TEttinger

22:00 lazybot: ⇒ true

22:01 llasram: ,(instance? java.util.Collection [])

22:01 clojurebot: true

22:01 llasram: ,(instance? java.util.Collection {})

22:01 clojurebot: false

22:01 justin_smith: &(contains? (supers (class {})) java.util.Collection)

22:01 lazybot: ⇒ false

22:02 justin_smith: &(supers (class {}))

22:02 lazybot: ⇒ #{clojure.lang.IHashEq java.io.Serializable clojure.lang.IEditableCollection clojure.lang.APersistentMap clojure.lang.IPersistentMap clojure.lang.Associative java.lang.Runnable java.util.concurrent.Callable java.lang.Iterable clojure.lang.IFn clojure.lang.IPersistent... https://www.refheap.com/94259

22:02 llasram: Maps aren't Collections (oh, you so crazy)

22:02 justin_smith: interesting

22:02 TEttinger: what

22:02 justin_smith: http://stackoverflow.com/questions/2651819/why-doesnt-java-map-extends-collection

22:03 a bad decision, IMHO

22:04 &(contains? (supers (class #{})) java.util.Collection)

22:04 lazybot: ⇒ true

22:04 TEttinger: &(map #(or (and (not (instance? java.lang.Iterable %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.HashMap.)])

22:04 lazybot: ⇒ (nil nil {:a 0} [1] (a b c) a "hello" {})

22:05 TEttinger: ,(instance? java.lang.Iterable {})

22:05 clojurebot: true

22:05 TEttinger: ,(instance? java.lang.Iterable (java.util.HashMap.))

22:05 clojurebot: false

22:05 TEttinger: hm

22:06 &(supers (class (java.util.HashMap.)))

22:06 lazybot: ⇒ #{java.io.Serializable java.lang.Cloneable java.util.AbstractMap java.lang.Object java.util.Map}

22:06 TEttinger: &(supers java.util.Map)

22:06 lazybot: ⇒ nil

22:06 TEttinger: &(supers java.util.AbstractMap)

22:06 lazybot: ⇒ #{java.lang.Object java.util.Map}

22:06 xeqi: ,(.add #{} "x")

22:06 clojurebot: #<UnsupportedOperationException java.lang.UnsupportedOperationException>

22:06 TEttinger: waaaat

22:08 wildnux: ,(.add (java.util.HashSet.) "x")

22:08 clojurebot: true

22:08 wildnux: :)

22:13 TEttinger: &(map #(or (and (not (some #{java.util.Map java.util.Collection} (supers (class %)))) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.HashMap.) (java.util.ArrayList.)])

22:13 lazybot: ⇒ (nil nil {:a 0} [1] (a b c) a "hello" nil nil)

22:14 justin_smith: nice, that's pretty general

22:16 rritoch: hiredman: Does this look like it will switch runtimes for loading correctly? (clojure.lang.Reflector/invokeStaticMethod (.loadClass (.getContextClassLoader (Thread/currentThread)) "clojure.lang.Compiler") "load" (object-array [(InputStreamReader. (.openStream (.toURL r)))]))

22:26 Didn't work

22:35 Looks like I need to reflect find-ns also, but I would think find-ns SHOULD fail to find the namespace if it was loaded by a compiler that came from a different classloader.

22:36 llasram: rritoch: You really should just need `var`. A correctly-initialized RT will also have loaded the `clojure.core` namespace, allowing you to get the Var for `require`

22:38 (Well, and the Symbol class)

22:41 rritoch: llasram: I haven't tried to use require yet, but that is a good idea. I have the code set to use load-reader from io/resource ... when find-ns returns null, but I haven't tried to do it with require which does make more sense. Will require use the current Context Loader?

22:41 llasram: rritoch: It should use the RT/baseLoader

22:44 rritoch: llasram: I have Compiler/LOADER bound to the current Context Classloader when this code is entered, so hopefully require will do what I want it to

22:45 llasram: Sounds plausible at least

22:46 rritoch: Basically I"m just trying to get (.getClassLoader (class *ns*)) to show my selected context classloader, seems like it would be a simple task, but so far it's been very elusive. But I haven't tried require yet.

22:49 Require should also be easy to execute as an eval also, so it gives me a few options to try.

22:49 prachetas: llasram: what is RT?

22:50 RunTime - got it

22:50 clojurebot: Gabh mo leithscéal?

22:52 prachetas: s/ - got it/?

22:59 llasram: prachetas: clojure.lang.RT

22:59 Where yeah, "RT" stands for "runtime (library)"

23:09 prachetas: thanks!

23:10 rritoch: Well it looks like require brings me somewhat closer, if I call require directly the namespace still has the wrong classloader, but if I run require using (eval list 'clojure.core/require 'my-ns) I'm getting a class not found exception. Seeing I haven't bound Compiler/LOADER in the target runtime maybe all I need to do is bind Compiler/LOADER in the eval.

23:12 Anyhow, thanks for the assistance. I should find a way to get this to work eventually, but as of now the solution is still hiding

Logging service provided by n01se.net