#clojure logs

2014-12-01

00:13kenrestivoi'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
00:14kenrestivoi have to rm -rf target/trampolines before running every time, to avoid this error
00:27rritochCan 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)
00:27lazybotjava.lang.RuntimeException: Unable to resolve symbol: cat in this context
00:27rritoch,((cat inc) 1)
00:27clojurebot2
00:58justin_smith(doc cat)
00:58clojurebot"([rf]); A transducer which concatenates the contents of each input, which must be a collection, into the reduction."
00:58justin_smithrritoch: 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
00:59justin_smith$grim clojure.core/cat
00:59lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/cat
00:59justin_smithgrimoire doesn't have that clojure version yet, sadly
01:00rritochjustin_smith: I read the documentation, but I don't see how to use it anywhere
01:01rritochjustin_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
01:01justin_smith,(sequence (comp cat (map inc)) [[0 1 2] [3 4 5]])
01:01clojurebot(1 2 3 4 5 ...)
01:01justin_smithit does that
01:02justin_smithyou use it in combination with another transducer
01:02justin_smithof course you would just use mapcat for that example
01:03rritochThanks, 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
01:03justin_smith,(sequence (comp cat (filter even?)) [[1 2 3] [4 5 6] [7 8 9]])
01:03clojurebot(2 4 6 8)
01:04justin_smithnote that here I could not have used mapcat
01:04justin_smithwithout an ugly anonymous function
01:04justin_smithyeah, cat makes no sense by itself
01:04justin_smithit only makes sense with other functions I think...
01:04justin_smithhmm
01:05justin_smith&(sequence cat '[[a b c] [d e f]])
01:05lazybotjava.lang.RuntimeException: Unable to resolve symbol: cat in this context
01:05justin_smith,(sequence cat '[[a b c] [d e f]])
01:05clojurebot(a b c d e ...)
01:05justin_smithnote that here, it acts just like (apply concat)
01:05justin_smithbut it's a transducer, not a lazy seq
01:09rritochjustin_smith: Well, eventually the differences should probably be resolved for common cases
01:09justin_smithI don't understand what you mean by that
01:10rritochI'm trying to find the example, but I found a case where I had to cast to seq before casting to vec
01:10justin_smiththe point here is we want something that acts like concat, but isn't a lazy-seq
01:10justin_smithfor perf reasons
01:12rritochAhh, here's the case I ran into
01:12justin_smithyou may want something other than sequence for that though
01:12justin_smith(doc sequence)
01:12clojurebot"([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
01:12rritoch,(def a (map (partial * 2)))
01:12clojurebot#'sandbox/a
01:12rritoch,(def c (eduction a [1 2 3]))
01:12clojurebot#'sandbox/c
01:13rritoch,(vec c)
01:13clojurebot#<RuntimeException java.lang.RuntimeException: Unable to convert: class clojure.core.Eduction to Object[]>
01:13rritoch,(seq (vec c))
01:13clojurebot#<RuntimeException java.lang.RuntimeException: Unable to convert: class clojure.core.Eduction to Object[]>
01:13justin_smithinteresting
01:13rritochmm
01:13rritochHmm
01:13justin_smithyou probably want (vec (seq c))
01:13justin_smiththat may be a bug?
01:13rritochyeah, lol
01:13rritoch,(vec (seq c))
01:13clojurebot[2 4 6]
01:13justin_smith,(into [] c)
01:13clojurebot[2 4 6]
01:14justin_smithor that
01:14rritochThat was an unusual case I ran into that should probably be automated in vec
01:14justin_smithI think using into is canonical with transducers in general
01:14rritochSure, there are easier ways, but it seems wierd that you can't cast the eduction result to a vector
01:15rritochWith the vec function that is...
01:15rritochTo be clearer, vec should be made transducer aware
01:19rritochSo what about these "transducer processes", are there examples of that someplace? The documentation was a bit vague
01:20kenrestivois 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?
01:57allenj12yea 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
01:59allenj12the :recursions is the layers i mentioned above
03:55fairuzhmm 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
04:00danielfairuz: i would have thought you restrict cross domain access at the webserver level, not in liberator
04:04fairuzdaniel: I did enable cors. If I don't enable it, I will get the usual cross domain error
04:05fairuzI'm thinking to put :options alongside :get in the allowed-methods. So just wondering why it still works even it's not allowed
04:06danieli didnt know options was meant to restrict cross domain access
04:06fairuzNo, it's not for restricting access
04:07fairuzWhen a cross origin request is made, the browser will send a preflight request to the server
04:07fairuzThis preflight request is using OPTIONS http method
04:07fairuzSo basically the browser is sending 2 requests instead of one
04:15danieli see fairuz
04:16danieldon't know the answer then, would be interested as well
04:28fairuzohh.. it's just that I'm doing a simple request, that will not make the browser send the preflight
04:28fairuzI'm seing it's blocked now with a proper request
04:28fairuz*seeing
04:28pllxfairuz did you just have an epiphany
04:49sveriHi, Is there a way to get the line ending character that is used in a file programmatically?
04:51llasramsveri: ##(System/getProperty "line.separator")
04:51lazybotjava.security.AccessControlException: access denied ("java.util.PropertyPermission" "line.separator" "read")
04:51llasramGee, thanks lazybot
04:51llasramAnyway, on JVM Clojure that should hook you up
04:57sverillasram: hm, but AFAIR the line ending may be a different one in a specific file?
04:58llasramsveri: What you are looking for is known as "magic"
04:58llasramI suggest sacrificing a goat. That usually works.
04:59llasramYeah, maybe there's some heuristic method akin to character-encoding detection. It does seem like it would be somewhat straightforward.
04:59llasramI do not however know of any library which implements such detection
05:14sverillasram: well, I sacrificed that goat, its still not working :D
05:15sverillasram: however, I have not found one either
05:16llasramsveri: Well, the obvious algorithm should be pretty easy try out on your data
05:16llasramPoor goat...
05:25sverillasram: Well, actually no goat was harmed during the sacrification, they only got drugged
05:29sveriWhat 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 :-)
05:30llasramkk; good luck! :-)
06:16CookedGryphonanybody got any hints for testing things involving timeouts in core.async?
06:52tsdhHi. 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?
07:04tsdhOh, it seems I can do just (let [common #"foo", special (re-matcher (str common #"bar"))...]...)
07:15mearnshtsdh: re-matcher should be avoided because the Matcher object it returns mutates in a non-thread-safe way
07:16clgvtsdh: there is `re-pattern`
07:16mearnshyeah that's what you want
07:16clgv,(re-pattern "bla")
07:16tsdhclgv: Ah, yes, I actually use re-pattern. Just a typo.
07:16clojurebot#"bla"
07:16tsdhThx
08:22dysfundoes anyone know of any way of efficiently serialising simple tree transforms?
09:11ordnungswidrigdysfun: what do you mean by "tree transforms"?
09:17dysfunordnungswidrig: 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
09:18dysfunso 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
09:20ordnungswidrigI see. What are those "simple transforms"?
09:20dysfunthings like "element foo had child added" (with attached information). or "element bar child 3 (textnode) mutated"
09:20gfredericks(inc TEttinger)
09:20lazybot⇒ 31
09:21dysfunwherein we presume i've solved the problem of uniquely identifying elements
09:23gfredericksdysfun: 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
09:25dysfungah, firefox is so damn slow since i updated
09:25gfredericksI'm pondering whether it would be productive to try to solve both problems at once
09:26dysfunor to split it into two phases?
09:26gfrederickswell if it were structured as a pair of multimethods
09:26gfredericksdiff and patch
09:26ordnungswidrigdysfun: how far can you go with "update-in"?
09:27gfredericksdiff :: A -> B -> Diff; Patch :: A -> Diff -> B
09:27dysfunhrm, i wonder how many primitives i'd actually need
09:28gfredericksperhaps less useful for my purposes, where I like being able to look at single individual differences even if there are a lot of them
09:29dysfuni'd just model it as two functions tbh
09:49hellofunkwhat is the idiomatic way to the get the nth item in a lazy-seq? the (drop .. (take .. )) seems clunky
09:51justin_smithhellofunk: nth?
09:51hellofunkah, ha ha justin_smith i didn't realize that a lazy seq qualified as a collection for nth.
09:52hellofunki see that seq is not considered a collection, while a lazy-seq is. that's interesting.
09:52justin_smithand I would use (first (drop ...)) as the alternative, over (drop ... (take ...))
09:53justin_smith,(nth (seq [0 1 2 3]) 2)
09:53clojurebot2
09:53hellofunk,(coll? (seq [1 2]))
09:53clojurebottrue
09:53hellofunkwell i'll be.
09:53hellofunkthanks mang.
09:53justin_smithnth works on all kinds of stuff
09:54justin_smith,(nth "hello" 2)
09:54clojurebot\l
09:54justin_smith(coll? "hello")
09:54justin_smith,(coll? "hello")
09:54clojurebotfalse
09:54hellofunkyou are the mang, mang!
10:00sverihellofunk: what is a mang?
10:00hellofunksveri http://www.urbandictionary.com/define.php?term=Mang
10:01hellofunksveri i prefer definition 3
10:05sverihellofunk: thank you, I see, I am getting to old :D
10:06hellofunksveri well, scarface was quite a long time ago!
10:06hellofunksveri but for a more recent example, terrence howard says it a lot in Hustle and Flow also
10:09sverihellofunk: ah, I see, I thought this was some new stuff, anyway, I never heard of both of them
10:11hellofunksveri scarface was a class Al Pacino movie about Miami drug wars
10:11hellofunk*classic
10:12sverihellofunk: jeez, I remember having seen a documentation where it was mentioned
10:19hellofunkgood movies
10:22SagiCZ1hi.. what is the best way to disregard a parameter in #() function?
10:22SagiCZ1,(#(println "hey") 42)
10:22clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval25/fn--26>
10:23SagiCZ1,((fn [_] (println "hey")) 42)
10:23clojurebothey\n
10:23SagiCZ1like this?
10:24stuartsierraSagiCZ1: you can't. #() produces a function with an arity based on the %-arguments you used inside #()
10:24SagiCZ1stuartsierra: i see
10:32hyPiRionwell...
10:33hyPiRionYou are a horrible person if you do this, but
10:33justin_smithfun 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:33justin_smithwat
10:33justin_smithtalk about fixing something in the wrong place...
10:33hyPiRion,((-> [_] #(println "hey")))
10:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/eval25/fn--26>
10:33hyPiRion,((-> [_] #(println "hey")) 1)
10:33clojurebothey\n
10:34justin_smithmarginally less terrible? #(do % (println "hey"))
10:34justin_smithbut really, just use fn
10:49justin_smithOK, 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:49clojurebotIt's greek to me.
10:49hyPiRionI think you missed #emacs and hit #clojure again
10:49justin_smithhyPiRion: this is a clojure program using nethack-lisp as a backend
10:50hyPiRionoh
10:50justin_smithit sends me all my data as sexps
10:50justin_smithwhich is the nice part
10:52martinklepschI'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:54martinklepschmanually indenting feels like being thrown back into stoneage ;)
11:03justin_smithcan't you make the template such that the substition in-template won't change the indenting?
11:04martinklepschjustin_smith: only if there are no multiline substitions if I understood your suggestion correctly
11:07justin_smithclojure.pprint has a code dispatch, but I recall hearing bad things about it
11:09clgvfipp?
11:26SagiCZ1does 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:27clgvSagiCZ1: just listen to :action
11:28SagiCZ1clgv: button brings up file chooser and i would like to bind some label text to the file name the user chooses
11:29SagiCZ1i guess i dont need to use bind for that
11:29clgvSagiCZ1: yeah
11:29clgvright tool for the job ;)
11:29SagiCZ1yeah i am new to this, so im kinda lost
11:30clgvI didnt use those binding features - they didn't seem that battle proof
11:31SagiCZ1i saw them here, looked neat https://github.com/franks42/clj-ns-browser/blob/master/src/clj_ns_browser/browser.clj
11:34schmirSagiCZ1: why don't you use javafx?
11:35SagiCZ1schmir: because seesaw uses swing?
11:35schmirand you consider that an advantage?
11:36clgvschmir: seesaw is an advantage, yes
11:36SagiCZ1schmir: i consider the api a huge advantage over swing or interop javafx yes
11:36clgvschmir: afaik there is nothing similar to seesaw for javafx
11:38martinklepschclgv: 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:38schmirok. I'm just asking. I also develop a gui application and I decided to use javafx instead of seesaw
11:38clgvmartinklepsch: no idea, I didnt try to write any templates
11:39clgvschmir: maybe you can steal some of seesaws idea and build a better frontend for javafx ;)
11:40schmirwell, there's https://github.com/zilti/clojurefx...but I generally just use java interop..the javafx api is fine
11:42SagiCZ1clgv: 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:44SagiCZ1i think i will find a way around
11:52clgvSagiCZ1: In my last GUI with seesaw I had one atom containing all of the state
12:00EvanR,(rest [1])
12:00clojurebot()
12:00EvanR,(rest [])
12:00clojurebot()
12:00bocaj_cemerick: What resources are out there to build out ACL (with friend or another library)?
12:03clgvEvanR: you want nil? then use `next`, e.g. ##(next [])
12:03lazybot⇒ nil
12:03EvanR,(next [1 2 3])
12:03clojurebot(2 3)
12:05nullptr,(let [[h & t] [1]] [h t])
12:05clojurebot[1 nil]
12:05bocaj_\nick bocaj
12:07clgv,(macroexpand-1 '(let [[h & t] [1]] [h t]))
12:07clojurebot(let* [vec__124 [1] h (clojure.core/nth vec__124 0 nil) t ...] [h t])
12:07clgv&(macroexpand-1 '(let [[h & t] [1]] [h t]))
12:07lazybot⇒ (let* [vec__20645 [1] h (clojure.core/nth vec__20645 0 nil) t (clojure.core/nthnext vec__20645 1)] [h t])
12:07jonathanjhrm
12:08jonathanjwhere does clojure.java.jdbc/with-connection come from?
12:10jonathanjjava.lang.RuntimeException: No such var: j/with-connection
12:10nullptrjonathanj: try clojure.java.jdbc.deprecated?
12:11nullptrcontext: http://stackoverflow.com/a/22591628/18636
12:12jonathanjoh it's deprecated
12:12bocajI'm looking for resources about Access Control Lists or person(identity) and field-level permissions.
12:12jonathanjwhat supersedes it? with-db-connection?
12:13clgvjonathanj: passing db explicitely?
12:13jonathanjclgv: i'm attempting to make this work: https://github.com/juxt/joplin/blob/master/example/joplin/seeds/sql.clj
12:13clgverr db connection ;)
12:32martinklepschwhen a function prints something, how can I capture that as a string? (asking about https://github.com/brandonbloom/fipp specifically)
12:33gfredericks(doc with-out-str)
12:33clojurebot"([& 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:33martinklepschgfredericks: thank you!
12:33gfredericksnp
12:33martinklepschthat was also crazy fast :)
12:33gfredericksI just happened to be xmonad-channel-surfing
12:33mearnshgfredericks: 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:36mearnsh(i'm trying to implement grover's algorithm)
12:38justin_smithmearnsh: I am halfway disappointed that grover's algorithm isn't based on searching for items by splitting them into NEAR and FAR
12:39mearnshtook me a second there
12:42gfredericksmearnsh: I don't think merge-systems is necessary to call
12:42gfredericksit's sort of an impl detail
12:42gfredericksmearnsh: qubits become part of the same system implicitly as the operate on them
12:43gfrederickss/the/you/
12:43mearnshah
12:45gfredericksmearnsh: the whole .data namespace shouldn't be necessary
12:46mearnshah i see, merge-systems! should do the trick then
12:47gfrederickshuhwhat?
12:47gfredericksoh I see
12:47clojurebotexcusez-moi
12:48gfredericksno even that shouldn't be necessary
12:48gfredericksI should make those private
12:48gfredericksor make an API namespace or something
12:49mearnshhm, not sure how to get an n-qubit system then
12:49gfredericksmearnsh: just make the qubits
12:49gfredericksno extra steps necessary
12:49gfredericksthey communicate with each other in the background implicitly like a good OOP lib
12:51gfredericksspooky action at a distance as a service
12:54mearnshwell say i have n-qubits all in superpositions (H foo), and i want to know the probability of getting n zeros
12:56gfrederickshmm
12:56gfredericksat worst you can do the experiment repeatedly
12:57gfredericksthat sounds tricky to implement in a general way, given the way the code is designed to let you casually introduce new qubits
12:57gfredericksi.e., systems are not static
12:58mearnshthis gives the exact result https://www.refheap.com/94245
12:59mearnshok, i see, i'm definitely thinking in terms of a fixed system
12:59gfredericksthe systems merge and split on demand
13:00gfrederickse.g., if you observe one qubit it will remove itself from whatever larger system it was in since it's no longer entangled
13:01martinklepschI 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:02martinklepschIt seems though that leiningen does expect something different. Whenever I do that I get a one line file containing a bunch of \n
13:05martinklepschhttps://gist.github.com/martinklepsch/e43002fa9f2f009f7343
13:06martinklepschthat'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:09EvanR,(str "a" nil "b")
13:09clojurebot"ab"
13:09EvanRis there a way to get not empty string when attempting to show something that might be nil
13:09gfredericks,(str "a" (or nil "not empty string") "b")
13:09clojurebot"anot empty stringb"
13:09justin_smith,(pr-str "a" nil "b")
13:10clojurebot"\"a\" nil \"b\""
13:10EvanR,(str "a" false "b")
13:10clojurebot"afalseb"
13:11EvanR,(str "a" (or false "NIL") "b")
13:11clojurebot"aNILb"
13:11octe_what would be the most idiomatic to find the index of an object in a list?
13:12gfredericksocte_: .indexOf can work; most people will suggest you're probably using the wrong data structure
13:12octe_it's not equal
13:12octe_there's some other criterias..
13:12EvanR,(get 3 [1 2 3 4]
13:12clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:12EvanR,(get 3 [1 2 3 4])
13:12clojurebotnil
13:13justin_smithEvanR: get looks up an index, but your args are reversed
13:13nullptrocte_: http://www.mail-archive.com/clojure@googlegroups.com/msg34159.html
13:13justin_smith,(get [:a :b :c] 1)
13:13clojurebot:b
13:13EvanR,(get 3 1)
13:13clojurebotnil
13:13EvanRwhy doesnt it crash ?
13:13justin_smithget is very easy-going
13:14EvanR,(get nil nil)
13:14clojurebotnil
13:14jonathanjis anyone familiar with joplin?
13:14octe_nullptr, thanks, that looks interesting
13:14octe_where di seq-utils go?
13:16nullptrocte_: that i don't know ... don't see any obvious refs
13:17EvanR,doc get
13:17clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)>
13:17kungiWhy 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:18EvanRwhat interface does get use
13:18gfredericksILookup I think
13:18gfredericksI think also explicitly supports java.util.Map
13:18justin_smith(doc get)
13:18clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
13:18justin_smith$source get
13:18lazybotget is http://is.gd/WaC1li
13:20octe_nullptr, i found keep-indexed
13:20octe_seems right.
13:20EvanRclojure.lang.RT
13:22gfredericks&(re-matches #"[ab]" "&")
13:22lazybot⇒ nil
13:22gfredericks&(re-matches #"[a&b]" "&")
13:22lazybot⇒ "&"
13:22gfredericks&(re-matches #"[a&&b]" "&")
13:22EvanRhttps://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:22lazybot⇒ nil
13:22gfredericks&(re-matches #"[a&&&b]" "&")
13:23lazybot⇒ "&"
13:23gfredericks&(re-matches #"[a&&&&b]" "&")
13:23lazybot⇒ nil
13:23gfredericks&c
13:23lazybotjava.lang.RuntimeException: Unable to resolve symbol: c in this context
13:23gfrederickslazybot: I just meant to say "etc."
13:23EvanRill get on coming up with a type for get immediately
13:23gfredericks,(get "abc" 0)
13:23clojurebot\a
13:23gfrederickshuh.
13:24EvanR,(get #{1 2 3 4} 0)
13:24clojurebotnil
13:24EvanR,(get #{1 2 3 4} 1)
13:24clojurebot1
14:03razum2umanyone 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:04justin_smithrazum2um: lein repl uses nrepl, which opens a port, then it runs an nrepl client connecting to that port
14:04hellofunkdoes 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:05justin_smithrazum2um: so maybe the vpn or proxy settings interferes with that internal connectint-to-itself logic?
14:05justin_smithhellofunk: if your namespaces are loaded properly, they should get hinted in cider, that's been the case for a long time now
14:05razum2umjustin_smith: but I can connect to localhost via browser, anyway local traffic shouldn't go via vpn
14:06justin_smithrazum2um: yeah, that was just a guess
14:06justin_smithis there any stack trace printed with that exception to show what it was trying to do?
14:07justin_smithalso, see if "lein run -m clojure.main" gets that error - it will give you a plain clojure repl (not nrepl)
14:07hellofunkjustin_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:08justin_smithhellofunk: yeah, cljs integration is probably going to only work well in lighttable, of the existing environments
14:09hellofunkjustin_smith i've tried lt many times. i want to like it but mac support is buggy
14:09justin_smithrazum2um: 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:10razum2umjustin_smith: ok, thanks :)
14:15justin_smithI mean other than the dep finding thing lein will do for all tasks of course...
14:19bocaj,(+ 1 1)
14:19clojurebot2
14:33angusiguessSo 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:33angusiguessHas anyone done such a thing?
14:37nullptrangusiguess: yes -- in a toy example though
14:38nullptr(let [[val port] (alts!! [intern-ch t] :default :not-started)] (assert (= val :not-started )))
14:38nullptrabove, 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:38nullptrt is just a timeout chan for the whole sequence of stuff
14:39nullptrit's a unit test scenario (the intern isn't supposed to start working until told)
14:44angusiguessnullptr: thanks!
14:56edw,(+ 1 1)
14:56clojurebot2
15:12justin_smith,(+ (+) (+))
15:12clojurebot0
15:12justin_smith,(+ (*) (*))
15:12clojurebot2
15:21leandro1can any pious soul tell me if this way of coding is canonical in clojure? https://www.refheap.com/94249
15:22llasramleandro1: Significant heresy I am afraid
15:22leandro1i guessed so, llasram :/
15:22llasramleandro1: `def` and friends create namespace-level vars, so should not be nested in normal code
15:23llasramYou want `let`
15:23Bronsamore likely he needs a loop
15:23llasramYour `require`s should be integrated into your `ns` form
15:23llasramBronsa: probably that too
15:24llasramleandro1: And you should eschew `use` for `(require ... :as ...)`
15:24leandro1ok about the requires
15:24Bronsaleandro1: clojure's vars are not the variables you're used to in other languages
15:24dbaschother things: you want a case instead of chain of ifs, nil? instead of = nil, etc
15:24llasramdbasch: I think that'll somewhat fall out as part of fixing the `def` thing
15:24edw,(Math/exp (* Math/PI (Math/sqrt (- (+) (*)))))
15:24clojurebotNaN
15:25edwclojurebot needs to learn about complex numbers.
15:25dbaschsystem/exit in the middle is terrible too
15:25kenrestivoo_0
15:25leandro1i'm just starting, but my sensation about `let` is i can't access it outside ... so i put those def
15:25llasramdbasch: Maybe be a bit softer on the newbies :-)
15:26dbaschllasram: ok, System/exit in the middle of a function is usually not the best idea :)
15:26llasramleandro1: 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:27llasramleandro1: As is, your `def`s will re-run every time `-main` is called.
15:27kenrestivoi'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:27dbaschleandro1: in this particular case you don’t need any state
15:27Bronsaleandro1: I'd encurage you to read some introductory guide on clojure to get used to avoid mutable state
15:28kenrestivoleandro1: 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:29leandro1i think i must start by avoiding changing state
15:29leandro1gotta read about that
15:41leandro1thank you all
15:45kenrestivois 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:46kenrestivothat just smells funny to me
15:46Bronsa(loop [] (let [data (get-data!)] .. (recur)))
15:49kenrestivohmm, well, my example isn't complete. i meant (loop [prev (get-data)] (let [cur (get-data)] (do-stuff prev cur).... (recur cur))
15:50kenrestivoi'm being OCD. there's probably no way around it.
15:50jonathanjis there somewhere i can specify project-wide settings that i can read from anywhere in my project?
15:50jonathanjfor example, i need to specify my database URI for various environments for joplin in project.clj
15:51kenrestivojonathanj: i use environ, but there may be other ways
15:51kenrestivohttps://github.com/weavejester/environ
16:04seangrove(doc mapcat)
16:04clojurebot"([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:07jonathanjkenrestivo: thanks, that looks useful
16:08jonathanjkenrestivo: if i needed something out of the environ to specify in a map in project.clj, how would i achieve this?
16:09kenrestivoi'm not sure i understand that.
16:09jonathanjso joplin seems to require me to add a :joplin key to the project macro, that key needs to contain the database URI
16:10jonathanji'm not sure how i refer to a value from environ at that point
16:10kenrestivooh, joplin is opinionated about where it gets its config from? hmm.
16:11kenrestivoyeah, environ might not help in that case
16:11kenrestivoi think the solution is to hack joplin to accept its config from places other than project.clj :-/
16:12kenrestivobecause, what, are you going to commit your database passwords to git in your project.clj? it seems kind of inflexible to me.
16:12jonathanjthat's what i was wondering too
16:14kenrestivomost 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:14kenrestivomight 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:16kenrestivoor, you know, use a different library, that's usually an option
16:23justin_smithremember that other files are merged into project.clj
16:23justin_smithand more can be
16:24justin_smithfor example I have certain credentials in my ~/lein/profiles.clj that are then visible to projects
16:24jonathanjhow do you access data in project.clj from somewhere else?
16:25jonathanjin other words, when your ~/.lein/profiles.clj is merged into project.clj, how do you make use of that data?
16:25SagiCZ1i 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:26justin_smithSagiCZ1: yeah, future is a convenient way to do it. It uses a thread pool too, which is nice.
16:26SagiCZ1so 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:26justin_smith(doc realized?)
16:26clojurebot"([x]); Returns true if a value has been produced for a promise, delay, future or lazy sequence."
16:27justin_smithdon't deref until it is done
16:27mindbender1can't core.async be used here?
16:27justin_smithit could, but it doesn't seem neccessary
16:27SagiCZ1justin_smith: and whats the common construct with realized? infinite loop?
16:27justin_smith?
16:27justin_smithrealized? tells you if a future is done
16:28SagiCZ1what if it says its not done
16:28justin_smithso you could poll, for example
16:28justin_smithyeah, poll and sleep in a loop
16:28justin_smithnot infinite though
16:29justin_smithsomething like (loop [] (if (realized? f) (do-something @f) (do (Thread/sleep 100) (recur))))
16:29littleli_I don't think this helps
16:29justin_smithbut if you are looping, you may as well block
16:29SagiCZ1isnt there some more idiomatic way to do this? like hooking some listener to the future?
16:29littleli_I would point at SwingUtilities.invokeLater
16:29justin_smithSagiCZ1: the action you want can be part of the future
16:29SagiCZ1littleli_: invoke later blocks the ui thread
16:30SagiCZ1justin_smith: hey thats a good idea
16:30SagiCZ1at the end of the future, i will just call on the ui thread to update the gui
16:31SagiCZ1(inc justin_smith)
16:31justin_smith"the end of the future" sounds pretty ominous
16:31lazybot⇒ 151
16:32littleli_justin_smith: yeah :)
16:34dbaschjustin_smith: the “end of history” sounded the same way, yet it turned out to be meaningless
16:34justin_smithheh
16:39kenrestivoam i reading the docs to when-let right, that it'll take an optional test?
16:39kenrestivoi.e. i'd love to have (when-let [foo some-map] (not (empty? foo) (do-stuff...))
16:40gfredericksno
16:40llasramkenrestivo: 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:40kenrestivobecause (let [foo (some-map)] (when (not (empty? foo)) (do-stuff ...)) is bugging me in the OCD mood i'm in
16:41gfredericks,(doc not-empty)
16:41clojurebot"([coll]); If coll is empty, returns nil, else coll"
16:41kenrestivowell, yeah, thanks, but it's still a (let ... (when
16:42qerubkenrestivo: What about (when-let [foo some-map] (when (seq foo) (do-stuff …)))?
16:42kenrestivofunny "empty?" but it's not "not-empty?"
16:42justin_smithkenrestivo: maybe (some-> ...)
16:42edwkenrestivo: No, it returns the original non-empty object.
16:42justin_smith,(some-> "hello" .getBytes)
16:42clojurebot#<byte[] [B@16fbaff>
16:42kenrestivooh! cool
16:42justin_smith,(some-> nil .getBytes)
16:42clojurebotnil
16:42edwso: (when-let [foo (not-empty some-map)] (blah...))
16:43kenrestivonot-empty is perfect, thanks!
16:43edwkenrestivo: Yeah, the absence of the question mark makes all the difference!
16:46kenrestivoit's an interesting function, seems specifically designed for use with if-let and when-let
16:46edwIf you find yourself writing ugly code, write a function to make it not ugly.
16:47edwWishful thinking is an essential part of writing beautiful code.
16:48kenrestivoheh, when i find myself writing ugly code, i start looking around for what i might be doing wrong
16:49kenrestivowhich usually means looking for a funciton that someone else wrote that'll make it not ugly
17:06joobusdoes anyone have any insight on using clojure-android? maybe an example app or a tutorial I could look at?
17:07joobusI 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:20SagiCZ1whats the shortest way to avoid repeating foo here?
17:20SagiCZ1 (if (= (foo) 0) 42 (foo))
17:22gfredericksI think just let
17:23SagiCZ1gfredericks: thats what i figured, ok
17:23gfredericks,(defn foo [] 0)
17:23clojurebot#'sandbox/foo
17:23gfredericksnaw nevermind
17:27BronsaSagiCZ1: I like `fix` from useful.fn
17:28Bronsait lets you write (fix (foo) zero? 42 identity)
17:28SagiCZ1Bronsa: what does it do in general? and where is useful.fn?
17:28Bronsaactually looks like you could drop the identity
17:29BronsaSagiCZ1: https://github.com/amalloy/useful
17:31SagiCZ1Bronsa: thank you very much
17:42kenrestivojoobus: i wrote one http://github.com/kenrestivo/spazradioapp
17:46stainkenrestivo: sweet
17:49stainkenrestivo: why was this one Java class needed..? https://github.com/kenrestivo/spazradioapp/blob/master/src/java/org/spaz/radio/SplashActivity.java
17:49stainah, it loads clojure :)
17:50kenrestivoyeah, that's to cover for the loooonnnnnggg load time
17:50staininstead of compiling it?
17:50kenrestivoclever hack that the clojure-android guys created
17:50kenrestivowell, it's compiled
17:50kenrestivothe whole app is aot'ed
17:50stainah.. but just kickstarting the RT takes forever on a phone?
17:50kenrestivobut.... clojure takes forever to load, that's a well-documented problem
17:51staincan't we do some kind of caching or something
17:51kenrestivohttps://www.youtube.com/watch?v=8NUI07y1SlQ , fyi
17:51kenrestivoyeah, there's an effort, which is rich-blessed, to create a lean runtime that loads faster
17:51kenrestivoi don't know the status of it tho
17:53stainI 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:53kenrestivojust reading that code for the first time in a while, lol, bitcoin, that's so 2013.
17:53stainEVERYTHING needs bitcoins!
17:53stainI never got a bitcoin :(
17:53kenrestivoit did in 2013
17:53staindidn't even experience the crash
17:53kenrestivoit was a wild ride for a while
17:54kenrestivonow everyone has as many tulips as they need, i suppose
17:54stainwell, you wouldn't get an actual bitcoin could you.. it's like £241
17:54stainexactly.. the drug dealers have enough to have their economy going
17:54kenrestivohttp://en.wikipedia.org/wiki/Tulip_mania
17:54stainyet still we have tulips..
17:56kenrestivoanyway, there's an example android app in clojure. it was a lot of fun.
18:05teahauzdo source maps get cached at all for cljs...or is chrome making a call to retrieve the latest source map every time?
18:11hodlranyone have experience with instrumenting clojure with new relic?
18:13TEttingernew relic is that expensive site analytic that had very misleading results on heroku for some time?
18:13x1337807xTEttinger: Yup, though expensive is relative. :)
18:14x1337807xhodlr: I found a bunch of blog posts by googling 'clojure new relic' and this project seems promising: https://github.com/TheClimateCorporation/clj-newrelic
18:15TEttingerhttp://genius.com/James-somers-herokus-ugly-secret-annotated it seems rather expensive for one of heroku's larger customers
18:16justin_smithTEttinger: 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:16hodlrx1337807x: 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:17TEttingernice justin_smith, starred
18:18justin_smithusing the clojure reader to get data from elisp feels ugly as fuck - but it works!
18:20x1337807xhodlr: 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:20hodlrx1337807x: rockin!
18:21x1337807xThe code he wrote isn't necessarily something we can make available but I'd be he'll at least have some advice.
18:21hodlrnice
18:30Balvedaanyone have any experience with play-clj.g3d?
18:51david234567Hello! I'm looking for some advice on a server/client project. I'm confused
18:51Guest81432how so?
18:52david234567I 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:52Guest81432um. i have the strangest nick today. this requires some looking into.
18:52Guest81432--jkj
18:53david234567All 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:56david234567That seems a bit too heavy for what I need to do
18:59{blake}Lamina?
18:59{blake}It's kind of a broad question.
18:59TEttingereven ##(doc slurp) can read from URLs
18:59lazybot⇒ "([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:00TEttingernot lazily
19:08david234567Sorry 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:09david234567I don't really know what's the best way to accomplish this
19:09david234567What I thought I could do was establish websockets between each server and read/write to that socket
19:09david234567but I don't know if that's a thing that I can do, or if that's the best way
19:12dbaschdavid234567: without any further context, that’s what distributed message queues are for
19:16david234567Thank you dbasch, I googled around and there's a couple libraries floating around for this sort of thing.
19:57afhammadIs there the equivilent of a ruby * splat in clojure?
19:59nullptrWhat does it do in ruby?
20:00afhammadit unwraps the array and passes the elements as arguments. for example hello(1, *[2,3]) is like saying hello(1,2,3)
20:01nullptrYou could write a macro for that, but I'm not aware of one that exists.
20:02afhammadbasically i want to do [:something (splat [1 2])] and get the same result as (concat [:something] [1 2])
20:02dbaschafhammad: in clojure, that would be (apply hello 1 [2 3])
20:02dbasch(doc apply)
20:02clojurebot"([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:03afhammadi keep forgetting about apply, thanks. I think that works in the function all scenario but not the vector one I mention above
20:04afhammadcall*
20:09TEttingerafhammad, well a function can only return one value, so what would splat return?
20:10TEttingerit can return a sequence or vector, but that's what you started with
20:11afhammadTEttinger, ur right, dont see how it would be possible in clojure
20:11TEttingeryou could still do what apply does and have splat be before the rest of the stuff you want in one sequence
21:09rritochHi, 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:10hiredmanrritoch: have you looked at the value of (class (find-ns 'my-ns)) ?
21:10hiredman(it may surprise you)
21:11rritochhiredman: Yes, and it is still returning the application class loader instead of the dynamic class loader that I've set
21:11hiredmanrritoch: no no, no the class loader bit
21:11hiredman (class (find-ns 'my-ns))
21:12hiredmannamespaces are instances of a class clojure.lang.Namepsace, a class loaded when the clojure runtime is loaded (likely with the application class loader)
21:13hiredmanthey are not instances of their own class
21:14rritochhiredman, 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:15hiredmanrritoch: what is it you actually want to do?
21:16rritochhiredman: 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:18hiredmanrritoch: 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:18hiredmannamespaces are not classes
21:18rritochhiredman: In OSGi you don't register classes as services, you register objects
21:19rritochI've setup the following to make calls on those services
21:19rritochhttps://github.com/rritoch/clj-grid-kernel/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/kernel.clj#L788-L806
21:19jkjdwouldn'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:20hiredmanrritoch: 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:21hiredmanthe objects that represent clojure namespaces as values all are instances of the same class, clojure.lang.Namespace
21:22hiredmanif you want to load multiple different classes named clojure.lang.Namespace then you need multiple isolated clojure runtimes
21:22jkjdcan have only one clojure?
21:22hiredmanyou can have multiple clojure runtimes, but you need to isolate each one via classloader monkeying
21:23hiredmanwhich osgi should be able to do
21:23rritochhiredman: 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:23hiredmanthe thing to keep in mind is, it will be an isolated runtime, so you will basically need to do interop/serialization to communicate
21:23hiredmanrritoch: have you looked at the existing clojure osgi stuff?
21:24rritochI'm setting these classloaders, and calling load-reader from within the OSGi activator class's start method.
21:24rritochhriedman: No, I didn't know there was any, I've been learning this with just trial and error.
21:24hiredmanrritoch: you are calling load-reader from the wrong runtime
21:25hiredmanyou need to call it from the runtime that is in the isolated classloader
21:27hiredmanrritoch: 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:27hiredmanthat is just my observation from hanging out in #clojure, like I said I don't know osgi
21:28rritochhiredman: 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:29rritochBut how do I switch runtimes?
21:29rritochWould eval work?
21:30hiredmanrritoch: 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:30hiredmannot entirely unlike https://github.com/hiredman/polycosm/blob/master/src/polycosm/primus.clj#L95-L115
21:30rritochhiredman: Thanks :) I'm fairly sure I can do that, and I can see how that would work
21:31rritoch(inc hiredman)
21:31lazybot⇒ 64
21:31jkjdI'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:31jkjdput it also in sfl4j MDC or something
21:33supersympublic final class UrlEscapers, static Escaper urlFragmentEscaper (or any other of those static methods) can anyone tell me what the correct form is?
21:33supersymdot-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:33TEttingersupersym: UrlEscapers/urlFragmentEscaper perhaps?
21:33TEttinger,Math/PI
21:33clojurebot3.141592653589793
21:34supersymmy first try... then tried about all combo's I think :S
21:34TEttingerPI should also be a static member, of the Math class
21:34TEttingeroh
21:34TEttingerit isn't public is it
21:34TEttingeris there a getter?
21:34supersymoh
21:34supersymwait... I see, I shouldnt pass it any args ofc
21:37supersymI need to dig a bit deeper/better in those API docs, since the type it implements has the escape method
21:37supersymso I'm good, thanks :)
21:45wildnuxhi,
21:45wildnuxhow can i check if the passed argument is a sequence or a single element?
21:46justin_smithwildnux: ##(doc coll?)
21:46lazybot⇒ "([x]); Returns true if x implements IPersistentCollection"
21:46clojurebotGabh mo leithscéal?
21:46TEttingerwildnux: sequential? may be useful too
21:46TEttinger(doc sequential?)
21:46clojurebot"([coll]); Returns true if coll implements Sequential"
21:46TEttinger,(sequential? (java.util.ArrayList.))
21:46clojurebotfalse
21:46wildnuxwhat is the difference between sequential? , seq? and coll?
21:47TEttinger,(sequential? (doto (java.util.ArrayList.) (.add 1))
21:47clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:47TEttinger,(sequential? (doto (java.util.ArrayList.) (.add 1)))
21:47clojurebotfalse
21:47TEttingerhm
21:47TEttinger,(coll? (doto (java.util.ArrayList.) (.add 1)))
21:47clojurebotfalse
21:47TEttinger,(seq? (doto (java.util.ArrayList.) (.add 1)))
21:47clojurebotfalse
21:47TEttinger,(seq (doto (java.util.ArrayList.) (.add 1)))
21:47clojurebot(1)
21:48jzp113hi
21:48TEttingerhey jzelinskie
21:48justin_smithwildnux: 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:48TEttingerjzp113, rather
21:48jzp113i think clojure is fun
21:48justin_smith&(map seq? [[] () ""])
21:48lazybot⇒ (false true false)
21:48wildnuxjustin_smith: thanks,
21:48jzp113but lt's hard to start
21:48wildnuxone more question, (seq? '()) returns true
21:48wildnux,(seq? '())
21:48clojurebottrue
21:48justin_smithright, but (seq? []) is false
21:49TEttingerjzp113, indeed. it took me a while, but it got easier. have you tried Brave Clojure and going through 4clojure problems?
21:49justin_smithbecause () is a seq (an empty one)
21:49justin_smith&(type ())
21:49lazybot⇒ clojure.lang.PersistentList$EmptyList
21:49TEttinger,(seq '())
21:49clojurebotnil
21:49TEttinger,(seq [])
21:49clojurebotnil
21:49TEttinger,(seq [1])
21:49clojurebot(1)
21:49TEttinger,(seq '(1))
21:49clojurebot(1)
21:49TEttinger,(seq 1)
21:50clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:50TEttingerhm
21:50wildnuxjustin_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:50TEttingerseqable is a common extension thing
21:51justin_smith,(map not-empty [{} () {:a 0} [1] '(a b c)]) ;; wildnux
21:51clojurebot(nil nil {:a 0} [1] (a b c))
21:51jzp113TEttinger, yeah ,I was new
21:52jzp113TEttinger, yeah ,I don't know how to start.just find a book of clojure then read it?
21:52justin_smithwildnux: not-empty will give you nil for empty inputs, and then nil is helpfully falsey
21:52justin_smith&(if nil :wat :ok)
21:52lazybot⇒ :ok
21:52wildnuxjustin_smith: if i had to check for single item or a non-empty list?
21:52TEttingerjzp113, brave clojure may be your best shot for now, it's a good starting place
21:54wildnux(if (single-item? x) :single-item :non-empty-seq)
21:54wildnuxthis is what i am trying to do
21:54wildnuxx can be '(1 2 3 4)
21:54wildnuxor x can be 1 as well
21:54justin_smith
21:54justin_smith,(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello"]) ;; lets see if this works
21:54clojurebot(nil nil {:a 0} [1] (a b c) ...)
21:55jzp113TEttinger,how to download the pdf?
21:55justin_smithwildnux: something like the above would be a start
21:55justin_smiththe part clojurebot truncated was the non-collections coming through unmodified
21:56TEttingerjzp113: 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:56TEttinger&(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello"])
21:56lazybot⇒ (nil nil {:a 0} [1] (a b c) a "hello")
21:57TEttinger&(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.ArrayList.)])
21:57lazybot⇒ (nil nil {:a 0} [1] (a b c) a "hello" [])
21:57TEttingerthat's odd
21:57TEttinger&(map #(or (and (not (coll? %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.HashMap.)])
21:57lazybot⇒ (nil nil {:a 0} [1] (a b c) a "hello" {})
21:57justin_smithTEttinger: ArrayList isn't a persistent collection
21:57TEttingerI was just not sure why it showed [] and {}
21:57justin_smithcoll isn't just for collections, it's for persistent ones
21:58TEttingerhow would you check if something implements the Collection interface?
21:58justin_smith,(java.util.HashMap.)
21:58clojurebot{}
22:00justin_smith&(contains? (supers (class (java.util.ArrayList.))) java.util.Collection) ;; TEttinger
22:00lazybot⇒ true
22:01llasram,(instance? java.util.Collection [])
22:01clojurebottrue
22:01llasram,(instance? java.util.Collection {})
22:01clojurebotfalse
22:01justin_smith&(contains? (supers (class {})) java.util.Collection)
22:01lazybot⇒ false
22:02justin_smith&(supers (class {}))
22:02lazybot⇒ #{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:02llasramMaps aren't Collections (oh, you so crazy)
22:02justin_smithinteresting
22:02TEttingerwhat
22:02justin_smithhttp://stackoverflow.com/questions/2651819/why-doesnt-java-map-extends-collection
22:03justin_smitha bad decision, IMHO
22:04justin_smith&(contains? (supers (class #{})) java.util.Collection)
22:04lazybot⇒ true
22:04TEttinger&(map #(or (and (not (instance? java.lang.Iterable %)) %) (not-empty %)) [{} () {:a 0} [1] '(a b c) 'a "hello" (java.util.HashMap.)])
22:04lazybot⇒ (nil nil {:a 0} [1] (a b c) a "hello" {})
22:05TEttinger,(instance? java.lang.Iterable {})
22:05clojurebottrue
22:05TEttinger,(instance? java.lang.Iterable (java.util.HashMap.))
22:05clojurebotfalse
22:05TEttingerhm
22:06TEttinger&(supers (class (java.util.HashMap.)))
22:06lazybot⇒ #{java.io.Serializable java.lang.Cloneable java.util.AbstractMap java.lang.Object java.util.Map}
22:06TEttinger&(supers java.util.Map)
22:06lazybot⇒ nil
22:06TEttinger&(supers java.util.AbstractMap)
22:06lazybot⇒ #{java.lang.Object java.util.Map}
22:06xeqi,(.add #{} "x")
22:06clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException>
22:06TEttingerwaaaat
22:08wildnux,(.add (java.util.HashSet.) "x")
22:08clojurebottrue
22:08wildnux:)
22:13TEttinger&(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:13lazybot⇒ (nil nil {:a 0} [1] (a b c) a "hello" nil nil)
22:14justin_smithnice, that's pretty general
22:16rritochhiredman: 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:26rritochDidn't work
22:35rritochLooks 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:36llasramrritoch: 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:38llasram(Well, and the Symbol class)
22:41rritochllasram: 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:41llasramrritoch: It should use the RT/baseLoader
22:44rritochllasram: 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:45llasramSounds plausible at least
22:46rritochBasically 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:49rritochRequire should also be easy to execute as an eval also, so it gives me a few options to try.
22:49prachetasllasram: what is RT?
22:50prachetasRunTime - got it
22:50clojurebotGabh mo leithscéal?
22:52prachetass/ - got it/?
22:59llasramprachetas: clojure.lang.RT
22:59llasramWhere yeah, "RT" stands for "runtime (library)"
23:09prachetasthanks!
23:10rritochWell 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:12rritochAnyhow, thanks for the assistance. I should find a way to get this to work eventually, but as of now the solution is still hiding