#clojure logs

2015-04-27

00:04seangroveUpdated that refheap with a slightly different take - I like to keep the code for parameterizing out of the function itself, keep the related concerns closer https://www.refheap.com/100084
01:02mischovNot sure who forked the refheap thingy with a more generic version, but I have a rebuttal.. :P https://www.refheap.com/100086
02:51nicferriercan one send to lots of async channels at the same time?
02:51nicferrierI want the opposite of alt :-)
02:51nicferrierI guess I just put them in a loop
02:55oddcullynicferrier: mult maybe?
02:56nicferrieroddcully: will look, thanks
04:06jack0when can we expect the result?
05:27wasamasaI'm currently breezing through 4clojure and wondered how to determine whether a character is uppercase
05:27wasamasajavadoc suggests there is an isUpperCase method for chars, but I can
05:28wasamasanot use (.isUpperCase \a)
05:28wasamasaanything I've overlooked?
05:29TMAwasamasa: you cannot do 'a'.isUpperCase() either IIRC
05:31wasamasasee also http://www.4clojure.com/problem/29
05:42wasamasameh, apparently I can't use that shorthand since it's a static method
05:42wasamasaso, (java.lang.Character/isUppercCase \a) it is
05:53notostraca,(re-find #"\p{Lu}" "A")
05:53clojurebot"A"
05:53notostraca,(re-find #"\p{Lu}" \A)
05:53clojurebot#error{:cause "java.lang.Character cannot be cast to java.lang.CharSequence", :via [{:type java.lang.ClassCastException, :message "java.lang.Character cannot be cast to java.lang.CharSequence", :at [clojure.core$re_matcher invoke "core.clj" 4641]}], :trace [[clojure.core$re_matcher invoke "core.clj" 4641] [clojure.core$re_find invoke "core.clj" 4700] [sandbox$eval49 invoke "NO_SOURCE_FILE" 0] [clo...
05:53notostracaaww
06:00bcn-florIs it possible to use the threading form for accessing maps which have string keys? (->mymap :address :city) works, but (-> mymap "address" "city") ?
06:02mpenetnope
06:02mpenet,(ancestors (type "a"))
06:02clojurebot#{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.CharSequence}
06:20ConfusionistIt seems there is no way to overload a function such that a single argument is handled by arity [x], unless it is a vector, in which case I want it to be destructured by arity [[x x' & tail]]? What are solutions besides core.match?
06:38rcgConfusionist, did you have a look at multimethods?
06:38rcgyou could dispatch on the type of the argument vec? vs. not vec?
06:39rcgerr, it's vector?
06:49Confusionistrcg, Ah, good point, I'
06:49Confusionistrcg, Ah, good point, I've kind of ignored multimethods so far... time to dive in
07:06justin_smith,(Character/isUpperCase \A)
07:06clojurebottrue
07:07justin_smithwasamasa: java.lang is always imported
07:07wasamasajustin_smith: oh, ok
07:07wasamasajustin_smith: the codegolfing solutions apparently just went for re-seq on a [A-Z] range
07:08justin_smithhow very unkind to our friends whose languages are not ascii subsets
07:09wasamasasneaky
07:13TMAWell, it covers the two widely used languages -- Latin and Indonesian -- so it shall be good enough. However it is quite uncoöperative and naïve to exclude English.
07:15oddcully,(Character/isUpperCase Ï)
07:15clojurebot#error{:cause "Unable to resolve symbol: Ï in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: Ï in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: Ï in this context", :at [clojure.lang.Ut...
07:15oddcullyerm
07:15oddcully,(Character/isUpperCase \Ï)
07:15clojurebottrue
07:15oddcully,(Character/isUpperCase \ï)
07:15clojurebotfalse
07:16justin_smith,(Character/isLowerCase \☃)
07:16clojurebotfalse
07:16justin_smith,(Character/isUpperCase \☃)
07:16clojurebotfalse
07:30notostracawasamasa: justin_smith: ##(re-seq #"\p{Lu}" "ÏÏÏ")
07:30lazybot⇒ ("Ï" "Ï" "Ï")
07:31notostracaone more char, all upper case in unicode
07:32notostracawasamasa: justin_smith: ##(re-seq #"\p{Ll}" (apply str (map char (range 150 200))))
07:32lazybot⇒ ("ª" "µ" "º")
07:32oddcullyand i bet it works better than the java function out of the age, where US-ASCII was the own charset they knew
07:32oddcullys/own/only/
07:34notostracawasamasa: justin_smith: ##(re-seq #"\p{Ll}" (apply str (map char (range 200 250))))
07:34lazybot⇒ ("ß" "à" "á" "â" "ã" "ä" "å" "æ" "ç" "è" "é" "ê" "ë" "ì" "í" "î" "ï" "ð" "ñ" "ò" "ó" "ô" "õ" "ö" "ø" "ù")
07:34notostracaoh geez sorry about the pings
07:35notostracaoddcully: it seems like it uses this internally http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#LOWERCASE_LETTER
07:35notostracabut the \p stuff is more flexible
07:38notostraca##(re-seq #"\pL" (apply str (map char (range 150 200))))
07:38lazybot⇒ ("ª" "µ" "º" "À" "Á" "Â" "Ã" "Ä" "Å" "Æ" "Ç")
07:38notostracause \pL to match all letters and letterlike symbols
07:39notostraca##(re-seq #"\pP" (apply str (map char (range 32 128))))
07:39lazybot⇒ ("!" "\"" "#" "%" "&" "'" "(" ")" "*" "," "-" "." "/" ":" ";" "?" "@" "[" "\\" "]" "_" "{" "}")
07:43notostraca##(re-seq #"\p{LuSm}" (apply str (map char (range 32 200))))
07:43notostracawhaaaaaat
07:43wasamasawhy does this channel have two bots able of evaluating clojure?
07:44notostracawasamasa: lazybot can eval long sequences of code and output to refheap
07:44notostracaclojurebot lets you define things temporarily
07:44notostracathey use different sandbox mechanisms
07:45notostraca,(re-seq #"\p{LuSm}" (apply str (map char (range 32 70))))
07:45clojurebot#<SecurityException java.lang.SecurityException: denied>
07:45notostraca???
07:45lazybotnotostraca: Oh, absolutely.
07:46notostraca##(try (re-seq #"\p{LuSm}" (apply str (map char (range 32 70)))) (catch Exception e (.printStacktrace e)))
07:47notostraca##(+ 1 2)
07:47lazybot⇒ 3
07:47notostracaok, still working
07:47notostracawonder what went wrong
07:48mmeixCan this be shortened: "(defn circle [cx cy r] [:circle {:cx cx :cy cy :r r}])"?
07:49m1dnight_Guys, how can I prevent clojure from creating a squence of a string?
07:49m1dnight_https://www.refheap.com/100096
07:50m1dnight_I know strings are sequences, but I cant think of the proper term here :p
07:50mpenetdont use ~@, use just ~
07:50notostraca~@ will splice it out
07:50clojurebotIt's greek to me.
07:51m1dnight_yeah i was looking for proper definitions on that
07:51m1dnight_so ~@ is "splicing"
07:51m1dnight_ill read up on it
07:51m1dnight_thank you mpenet
07:54notostracammeix, it could be shortened with a macro
07:54mmeixI thought about :keys, but this doesn't apply here
07:55mmeixthanx
07:55notostracathe thing is, in a regular fn, [cx xy r] have those values, and you can't get the names
07:56notostracammeix, is this for code golf?
07:56mmeixno, just a silly beginner's question :)
07:57mmeixonly wanted to make sure
07:57mmeixthanx again
07:57notostracanp
07:58notostracait's tricky thinking about names and the values they hold
07:58notostracabut in most cases it's simple enough that you don't need to worry :)
07:58mmeixI see
08:00engblomReadable code is far more important than having the most short code. One day someone might have to look at your code again... It already was just one line and very readable.
08:00mmeixyes, I thought so
08:01mmeixgiving sane names for functions and vars seems to be a special art, I found
08:03mmeixhere's another beginner's question:
08:04mmeixI have two namespaces, core and d
08:04mmeixin d I have "(def add3 (partial + 3))"
08:05mmeixwhich I can use in core, after :require [test.d :as d], like so (d/add3 5)
08:06mmeixin test.d I have a second def: "(def five 5)"
08:07mmeixbut using "(d/add3 d/five)" in core gives me an error "No such var: d/five" -why?
08:09notostracanot sure actually
08:09notostracaI wonder if the require is getting an older compiled version. try lein clean
08:10mmeixso it should work?
08:11notostracaI'm not sure how :as works with def, actually
08:11mmeixah ...
08:12mmeixI tried in two different projects, and it looks as if functions get adressed correctly, but simple value-definitions don't)
08:13mmeixI#m feeling a bit dumb ...
08:15mmeixbut even fully qualified names don't work, just tested
08:15mmeixok, will find out
08:26surtnmmeix: it's because your five isn't d/five, it's test.d/five
08:26surtnyou need to require both namespaces
08:27mmeixbut I did :require [test.d :as d]
08:27surtnin core?
08:27mmeixja
08:28surtnso core has (ns core (:require [test.d as d] [d :as d]))?
08:29mmeixmust be some dumb oversight
08:29surtnI mean, if it does that won't work :)
08:30surtnmmeix: did you get it to work?
08:31mmeixhttps://www.refheap.com/100098
08:32mmeixah, now it worked
08:32mmeixstrange
08:32mmeixsorry for bothering
08:34surtnno worries! yeah, it looks good, perhaps you hadn't loaded test/d.clj before trying to execute the code in core.clj
08:37mmeixjust found (I'm workin in Lighttable): saving alone doesn't help with the evaluation, have to evaluate test.d, and then try again in core
08:37mmeixthere is something with Lighttable's REPL I didn't understand yet, I guess
08:38mmeixok, thanx for hints, guys
08:52darthdeushey guys, I sort of need to either pass around (atom {}) or a map where each field is an atom ... I don't really care that much about atomic updates (it's clojurescript), but what I'd like to have is convenient access to update values for specific keys in the map
08:52darthdeusand both options lead to ugly combinations of swap! and update-in :\
08:54darthdeuslike for example, if I have (atom {:foo [:bar]}) and I want to conj :baz to the vector, that'd be (swap! (atom {:foo [:bar]}) update-in [:foo] conj :baz) ... and I'm not really sure if this is the way it's meant to be used?
09:00engblomdarthdeus: I would pass around a map and then destruct out what I need. I would not use atom unless I know I want to access a shared value from several threads.
09:03engblomdarthdeus: Unless you need all from the map you pass around, you might only destruct out the part you need. It is very simple.
09:08darthdeusengblom: well there are no threads in cljs, and atoms are the only way to manage mutable state
09:08darthdeusengblom: I can't really just use an immutable map, since the external API needs to be mutable
09:11engblomdarthdeus: That does not give much options than having to use what you already considered (atoms or refs).
09:11darthdeusengblom: yeah, but the thing I'm considering is a map of atoms, or atom containing a map
09:12justin_smithmap of atoms is a bad idea
09:12justin_smiththe only reason to use more than one atom is thread contention, and it's single threaded. Even then refs are a better idea if you need more than one.
09:13darthdeusjustin_smith: i can't use refs in cljs
09:13darthdeusthough my keys in the map are fixed
09:13justin_smithdarthdeus: that's fine, you also don't have threads :)
09:14gfredericksa single atom right at the edge is the ideal way to implement a mutable api
09:14justin_smithpoint was - use one atom, unless you have threads+contention, then use refs
09:14darthdeusjustin_smith: but there's still concurrent access and possible race conditions
09:14darthdeuskk, seems reasonable
09:14justin_smithatoms, as you might guess from the name, make their changes atomically
09:14justin_smith(all or nothing)
09:15darthdeusyup
09:16darthdeusone thing that sucks a bit though, is that I can't destructure a map containing an atom
09:16justin_smithyou don't need a map containing an atom
09:16darthdeussry an atom with a map in it
09:16justin_smithyou can, if you deref
09:16darthdeuslike if the argument being passed is the atom itself, i have to deref first
09:16darthdeusyeah
09:17justin_smithdestructuring works in let blocks
09:17darthdeusyep, but that's verbose :\ I guess I'll just pass around the dereferenced value of the atom whenever I don't need to change it
09:22CookedGryphonDoes anyone know how in clj-time you'd specify "The upcoming 2:30pm" for example?
09:22CookedGryphonso the first time it hits a time, after now
09:32gfredericksI've never thought about how to do that
09:33gfrederickssounds especially tricksy if you're using local time zones
09:33CookedGryphonMy use case being: I want to do something at a certain time each day while the app is running, but when it starts up, I'm going to check if it's more than a couple of hours until the next time it should do the action, and do something in the interim
09:34CookedGryphonshouldn't be a timezone issue, I have a random hour/minute every day when a client should do an upload (to spread out server load), and I want to work out how long it is until the next upload time
09:35CookedGryphonso I can do (today-at hour minute) and then check if it's in the past, but it feels like there should be a better way
09:35CookedGryphonor at least a built in way
09:37gfredericks(inc puredanger) ; for not having conf t-shirts etc
09:37lazybot⇒ 47
09:38mpenetCookedGryphon: you could use something like quartz, but it's trading a
09:38mpeneta if clause for a dependency
09:39CookedGryphonyeah, that's a bit overkill!
09:39CookedGryphonhappy to make a function, was just wondering if I was missing something in clj-time I could use, or some clever trick I could do
09:40CookedGryphonwhich wasn't just calculating the time today and then seeing if it's passed or not
09:40noncom|2CookedGryphon: to me clj-time seemed a fairly straight and low-level api
09:40gfredericksit's something you could include for UTC-only maybe, but once you have time zones the daylight-savings-time edge case makes it hard to have something general
09:40sveriHi, I am trying to generate a vec of vecs, this almost does the trick: (into [] (partition 10 (into [] (repeatedly 400 #(identity 1))))), but it generates a vec of lists [(0 ...) (0...)...], which I do not want, how do I make it a vec of vecs: [[0 ...] [0 ...] ...]?
09:41noncom|2CookedGryphon: so to acheive some more complex functionality liket the one you mention, requires implementing the logic by yourself. luckily, clj-time usually makes that to be rather easy
09:42noncom|2sveri: you can (mapv #(into [] %) your-partitioned-data) , instead of your outer (into [])
09:42noncom|2however, i am very interested if anyone esle can suggest anything better
09:42CookedGryphongfredericks: true. dates are ridiculous. I'm not going to get any uploads when the clocks change one way, and I'm going to get twice as many when they change the other way... ugh
09:43CookedGryphonmaybe I should drop the hours/minutes bit and just do it with the unix time for this particular use case
09:43sverinoncom|2: yea, havn't thought of that, my idea was to not generate a lazy seq in the first place :-)
09:44mpenetCookedGryphon: it's a long running process (I mean not a script)?
09:44noncom|2yeah, this one question bother me much too. these lists and lazyseqs always get in the way, when you just need vectors. clojure somehow makes me love vectors more than lists... whats up? maybe someone else can comment on that?
09:45gfredericksnoncom|2: what don't you like about seqs? you want indexibility?
09:46sverigfredericks: that's my usecase right now, I want to assoc into it
09:47noncom|2gfredericks: i don't like: 1) when i println it, it comes out as a LazySeq and i have to enrich the printlns with some realizer 2) in clojure, i totally do not see why should i use lists over vectors (except for when in macros), 3) what sveri says
09:47noncom|23) * i mean, yeah, indexibility
09:47gfredericksnoncom|2: I think the printing is kind of a bug
09:47noncom|2like, often those lazyseqs are not needed at all, however, clojure forces me into these lazyseqs when i do not even want to
09:47gfrederickssveri: why do you wnat to assoc?
09:48CookedGryphonmpenet: yeah
09:48noncom|2gfredericks: well, about printing: maybe it has meaning in terms of lazyseqs when computing an element is costly and such... so i understand why lazyseqs print as lazyseqs.. it is just that i do not need any lazyseqs at all
09:49sverigfredericks: I just have a multidimensional vec in an atom, my game-state which I want to update
09:49noncom|2i rarely get into computations that require multiseqs
09:49gfredericksnoncom|2: the buggy thing is that printing still realizes the whole thing
09:49noncom|2* lazyseqs, sorry :)
09:49gfredericks,(str (map inc (range 3)))
09:49clojurebot"clojure.lang.LazySeq@7861"
09:49gfredericks,(str (map inc (range)))
09:49clojurebot#error{:cause "Java heap space", :via [{:type java.lang.OutOfMemoryError, :message "Java heap space", :at [clojure.lang.Iterate next "Iterate.java" 50]}], :trace [[clojure.lang.Iterate next "Iterate.java" 50] [clojure.lang.ASeq more "ASeq.java" 131] [clojure.lang.RT more "RT.java" 683] [clojure.core$rest__4093 invoke "core.clj" 73] [clojure.core$map$fn__4532 invoke "core.clj" 2622] ...]}
09:49gfredericks^^
09:49noncom|2OMG
09:50noncom|2and no one ever cared about that?
09:50noncom|2even in clojure-1.7.x ?
09:50gfredericksthere's a ticket
09:50gfrederickswhat's the fix though? print something w/o realizing at all, or print the actual collection?
09:51noncom|2gfredericks: *realize-lazyseqs-on-print* ? :)
09:51gfredericks:/
09:52noncom|2haha.. well, maybe like LazySeq@7681 [a, b, c, ...] ?
09:52noncom|2like 3 elts are realized
09:52noncom|2idk rly
09:52gfredericksthe reason they're realized is that the hexy thing is the hashcode
09:52gfredericksand hashcode requires realizing everything
09:53noncom|2ah, that's what...
09:53gfredericksso if you want a realization-free print you have to decide on something else to print
09:53noncom|2actually, when i print a lazyseq, really i expect to see its contents (at least partly)
09:54noncom|2so, yes, here we have a hard theoretical question...
09:57mpenetCookedGryphon: then maybe use a ScheduledExecutor with an initialdelay to the first run, and delay on 24h, it probably also replaces a bunch of code you already wrote to wait/run etc
09:58noncom|2CookedGryphon: also, there are the at-at and chimes libraries...
09:59CookedGryphonmpenet: I know how to do the runnign
09:59CookedGryphonI'm using schejulure
10:00CookedGryphonI just wanted a way when I set off that scheduled one, to work out whether it's going to be a while until its scheduled time
10:00noncom|2CookedGryphon: so, you construct an interval from (now) and till the time you check for, and then compare the interval?
10:00CookedGryphonyeah, but generating the time I'm checking for is clunky with clj-time
10:01CookedGryphonthat's the only thing I have an issue with
10:01CookedGryphongetting that "next time it's 2pm", without doing "today at 2pm, is that time in the past? If so add a day" logic
10:07noncom|2CookedGryphon: try filing an issue maybe?
10:08noncom|2CookedGryphon: like, add (past?) and (future?) predicates...
10:09noncom|2CookedGryphon: bw, you can use the (after?) and (before?) predicates to compare the generated date with (now)
10:12tomjackprinting a lazy seq is a type error :(
10:16noncom|2tomjack: maybe but 1) they always get in the way here or there, even when you don't need them, so you *have to* deal with them, 2) how else can we visually inspect it?
10:20tomjackwow
10:21tomjack,(binding [*print-length* 3] (str (iterate inc 0)))
10:21clojurebot"(0 1 2 ...)"
10:21tomjack,(binding [*print-length* 3] (str (range)))
10:21clojurebot"(0 1 2 ...)"
10:21tomjackI guess the latter was fixed since alpha3
10:22tomjackprint is OK type-wise, I guess. str is a type error unless *print-length* is set :)
10:22gfredericksha
10:22gfredericks,(print (map inc (range 5)))
10:22clojurebot(1 2 3 4 5)
10:23engblom,(str (range))
10:23clojurebot"(0 1 2 3 4 ...)"
10:24H4nshi, i have the need to perform matches against seqs of maps (e.g. i need to extract "john doe" from '({:type "first-name" :value "john"} {:type "something" ..} {:type "last-name" :value "doe"})) - is core.match a good matching library for that kind of work?
10:26m1dnight_If I have a macro 'foo' in namespace clojbot.botcore and I want to use that macro in a namespace 'clojbot.modules.echo', should a (:require [clojbot.botcore :as c]) suffice?
10:27sobelhrm, just noticed relational algebra is in contrib. anyone use that?
10:27m1dnight_Im trying to get it to work but I cant succeed
10:29m1dnight_this is the error: Can't refer to qualified var that doesn't exist, compiling:(clojbot/modules/echo.clj:17:1)
10:29m1dnight_Ive tried :require without :as, just :use etc
10:29tomjackhmm so the above OOM actually shows that *print-length* is broken for (map inc (range)), since clojurebot has *print-length* 5 by default?
10:30tomjack(or maybe *print-length* isn't supposed to work for that at all, so "broken" is the wrong word..?)
10:35noncom|2H4ns: core.match looks pretty suitable. however, not sure about your task. maybe you better use (filter) .. ?
10:36oskarkvH4ns maybe https://github.com/oskarkv/map-regexps
10:38H4nsnoncom|2: i'll give it a try.
10:38H4nsoskarkv: i don't really think that i want to add another syntax like the map regex syntax that you have, but thanks!
10:43eraserhdI have a weird problem: when lein release spawns gpg, it prompts me for my password; however, I can't enter it. I can use gpg manually and it works.
10:43eraserhdIt doesn't _reject_ my password, it times out waiting. Even though I hit enter like four times.
10:43eraserhdIdeas?
10:44m1dnight_aha, I have foundmy problem. defn inside a macro isn't so easy :>
10:45eraserhdSame result in a non-tmux window.
10:50gfredericks`lein release` has had confusing behavior for me, probably related to me not understanding gpg well enough yet; I haven't dug into it
10:51gfrederickson some computers I have to just run through the :release-tasks manually and it works that way o_O
10:51bacon1989was wondering, has anyone here used the Component Design Pattern? https://github.com/stuartsierra/component
10:52bacon1989Is it really required for writing bigger clojure applications?
10:52bacon1989Or I mean, does it at least simplify the process
10:52wasamasait does make it cleaner
10:53TimMcm1dnight_: ~(name name-of-var)
10:53bacon1989wasamasa: I was looking it over, and got held up on a few things. The database component example kind of threw me off
10:54bacon1989like when a component uses the database component
10:54bacon1989it just starts referring to the 'database' var, and the only way to figure this out is to look at the system definition?
10:54bacon1989I"m guessing the components are supposed to be quite small, with few dependencies
10:54wasamasayup
10:55bacon1989wasamasa: I'm just thinking about how a new user who hasn't dealt with this model might make huge mistakes in that manner
10:55bacon1989but I guess that could happen with any design
10:55bacon1989in the manner of making it monolithic
10:55wasamasaindeed
10:56bacon1989indubitably
11:29justin_smithnoncom|2: well, partition as provided by clojure is a lazy seq algorithm
11:29justin_smithooops, sorry I was in deep scrollback and forgot
11:30noncom|2justin_smith: yet, you've just answered a question that nobody yet answered :)
11:30justin_smithhaha
11:30noncom|2yeah, it is lazyseq inherently..
11:30justin_smithone could construct a vector partition
11:30justin_smithbut that would be a different function, surely
11:31noncom|2clojrue strangely leans toward vectors, but still, uses lists in most of its functions... thats.. umm.. funny?
11:31noncom|2or don't i understand something?
11:31justin_smitheg. first construct a vector of n elements, then fill it, as you walk the input
11:31dnolennoncom|2: lists and lazy sequences aren't the same thing
11:31justin_smithit prefers vectors for literals (this is good, you can construct them when compiling and reuse them, they are associative etc.)
11:32justin_smithand it prefers to generate lazy things at runtime (because this allows nice lazy algorithms)
11:33eli-seWhat is the preferred generic way to test membership in a set?
11:33justin_smitheli-se: contains?
11:33eli-seApplying the set doesn't work if the set contains false.
11:33eli-seAh, I see. Of course.
11:33justin_smith,(contains? #{false} false)
11:33clojurebottrue
11:33eli-senice
11:33justin_smith,(contains? #{nil} nil)
11:33clojurebottrue
11:34justin_smith,(contains? #{Double/NaN} Double/NaN) ; the one gotcha, but your fault for using this value
11:34clojurebotfalse
11:34eli-seamazing
11:35justin_smithnan is weird
11:40expez(first (reduce concat (map next-results (range 1 4000))))
11:40expez;; StackOverflowError clojure.core/seq (core.clj:133)
11:40justin_smithexpez: cemerick has a recent article on concat
11:40expezHow can you start consuming this lazy-seq without blowing the stack?
11:40justin_smithand why you should not do that
11:41expezjustin_smith: this is from stuartsierra's post from yesterday
11:41expezwhich is about how people get into trouble with concat
11:41justin_smithoh, I misremembered
11:41justin_smithhe has the answer in the same blog
11:42justin_smiththe problem is reduce and concat - reduce is eager, concat is lazy
11:43justin_smithif you are using reduce, use into and a vector instead of concat and a lazy-seq
11:44expezaha, I thought it was 'first' that forced the realization of the lazy-seq
11:44expezbut it does blow up anyway
11:46justin_smithreduce can't do lazy. It can incidentally return something that is lazy, but itself it is eager.
11:46expezWhen I read the post and saw the stacktrace I was like "Aha! so that's what that was"
12:01TimMc$seen djpowell
12:01lazybotdjpowell was last seen quittingQuit: Bye 9 weeks and 6 days ago.
12:03justin_smithis there a better way to test if something is a channel other than just testing if it is a clojure.core.async.impl.channels.ManyToManyChannel?
12:04mdrogalisjustin_smith: I don't think so.
12:07justin_smithI'm tempted to test the supers so at least my code works with a concrete substitution
12:08justin_smith(contains? (supers (class (>/chan))) clojure.core.async.impl.protocols.WritePort)
12:08justin_smithsomething like that
12:28amalloyjustin_smith: that's an odd way to write (instance? ...)
12:32justin_smith(inc amalloy)
12:32lazybot⇒ 262
12:32justin_smithI knew there was something simpler, but it was escaping me
12:32amalloyalso, it sounds like it's a protocol, right, not just an interface?
12:33justin_smithyeah
12:33amalloyso you'd be a bit better off using safisfies: (satisfies? (>/chan) c.c.a.i.p/WritePort)
12:33justin_smithyeah, but I have a condp... I may or may not be only checking protocols
12:34justin_smithand of course that condp could be a multimethod or protocol... early stages of the design
13:01timvisherin clojure.java.jdbc, if i have a column named `charnock_column`, should be able to `insert!` against it using `{:charnock-column "value"}`?
13:02hiredmanno
13:02hiredman:charnock_column
13:02fowslslegsIs there a way to typecast that I want a byte as I add two bits. I think it usually autopromotes to long, but I don't want this.
13:03fowslslegsadd two bytes*
13:03fowslslegsOr rather that my result is a byte array?
13:06puredangeryou're generally going to be frustrated if you try to do byte-level twiddling in Clojure - it's quite easy to introduce promotion/boxing
13:06puredangeryou can use ^bytes to hint a byte[]
13:07timvisherhiredman: ah. suppose if i want that sort of magic i should be going above java.jdbc...
13:10timvisherjava.jdbc does, however, seem to translate the column names on retrieval...
13:11timvisheror actually i suppose liberator is doing that in this case...
13:18lasergoati use camel-snake-kebab to translate my keys coming and going to jdbc
13:19timvisherlasergoat: hadn't heard of it. thanks :)
13:19lasergoatand yeah, java.jdbc doesn't translate them for the results either; something else must be doing that for you
13:43m1dnight_Is there a macroexpand-2 of some sort?
13:45craigglennieHow do people go about persisting the functions they've worked out in the REPL to a file? Let's say I've been building up my program in the REPL through lots of trial and error, and now I have some functions that I like and I want to put them in my project - is there a best way to do that? Can I have the REPL dump out all the functions somewhere, or do I just work my way back up through the command history and copy-paste into my file?
13:46craigglennieWhen I develop in Python I typically define functions in a file, load them in the REPL, play around, make changes in the file, and repeat. That'll work here too, I think, but I wondered if there's another way
13:47craigglennieIt's slightly annoying to have to reload the file (especially if it means you need to recreate a bunch of state - I suppose that shouldn't be happening in a good Clojure program) but it works...
13:49luxbockcraigglennie: I like to have a scratch buffer where I play around
13:51craigglennieluxbock: That's an emacs thing, right?
13:53engblomcraigglennie: I am using vim + fireplace. I am always working on the file, and each function I write, I send to the REPL for testing. If it did not work well enough, I change it, send it again to REPL for another test.
13:55dnolencraigglennie: historically with Lisp generally you can just play around with functions in your source file, no need for a scratch thing. Clojure supports this way of working quite well.
13:57craigglennieengblom: Ahh, that made me think - I'm using Cursive, and I wonder if it has this option? So I selected my function, and there is indeed a "send to REPL" option. It seems to just copy and paste the text into the REPL, but unfortunately I get a CompilerException from it (if I do the copy and paste manually it's fine)
13:58engblomcraigglennie: I do not use Cursive, so I am not able to help there... Someone here on this channel is making that IDE and would be able to answer that question better. I do not remember the nick of that person.
13:59craigglennieengblom: Thanks. Maybe they'll see this. If not, I can deal with just copy-paste for now.
14:11puredangercfleming is the author of Cursive
14:13daviidi have this file, ij-support.clj defining a ns, like (ns ij-support "..." (:import '(ij IJ) ...)), how do i use it from another .clj ? I mean what is the default clojure load-path so i can import in other .clj files [or should i use 'use' for this matter? i should
14:14justin_smithdaviid: i-support.clj is not a valid file name
14:15daviidij-support.clj, ok why ?
14:15justin_smithif the ns is called ij-support the file needs to be ij_support.clj
14:15justin_smithbecause java
14:15daviidok
14:15justin_smithafter the filename is correct, require or use should work
14:15daviidtoo bad but i will survive :)
14:15daviidlet me try then
14:16justin_smithalso, the file needs to be on your classpath in a file path that reflects the package
14:16justin_smithso if the ns is just ij-support and you have the default lein setup, it should be in src/ij_support.clj
14:16m1dnight_could somebody have a look at my macro? Ive been trying to solve it for a few hours now and cant get it to work. https://www.refheap.com/100112
14:17daviidthat's indeed my second quiz, how do i inform clojure of location of things i would like to require/inport/use
14:17justin_smithbut having some package is highly recommended (it avoids weird collisions)
14:17justin_smithdaviid: it looks on its classpath, using folders as the elements of the package
14:17justin_smithso foo.bar.baz would be in src/foo/bar/baz.clj
14:18daviidjustin_smith: [too many justin won't let me complete your acro] in guile, the system has %load-path, and we add to this what ever we want to ...
14:18justin_smithdaviid: this is similar, but we let leiningen manage the classpath, it's easier that way
14:19justin_smithand instead of managing the classpath directly, we declare our dependencies, and it builds the apropriate path. Thus we avoid version conflicts.
14:19daviidactually i'd like just to use emacs [and later slime but it seems complicated to configure]
14:19justin_smiththere are other tools like boot, or even maven, but the concept is similar
14:19justin_smithdaviid: emacs is not even a factor here
14:20daviidok but just using clojure
14:20justin_smiththat's like saying "I just want to use c and not make"
14:20engblomdaviid: All you need is any text editor, jre and leiningen. Leiningen will even provide Clojure for you
14:20justin_smiththere are options other than lein, but the sane path is to use one of them
14:21amalloym1dnight_: what would macroexpand-2 do? just be (comp macroexpand-1 macroexpand-1)?
14:21daviidi don't want to use Leiningen, just a clojure repl in emacs
14:21m1dnight_ah, i didnt think about that. But i already rolled my own in the mean while :D
14:21justin_smithdaviid: like I said, that is like using c but not make
14:21daviidand alter the load-path so my ij_support.clj
14:21justin_smithit's silly
14:21justin_smithonce you are in ij_support.clj you should be done setting your classpath
14:22justin_smithunless you are adding deps at runtime interactively
14:22daviidhow do i set my classpath
14:22justin_smithit's a command line arg to java
14:22amalloywell, what you wrote is quite different from that
14:22justin_smithor use a tool that sets it up properly
14:23m1dnight_I know, but it did what I wanted. Show me the expansion of my two macros
14:23daviidas an example the file is here: /usr/lpdi/projects/clojure/cljs/ij_support.clj
14:23m1dnight_well, i dont know what you mean, but ill try once I get this little bastard working :D
14:23justin_smithdaviid: java -cp clojure.jar:foo.jar:bar.jar:src clojure.main will give you a repl, with clojure, and the things in foo and bar, and source under your src/ directory. But this is not the simple or sane way to do things generally
14:23amalloym1dnight_: how is anyone supposed to help you with this? it's just a bunch of code with some output printed. i don't know what's "wrong" with how it's behaving
14:23m1dnight_I was waiting for somebody to want to help so I could explain :)
14:24justin_smithdaviid: the difference with lein is that instead of specifying all the jars for the libraries you would use, you declare library packages and version numbers, and it sets up that path. That is what lein does. It is just a deps / build tool.
14:25engblomdaviid: with lein installed, you just write: "lein new app whatever-you-want-to-call-your-app". Then inside of the created folder you write "lein repl" and you got a repl with everything automatically setup.
14:25justin_smithdaviid: you can do things the hard way, but be aware that not using lein (or boot, or even maven) is the very hard way
14:25m1dnight_So, the problem is the following. I have 3 macros (defmodule, defcommand and defhook). The two latter only expand to a map and they are okay. The defmodule macro should expand to a function named 'load-module' which I can then later call with some dirty namespace code. Which also works. I had the macro working for a single "cmd" parameter, but I want to do 1 or more. (hence, '& cmds' in my macro).
14:26m1dnight_The usage of the macro code in the refheap shows an example. It expands to the code shown below. I.e., a function 'load-module' that take 1 argument, and then applies a function to that argument and each of the cmd's in 'cmds'
14:27m1dnight_I have put some print statements in my macro expansion and those get printed, so I know the macro is being executed. It just doesnt execute any code in the doseq body.
14:27m1dnight_Not even a simple print. And im wondering why that could be. The expanded form looks perfect to me..
14:28amalloym1dnight_: (doseq [cmd# [~@cmds]] ...)
14:28amalloyis the first thing i would fix
14:28m1dnight_but isn't [~@cmds] == ~cmds ?
14:29amalloy&(let [cmds (range 5)] `{:yours ~cmds, :mine [~@cmds]})
14:29lazybot⇒ {:yours (0 1 2 3 4), :mine [0 1 2 3 4]}
14:29m1dnight_:(
14:29m1dnight_your solution worked
14:29m1dnight_i feel stupid :p
14:29amalloyyou see the difference, and why it matters?
14:29m1dnight_I know the first is a list and probably doesnt implement Seq ?
14:30m1dnight_well, cant be used as a seq
14:30m1dnight_or is mine interpreted as an expression?
14:30m1dnight_for lack of proper jargon, mine is not interpreted as a list of data, but as an expression
14:31amalloyyes
14:31amalloyyou could also write (list ~@cmds)
14:31m1dnight_ah well, i was indeed under the assumption that those were semantically equivalent
14:32m1dnight_(inc amalloy)
14:32lazybot⇒ 263
14:35gfrederickshey a prime
14:35justin_smithhmm
14:35justin_smith(identity justin_smith)
14:35lazybotjustin_smith has karma 249.
14:35justin_smithdivisible by 3
14:35gfredericksboooo
14:36daviidjava -cp clojure.jar:ij-core.jar:cljs clojure.main /usr/lpdi/projects/clojure/cljs/get-particles.clj arg1 ... where get-particles.clj does (import 'ij-support) fails to find and import ij_support.clj i'd like to make this working, tx for the help reagrding this way of doing things, i look into lein later, maybe
14:36m1dnight_(identity m1dnight_)
14:36lazybotm1dnight_ has karma 1.
14:36m1dnight_PRIME \o/
14:36justin_smithdaviid: it needs to be separated by :
14:36justin_smithlike your shell path
14:37justin_smithdaviid: you are pointlessly punishing yourself with needless complexity by doing it this way
14:37daviidis it not? java -cp clojure.jar:ij-core.jar:cljs [cljs is a symbolic link]
14:38justin_smithsorry, misread
14:38justin_smithwhere did ij-core.jar come from?
14:38daviidit's a symblic link as well but that worked for ages
14:38justin_smithalso import does not work on namespaces, only classes
14:38justin_smithyou don't import a namespace, you require it or use it
14:39justin_smitha namespace is a datastructure, not a class
14:40justin_smithalso, you should rename get-particles.clj to get_particles.clj if you ever expect it to be auto-loaded
14:40justin_smith(via require or use or load)
14:41jelooking for a "pretty" way to dividing a collection after (or before) a specific element ie. transform [\a \x \y \b \a \y \z \b] into (list [\a \x \y \b] [\a \y \z \b])
14:41daviidok. it seems it finds it now, but i have another problem in ij_support.clj itself it seems. [get-particles.clj is and will always remain a script [and I hate _ in filenames :)]]
14:42Pokyje: split-at ?
14:42justin_smithdaviid: people that know clojure will waste cognitive time wondering if that file name is going to break something
14:42jenotice that both \a and \b can be used to identify a split... the only thing I can come up with is doing something with a loop-recur. I was wondering if there is a better alternative
14:43Pokyoh I'm stupid, that takes an index.
14:43daviid the ultimate goal is to call it get-particles
14:43daviidnobody should even know it is clojure...
14:43daviidbut let me get thing working first
14:44justin_smithdaviid: then provide a launcher script with the java invocation inside it
14:44justin_smithin fact you can embed that in a jar
14:44justin_smiththe .clj file is not the right place to do that abstraction IMHO
14:44jePoky: split-at uses a specific position, and I can have any number of elements between \a and \b and I can have any number of occurrences of sequences with \a (some elements) \b
14:44daviidjustin_smith: yes but let's do that after, it still does not work now
14:44jePoky: but thanks :-)
14:44justin_smithOK
14:45justin_smithdaviid: once you want to pack it up, you can put a #!/usr/bin/java inside an uberjar
14:45justin_smithremarkably enough
14:45daviidhere my ns def: [part of it] (ns ij-support "imagej support" (:import '(ij IJ)))
14:45Pokyje: yeah, my bad. I'm just not sure, how would you identify that you want to split before the 'second' \a and not the first one?
14:45daviidthe system says: Exception in thread "main" java.lang.ClassNotFoundException: quote.(ij IJ)
14:46justin_smithdaviid: yeah, inside ns forms, you don't quote deps
14:46justin_smithit's a macro, it's already quoted for you
14:46justin_smith(:import (ij IJ))
14:47daviidright, now it complains with something else, let me understand and copy here
14:49daviidin get-particles.clj, i did (use 'ij-support), it now complains with Exception in thread "main" java.lang.RuntimeException: No such namespace: IJ, compiling:(/usr/lpdi/projects/clojure/cljs/get-particles.clj:39:15) where that line calls ... (IJ/openImage filename) ...
14:49justin_smithdaviid: importing is per namespace
14:49daviidah ok
14:49justin_smithif IJ is not imported, you would get that error
14:49daviidunderstood
14:50justin_smithdaviid: in general dependencies and sources of definitions are explicit and local in clojure
14:50justin_smithit's one of the great things about the language, as far as I am concerned
14:50daviidsame in scheme, my mistake
14:50justin_smiththe classpath stuff actually helps with that (explicit controllable versions), despite being a little clunky
14:52daviidok it seems to work now, many thanks, my first ns just borned
14:52daviid:)
14:53justin_smithcool
14:54daviidwithin the namespace i defined, i don't need to explicitly export right?
14:54daviidall defn are available to whom (use ...)?
14:55j-pbdaviid: yes
14:55daviid[in scheme we have to export]
14:55j-pbdaviid: you can define private functions with defn-
14:55daviidj-pb: ok
14:57daviidgoing afk for a little bbl, tx
15:10borkdudeI'm trying to call phantomjs from clojure with conch, but I don't see any output. Maybe someone has an example for me how it's done?
15:11cflemingcraigglennie: You can configure Cursive to execute forms sent from an editor to the REPL either in the namespace of the editor they come from, or the current namespace of the REPL
15:11cflemingcraigglennie: What you are describing means that you almost certainly have it configured to execute in the editor namespace, but that namespace is not yet loaded into the REPL
15:12cflemingcraigglennie: If you load that NS into the REPL it should work
15:16craigglenniecfleming: Okay, thanks. Is there a keyboard shortcut for "send to REPL", so I don't have to go through the context menu?
15:18TimMcHuh, the Sonatype Central Repository's terms of service exclude "pornographic" submissions.
15:18TimMcs/not/now/ :-P
15:19TimMcThen we could have a great argument over whether a jar file is pornographic, or whether merely its possible outputs are.
15:19cflemingcraigglennie: See https://cursiveclojure.com/userguide/keybindings.html for details
15:19craigglenniecfleming: t
15:19craigglenniehanks
15:22virmundihello. i need to do something interesting. I’ve got an ArangoDB driver. Part of ArangoDB is the ability to run arbitrary JS as a transactional unit. to send this information to the server, arango wants an attribute in the transaction JSON named action with a string that is the representation of the function
15:22virmundi{action: “function () { console.log(‘worthless transaction’);}”}
15:23virmundiI would like to embed the JavaScript structure directly in the code.
15:23virmundi{:action (js function() { blah; blah}))
15:24virmundiI need help trying to figure out how to do this. I think that I should a macro, but I have 0 experience with making my own.
15:24virmundiAm I on the right track?
15:28stevenleegdoes anyone know what happened to to the leiningen package for debian sid?
15:28stevenleegI only see the package for wheezy
15:35felipedvorakI'm a web developer. I'm curious about functional programming. I should learn... ?
15:36the-kennyfelipedvorak: Regardless of chosen programming language, FP will help you think different about problems :)
15:37the-kennyfelipedvorak: Clojure shines on the server, but ClojureScript makes browser-side programming fun too. But be aware that ClojureScript slightly harder because the tools as well as libraries aren't as mature.
15:39arav93could someone say who the selected students are?
15:40Bronsaarav93: it's public info on the gsoc site
15:41sverifelipedvorak: well, it still is better than plain javascript regarding the language aspect
15:41arav93I'm unable to access
15:41Bronsaarav93: https://www.google-melange.com/gsoc/projects/list/google/gsoc2015
15:42sobelTimMc: i wonder if that means they would not host open firmware for a sex toy
15:43gfredericksfirmware in a jar?
15:43sobelfirmware is relative
15:45TimMcsobel: Yeah, exactly!
15:46TimMcCould be considered "obscene" under their rules too.
15:46TimMc"FORTRAN is not meant to be used that way!"
15:46TimMcOh crap, they'll probably ban swearjure.
15:52felipedvorakthe-kenny: :) thanks.
15:52jason__hey - could anyone help me out here: looking for a way to loop through a directory and load a var from each of the namespaces in that directory. this is what I have currently: https://gist.github.com/jtmarmon/391477e88eec05fcba95 but i get "no such namespace schema-ns", meaning it's trying to load the namespace schema-ns, rather than the namesapce passed in the anonymous fn for map. any ideas on how i can fix this (or just a better
15:53felipedvoraksveri: I see, JavaScript doesn't get a lot of love...
15:55TimMcjason__: In that code you are trying to call a var called schemas in a namespace *literally* called schema-ns.
15:55TimMcWhat you want to do is look up the var and call that. ((resolve (name schema-ns) "schemas")) should do it.
16:04m1dnight_what do peopl euse for http requests? (something like requests for python, for those wwho know it)
16:04m1dnight_something that handles cookies etc all easily
16:05the-kennySo you want a browser? :)
16:05jason__TimMc: Thanks for the advice. I'm getting a different error - updated code w/ error in comment here https://gist.github.com/jtmarmon/391477e88eec05fcba95
16:05m1dnight_the-kenny: a headless browser, yes! :p
16:06the-kennym1dnight_: I'm not aware of a library that handles cookies, cookie-storage, etc. for you - for other stuff, http-kit might be good
16:08jason__TimMc: changing that line to (resolve (symbol (str (name schema-ns) "/schemas"))))) (though ugly) seemed to fix the errors, but is just resolving an array of nils
16:10jason__ahh i see - just had to require the NS first. thanks TimMc
16:11justin_smithjason__: resolve can take the ns and var args separately, no need to do a string concat
16:11justin_smith(doc resolve)
16:11clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
16:12justin_smithoh wait, I am thinking of ns-resolve
16:12justin_smith(doc ns-resolve)
16:12clojurebot"([ns sym] [ns env sym]); Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environment), else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."
16:12justin_smithyeah, that's the one
16:14arohnerm1dnight_: clj-http can handle cookies for you, but it's not a browser
16:15arohnerm1dnight_: https://github.com/dakrone/clj-http#cookie-stores
16:16sobelcookie handling sounds like a good idea right now (hungry)
16:21m1dnight_arohner: i just stumbled upon it! :)
16:21m1dnight_it looks excellent!
16:21m1dnight_I was guessing there would something as lean as requests.py
16:25wasamasarequests.py wraps three libraries that have the prefix "urllib" in common
16:25wasamasathat's not what I'd use as example of a lean library
16:25wasamasano, it's about the fact that it's a lot more pleasant to use than the libraries it's wrapping and comes with a sensible API
16:27m1dnight_thats what i meant with lean
16:27m1dnight_lean as in, making an http request is as easy as one expects it to be
16:27m1dnight_no hassle, no fuss. Just a request.
16:28wasamasawell, you're in luck then, the clojure libraries I've seen so far strive for simplicity
16:29justin_smiththat definition of lean is the opposite of most I've seen
16:29wasamasa^
16:31the-kennym1dnight_: the problem is: HTTP is everything but easy. You can hide complexity, but that will break
16:37scizoI am experiencing an issue with aot-compilation changing the order of evaluation in a namespace. Here is a minimal reproducing example. https://github.com/scizo/unmap-failure
16:38justin_smith(doc ns-unmap)
16:38clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
16:39scizoMy first question is, is this a known oddity about aot compilation where all interned var are created before the body of the expressions in the namespace are evaluated?
16:39justin_smithscizo: vars are created before the forms are executed. This allows primitive recursion.
16:40scizoI understand that the var is created before the forms are executed, but generally not before the previous expression, correct?
16:41justin_smithwell, Long is already mapped to java.lang.Long
16:41scizoIt certainly behaves as I would expect in the absence of aot compilation.
16:42justin_smithis there a reason you need to shadow java.lang? does the issue persist if you aren't shadowing something in java.lang?
16:42scizoYes. That is why the ns-unmap is there. To silence the warning by removing the mapping to java.lang.Long before creating the new mapping from Long.
16:44scizoThe reason for using 'Long is because it allows for using some simple conventions when generating some code that for java interop. Another name could be used, but then a special case would have to be made.
16:45justin_smithOK.
16:45scizoI could also get rid of the ns-unmap and live with the WARNING everytime that namespace is evaluated, but that gets annoying.
16:46scizoI don't think the nature of the problem has anything to do with the nature of shadowing java.lang though, I think that just lead to me discovering it.
16:46justin_smithscizo: I'm really not sure what's going on there, or even whether it should be considered a bug. The thing that stands out for me at the moment is that ns-unmap is a top level side effect, and those are tricky
16:47justin_smithscizo: what if you had (defn init [] (ns-unmap *ns* 'Long) (def Long :long-exists))
16:48justin_smithusually a def inside a defn is a bad idea, but here it might make things more sensible
16:48justin_smithof course this still requires calling init
16:49justin_smithor would even the defn form cause the warning about shadowing Long?
16:51scizoI imagine the same thing would happen if trying to shadow something from clojure.core, but there exists :refer-clojure for that case. I will have to experiment with that one.
16:52justin_smithI tried init, it causes an error
16:54scizoThe same behavior is exhibited when trying to unmap 'map. It works without aot compilation, but doesn't with.
16:56justin_smithyeah, I think it has to do with the fact that ns-unmap is a side effecting function, and those interact poorly with compiled namespaces
17:50scizojustin_smith: Thanks for taking a look!
18:14arohneris there a library that *generates* html, using the data returned by clj-tagsoup lazy-parse-xml?
18:16amalloyi would be a little surprised if tagsoup returned xml in a format other than the one used by enlive
18:20arohnerclj-tagsoup lazy-parse-xml is a different format from 'normal' clj-tagsoup, it returns clojure.data.xml
18:20arohnerAFAICT, enlive uses tagsoup directly
18:20arohnerenlive is a mess, documentation-wise, so I'm trying to avoid it
18:22Bruce_Wayneoff topic, but does anyone know how to accept the rules on a kickstarter project?
18:22Bruce_Waynetrying to launch my project now, but says i need to accept the rules first...
18:24amalloyclojure.data.xml is the same as enlive's format. you should be able to use either to emit html/xml
18:30hiredmanenlive has comment nodes
18:31hiredmanI guess clojure.data.xml does too, and I am thinking of clojure.xml
18:40amalloyyeah clojure.xml is pretty featureless
18:52brehaut_what we need is xml literals
18:59amalloybrehaut_: flagship new feature for 1.8.0: #xml [:people [:person {:name "x"}] [:person {:name "y"}]]
19:00brehaut_amalloy: point taken. i shouldnt joke about this stuff
19:02j-pbamalloy: and buggy
19:02j-pbamalloy: clojure.xml is pretty broken
19:03arohnerbrehaut_: amalloy: wow, enterprise-ready, right there!
19:04brehaut_oh man we could have an #xslt tag that compiles XSLT from #xml notation directly into clojure code
19:05j-pbI'm still waiting for the #clj tag, so that we can write #[:map :inc [:range 10]] instead of (map inc (range 10)), so that even our code is data
19:06j-pb#clj [:map :inc [:range 10]] that is
19:13rmanderswhy does this work: (.encode (java.util.Base64/getEncoder) (.getBytes "testString")) but it fails when I try this: (def encode (partial (.encode (java.util.Base64/getEncoder))))
19:16surtnrmanders: .encode isn't a clojure function, so you can't partial it
19:16tbaldrid_.encode is not a function, it's actually a special form
19:16pmonksThis works: (def encode (partial #(.encode (java.util.Base64/getEncoder) %)))
19:20rmandersThanks pmonks. Is this the preferred way to treat java instance methods as clojure functions?
19:21amalloyrmanders: do not follow pmonks's example, it is super-weird
19:22pmonks;-)
19:22pmonks<insert usual n00b warning)
19:22amalloyspecifically, the (partial) there might as well be (identity)
19:22pmonksTo be fair, I wouldn't do that anyway.
19:22pmonksI'd just write that as a normal Clojure fn.
19:22tbaldrid_okay, so there is memfn
19:22tbaldrid_,(doc memfn)
19:22clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
19:23pmonks(defn encode [s] (.encode (java.util.Base64/getEncoder) (.getBytes s)))
19:23tbaldrid_but that fn ^^ is super weird and some docs even state that you should just use a function
19:23pmonksPerhaps with a type hint in the arg list to avoid a reflection warning.
19:23pmonks(defn encode [^String s] ...
19:35seancorfieldI have some ugly code I'd like to clean up. I have a side-effecting process p and a collection c. I want to (attempt to) apply p to every element of c. If any of those calls fail (with an exception), I want to arbitrarily (re-)throw any one of those exceptions (doesn't matter which), but I still want p applied to _all_ elements of c.
19:36seancorfieldso far I have (some (fn [e] (when e (throw e))) (doall (map p c))) but that feels like cheating...
19:48surtnseancorfield: what about with reduce? http://clojurepastebin.appspot.com/13689371
19:59seancorfieldsurtn: interesting alternative... eager so it evaluates every process and returns the sequence of exceptions if any...
20:15elvis4526Is there a good clojure formatter for emacs ?
20:15elvis4526or probably lisp in general
20:34justin_smithelvis4526: https://github.com/weavejester/cljfmt
20:36elvis4526justin_smith: Ty
20:36elvis4526is weavejester a kind of god or something?
20:36elvis4526Half of the lib i'm using are from him
20:36elvis4526lol
20:37justin_smithhah, he's good at finding itches and scratching them well
20:54gfredericks~weavejester is a kind of god or something
20:54clojurebot'Sea, mhuise.
20:58elvis4526I can't find the plugin for emacs, is there any?
20:59justin_smithelvis4526: I think cider actually integrates it for recent versions
20:59elvis4526wow
21:00justin_smithcider can be a little finicky though (it changes fast and has frequent backward-incompatible changes)
21:38itruslovejustin_smith: with the latest emacs (definitely 24.5, I don't know how far back) you can "pin" cider to a repository - melpa-stable currently has 0.8.2, there should be a far slower rate of change
21:39itrusloveit's in the cider installation notes https://github.com/clojure-emacs/cider/tree/v0.8.2#installation-via-packageel
21:49justin_smithitruslove: yeah, 0.8.2 is too old for cljfmt right?
21:50justin_smithit's the classic features vs. stability thing
21:56itruslovejustin_smith: ah... yeah. cider.
22:00brehaut_whats the lib of choice for json consumption atm?
22:00justin_smithcheshire works for me
22:00gfredericksit's definitely cheshire and it's definitely data.json
22:00gfredericksit's also definitely not both of them
22:00gfredericksbecause it's the other one
22:00brehaut_thanks
22:01justin_smiththis has been another episode of gfredericks in wonderland
22:11gfredericks~this |has been| another episode of gfredericks in wonderland
22:11clojurebotIk begrijp
22:46dkropfuntuchtanyone using lobos for database migrations?
23:49brainproxyso the jvm's gc has more room to "breathe" when there is a lot of i/o?
23:49brainproxyI put a println in a hot loop and I'm getting far less total memory consumption than when it's not there
23:50brainproxyso I'm explaining that to myself as the gc taking advantage of i/o wait, i.e. to do its thing
23:50hiredmanwell, println will just slow down the hot loop, and if your hot loop is generating garbage (which you should avoid) that will slow down the generation of garbage
23:52brainproxythat makes sense too; so the freq of garbage production is slowed down, ergo the gc is able to keep up better