#clojure log - Apr 27 2015

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

0:04 seangrove: Updated 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

1:02 mischov: Not sure who forked the refheap thingy with a more generic version, but I have a rebuttal.. :P https://www.refheap.com/100086

2:51 nicferrier: can one send to lots of async channels at the same time?

2:51 I want the opposite of alt :-)

2:51 I guess I just put them in a loop

2:55 oddcully: nicferrier: mult maybe?

2:56 nicferrier: oddcully: will look, thanks

4:06 jack0: when can we expect the result?

5:27 wasamasa: I'm currently breezing through 4clojure and wondered how to determine whether a character is uppercase

5:27 javadoc suggests there is an isUpperCase method for chars, but I can

5:28 not use (.isUpperCase \a)

5:28 anything I've overlooked?

5:29 TMA: wasamasa: you cannot do 'a'.isUpperCase() either IIRC

5:31 wasamasa: see also http://www.4clojure.com/problem/29

5:42 meh, apparently I can't use that shorthand since it's a static method

5:42 so, (java.lang.Character/isUppercCase \a) it is

5:53 notostraca: ,(re-find #"\p{Lu}" "A")

5:53 clojurebot: "A"

5:53 notostraca: ,(re-find #"\p{Lu}" \A)

5:53 clojurebot: #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...

5:53 notostraca: aww

6:00 bcn-flor: Is it possible to use the threading form for accessing maps which have string keys? (->mymap :address :city) works, but (-> mymap "address" "city") ?

6:02 mpenet: nope

6:02 ,(ancestors (type "a"))

6:02 clojurebot: #{java.io.Serializable java.lang.Comparable java.lang.Object java.lang.CharSequence}

6:20 Confusionist: It 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?

6:38 rcg: Confusionist, did you have a look at multimethods?

6:38 you could dispatch on the type of the argument vec? vs. not vec?

6:39 err, it's vector?

6:49 Confusionist: rcg, Ah, good point, I'

6:49 rcg, Ah, good point, I've kind of ignored multimethods so far... time to dive in

7:06 justin_smith: ,(Character/isUpperCase \A)

7:06 clojurebot: true

7:07 justin_smith: wasamasa: java.lang is always imported

7:07 wasamasa: justin_smith: oh, ok

7:07 justin_smith: the codegolfing solutions apparently just went for re-seq on a [A-Z] range

7:08 justin_smith: how very unkind to our friends whose languages are not ascii subsets

7:09 wasamasa: sneaky

7:13 TMA: Well, 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.

7:15 oddcully: ,(Character/isUpperCase Ï)

7:15 clojurebot: #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...

7:15 oddcully: erm

7:15 ,(Character/isUpperCase \Ï)

7:15 clojurebot: true

7:15 oddcully: ,(Character/isUpperCase \ï)

7:15 clojurebot: false

7:16 justin_smith: ,(Character/isLowerCase \☃)

7:16 clojurebot: false

7:16 justin_smith: ,(Character/isUpperCase \☃)

7:16 clojurebot: false

7:30 notostraca: wasamasa: justin_smith: ##(re-seq #"\p{Lu}" "ÏÏÏ")

7:30 lazybot: ⇒ ("Ï" "Ï" "Ï")

7:31 notostraca: one more char, all upper case in unicode

7:32 wasamasa: justin_smith: ##(re-seq #"\p{Ll}" (apply str (map char (range 150 200))))

7:32 lazybot: ⇒ ("ª" "µ" "º")

7:32 oddcully: and i bet it works better than the java function out of the age, where US-ASCII was the own charset they knew

7:32 s/own/only/

7:34 notostraca: wasamasa: justin_smith: ##(re-seq #"\p{Ll}" (apply str (map char (range 200 250))))

7:34 lazybot: ⇒ ("ß" "à" "á" "â" "ã" "ä" "å" "æ" "ç" "è" "é" "ê" "ë" "ì" "í" "î" "ï" "ð" "ñ" "ò" "ó" "ô" "õ" "ö" "ø" "ù")

7:34 notostraca: oh geez sorry about the pings

7:35 oddcully: it seems like it uses this internally http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#LOWERCASE_LETTER

7:35 but the \p stuff is more flexible

7:38 ##(re-seq #"\pL" (apply str (map char (range 150 200))))

7:38 lazybot: ⇒ ("ª" "µ" "º" "À" "Á" "Â" "Ã" "Ä" "Å" "Æ" "Ç")

7:38 notostraca: use \pL to match all letters and letterlike symbols

7:39 ##(re-seq #"\pP" (apply str (map char (range 32 128))))

7:39 lazybot: ⇒ ("!" "\"" "#" "%" "&" "'" "(" ")" "*" "," "-" "." "/" ":" ";" "?" "@" "[" "\\" "]" "_" "{" "}")

7:43 notostraca: ##(re-seq #"\p{LuSm}" (apply str (map char (range 32 200))))

7:43 whaaaaaat

7:43 wasamasa: why does this channel have two bots able of evaluating clojure?

7:44 notostraca: wasamasa: lazybot can eval long sequences of code and output to refheap

7:44 clojurebot lets you define things temporarily

7:44 they use different sandbox mechanisms

7:45 ,(re-seq #"\p{LuSm}" (apply str (map char (range 32 70))))

7:45 clojurebot: #<SecurityException java.lang.SecurityException: denied>

7:45 notostraca: ???

7:45 lazybot: notostraca: Oh, absolutely.

7:46 notostraca: ##(try (re-seq #"\p{LuSm}" (apply str (map char (range 32 70)))) (catch Exception e (.printStacktrace e)))

7:47 ##(+ 1 2)

7:47 lazybot: ⇒ 3

7:47 notostraca: ok, still working

7:47 wonder what went wrong

7:48 mmeix: Can this be shortened: "(defn circle [cx cy r] [:circle {:cx cx :cy cy :r r}])"?

7:49 m1dnight_: Guys, how can I prevent clojure from creating a squence of a string?

7:49 https://www.refheap.com/100096

7:50 I know strings are sequences, but I cant think of the proper term here :p

7:50 mpenet: dont use ~@, use just ~

7:50 notostraca: ~@ will splice it out

7:50 clojurebot: It's greek to me.

7:51 m1dnight_: yeah i was looking for proper definitions on that

7:51 so ~@ is "splicing"

7:51 ill read up on it

7:51 thank you mpenet

7:54 notostraca: mmeix, it could be shortened with a macro

7:54 mmeix: I thought about :keys, but this doesn't apply here

7:55 thanx

7:55 notostraca: the thing is, in a regular fn, [cx xy r] have those values, and you can't get the names

7:56 mmeix, is this for code golf?

7:56 mmeix: no, just a silly beginner's question :)

7:57 only wanted to make sure

7:57 thanx again

7:57 notostraca: np

7:58 it's tricky thinking about names and the values they hold

7:58 but in most cases it's simple enough that you don't need to worry :)

7:58 mmeix: I see

8:00 engblom: Readable 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.

8:00 mmeix: yes, I thought so

8:01 giving sane names for functions and vars seems to be a special art, I found

8:03 here's another beginner's question:

8:04 I have two namespaces, core and d

8:04 in d I have "(def add3 (partial + 3))"

8:05 which I can use in core, after :require [test.d :as d], like so (d/add3 5)

8:06 in test.d I have a second def: "(def five 5)"

8:07 but using "(d/add3 d/five)" in core gives me an error "No such var: d/five" -why?

8:09 notostraca: not sure actually

8:09 I wonder if the require is getting an older compiled version. try lein clean

8:10 mmeix: so it should work?

8:11 notostraca: I'm not sure how :as works with def, actually

8:11 mmeix: ah ...

8:12 I tried in two different projects, and it looks as if functions get adressed correctly, but simple value-definitions don't)

8:13 I#m feeling a bit dumb ...

8:15 but even fully qualified names don't work, just tested

8:15 ok, will find out

8:26 surtn: mmeix: it's because your five isn't d/five, it's test.d/five

8:26 you need to require both namespaces

8:27 mmeix: but I did :require [test.d :as d]

8:27 surtn: in core?

8:27 mmeix: ja

8:28 surtn: so core has (ns core (:require [test.d as d] [d :as d]))?

8:29 mmeix: must be some dumb oversight

8:29 surtn: I mean, if it does that won't work :)

8:30 mmeix: did you get it to work?

8:31 mmeix: https://www.refheap.com/100098

8:32 ah, now it worked

8:32 strange

8:32 sorry for bothering

8:34 surtn: no worries! yeah, it looks good, perhaps you hadn't loaded test/d.clj before trying to execute the code in core.clj

8:37 mmeix: just 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

8:37 there is something with Lighttable's REPL I didn't understand yet, I guess

8:38 ok, thanx for hints, guys

8:52 darthdeus: hey 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

8:52 and both options lead to ugly combinations of swap! and update-in :\

8:54 like 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?

9:00 engblom: darthdeus: 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.

9:03 darthdeus: Unless you need all from the map you pass around, you might only destruct out the part you need. It is very simple.

9:08 darthdeus: engblom: well there are no threads in cljs, and atoms are the only way to manage mutable state

9:08 engblom: I can't really just use an immutable map, since the external API needs to be mutable

9:11 engblom: darthdeus: That does not give much options than having to use what you already considered (atoms or refs).

9:11 darthdeus: engblom: yeah, but the thing I'm considering is a map of atoms, or atom containing a map

9:12 justin_smith: map of atoms is a bad idea

9:12 the 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.

9:13 darthdeus: justin_smith: i can't use refs in cljs

9:13 though my keys in the map are fixed

9:13 justin_smith: darthdeus: that's fine, you also don't have threads :)

9:14 gfredericks: a single atom right at the edge is the ideal way to implement a mutable api

9:14 justin_smith: point was - use one atom, unless you have threads+contention, then use refs

9:14 darthdeus: justin_smith: but there's still concurrent access and possible race conditions

9:14 kk, seems reasonable

9:14 justin_smith: atoms, as you might guess from the name, make their changes atomically

9:14 (all or nothing)

9:15 darthdeus: yup

9:16 one thing that sucks a bit though, is that I can't destructure a map containing an atom

9:16 justin_smith: you don't need a map containing an atom

9:16 darthdeus: sry an atom with a map in it

9:16 justin_smith: you can, if you deref

9:16 darthdeus: like if the argument being passed is the atom itself, i have to deref first

9:16 yeah

9:17 justin_smith: destructuring works in let blocks

9:17 darthdeus: yep, 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

9:22 CookedGryphon: Does anyone know how in clj-time you'd specify "The upcoming 2:30pm" for example?

9:22 so the first time it hits a time, after now

9:32 gfredericks: I've never thought about how to do that

9:33 sounds especially tricksy if you're using local time zones

9:33 CookedGryphon: My 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

9:34 shouldn'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

9:35 so 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

9:35 or at least a built in way

9:37 gfredericks: (inc puredanger) ; for not having conf t-shirts etc

9:37 lazybot: ⇒ 47

9:38 mpenet: CookedGryphon: you could use something like quartz, but it's trading a

9:38 a if clause for a dependency

9:39 CookedGryphon: yeah, that's a bit overkill!

9:39 happy 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

9:40 which wasn't just calculating the time today and then seeing if it's passed or not

9:40 noncom|2: CookedGryphon: to me clj-time seemed a fairly straight and low-level api

9:40 gfredericks: it'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

9:40 sveri: Hi, 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 ...] ...]?

9:41 noncom|2: CookedGryphon: 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

9:42 sveri: you can (mapv #(into [] %) your-partitioned-data) , instead of your outer (into [])

9:42 however, i am very interested if anyone esle can suggest anything better

9:42 CookedGryphon: gfredericks: 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

9:43 maybe I should drop the hours/minutes bit and just do it with the unix time for this particular use case

9:43 sveri: noncom|2: yea, havn't thought of that, my idea was to not generate a lazy seq in the first place :-)

9:44 mpenet: CookedGryphon: it's a long running process (I mean not a script)?

9:44 noncom|2: yeah, 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?

9:45 gfredericks: noncom|2: what don't you like about seqs? you want indexibility?

9:46 sveri: gfredericks: that's my usecase right now, I want to assoc into it

9:47 noncom|2: gfredericks: 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

9:47 3) * i mean, yeah, indexibility

9:47 gfredericks: noncom|2: I think the printing is kind of a bug

9:47 noncom|2: like, often those lazyseqs are not needed at all, however, clojure forces me into these lazyseqs when i do not even want to

9:47 gfredericks: sveri: why do you wnat to assoc?

9:48 CookedGryphon: mpenet: yeah

9:48 noncom|2: gfredericks: 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

9:49 sveri: gfredericks: I just have a multidimensional vec in an atom, my game-state which I want to update

9:49 noncom|2: i rarely get into computations that require multiseqs

9:49 gfredericks: noncom|2: the buggy thing is that printing still realizes the whole thing

9:49 noncom|2: * lazyseqs, sorry :)

9:49 gfredericks: ,(str (map inc (range 3)))

9:49 clojurebot: "clojure.lang.LazySeq@7861"

9:49 gfredericks: ,(str (map inc (range)))

9:49 clojurebot: #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] ...]}

9:49 gfredericks: ^^

9:49 noncom|2: OMG

9:50 and no one ever cared about that?

9:50 even in clojure-1.7.x ?

9:50 gfredericks: there's a ticket

9:50 what's the fix though? print something w/o realizing at all, or print the actual collection?

9:51 noncom|2: gfredericks: *realize-lazyseqs-on-print* ? :)

9:51 gfredericks: :/

9:52 noncom|2: haha.. well, maybe like LazySeq@7681 [a, b, c, ...] ?

9:52 like 3 elts are realized

9:52 idk rly

9:52 gfredericks: the reason they're realized is that the hexy thing is the hashcode

9:52 and hashcode requires realizing everything

9:53 noncom|2: ah, that's what...

9:53 gfredericks: so if you want a realization-free print you have to decide on something else to print

9:53 noncom|2: actually, when i print a lazyseq, really i expect to see its contents (at least partly)

9:54 so, yes, here we have a hard theoretical question...

9:57 mpenet: CookedGryphon: 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

9:58 noncom|2: CookedGryphon: also, there are the at-at and chimes libraries...

9:59 CookedGryphon: mpenet: I know how to do the runnign

9:59 I'm using schejulure

10:00 I 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:00 noncom|2: CookedGryphon: so, you construct an interval from (now) and till the time you check for, and then compare the interval?

10:00 CookedGryphon: yeah, but generating the time I'm checking for is clunky with clj-time

10:01 that's the only thing I have an issue with

10:01 getting that "next time it's 2pm", without doing "today at 2pm, is that time in the past? If so add a day" logic

10:07 noncom|2: CookedGryphon: try filing an issue maybe?

10:08 CookedGryphon: like, add (past?) and (future?) predicates...

10:09 CookedGryphon: bw, you can use the (after?) and (before?) predicates to compare the generated date with (now)

10:12 tomjack: printing a lazy seq is a type error :(

10:16 noncom|2: tomjack: 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:20 tomjack: wow

10:21 ,(binding [*print-length* 3] (str (iterate inc 0)))

10:21 clojurebot: "(0 1 2 ...)"

10:21 tomjack: ,(binding [*print-length* 3] (str (range)))

10:21 clojurebot: "(0 1 2 ...)"

10:21 tomjack: I guess the latter was fixed since alpha3

10:22 print is OK type-wise, I guess. str is a type error unless *print-length* is set :)

10:22 gfredericks: ha

10:22 ,(print (map inc (range 5)))

10:22 clojurebot: (1 2 3 4 5)

10:23 engblom: ,(str (range))

10:23 clojurebot: "(0 1 2 3 4 ...)"

10:24 H4ns: hi, 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:26 m1dnight_: 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:27 sobel: hrm, just noticed relational algebra is in contrib. anyone use that?

10:27 m1dnight_: Im trying to get it to work but I cant succeed

10:29 this is the error: Can't refer to qualified var that doesn't exist, compiling:(clojbot/modules/echo.clj:17:1)

10:29 Ive tried :require without :as, just :use etc

10:29 tomjack: hmm so the above OOM actually shows that *print-length* is broken for (map inc (range)), since clojurebot has *print-length* 5 by default?

10:30 (or maybe *print-length* isn't supposed to work for that at all, so "broken" is the wrong word..?)

10:35 noncom|2: H4ns: core.match looks pretty suitable. however, not sure about your task. maybe you better use (filter) .. ?

10:36 oskarkv: H4ns maybe https://github.com/oskarkv/map-regexps

10:38 H4ns: noncom|2: i'll give it a try.

10:38 oskarkv: i don't really think that i want to add another syntax like the map regex syntax that you have, but thanks!

10:43 eraserhd: I 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:43 It doesn't _reject_ my password, it times out waiting. Even though I hit enter like four times.

10:43 Ideas?

10:44 m1dnight_: aha, I have foundmy problem. defn inside a macro isn't so easy :>

10:45 eraserhd: Same result in a non-tmux window.

10:50 gfredericks: `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:51 on some computers I have to just run through the :release-tasks manually and it works that way o_O

10:51 bacon1989: was wondering, has anyone here used the Component Design Pattern? https://github.com/stuartsierra/component

10:52 Is it really required for writing bigger clojure applications?

10:52 Or I mean, does it at least simplify the process

10:52 wasamasa: it does make it cleaner

10:53 TimMc: m1dnight_: ~(name name-of-var)

10:53 bacon1989: wasamasa: I was looking it over, and got held up on a few things. The database component example kind of threw me off

10:54 like when a component uses the database component

10:54 it just starts referring to the 'database' var, and the only way to figure this out is to look at the system definition?

10:54 I"m guessing the components are supposed to be quite small, with few dependencies

10:54 wasamasa: yup

10:55 bacon1989: wasamasa: I'm just thinking about how a new user who hasn't dealt with this model might make huge mistakes in that manner

10:55 but I guess that could happen with any design

10:55 in the manner of making it monolithic

10:55 wasamasa: indeed

10:56 bacon1989: indubitably

11:29 justin_smith: noncom|2: well, partition as provided by clojure is a lazy seq algorithm

11:29 ooops, sorry I was in deep scrollback and forgot

11:30 noncom|2: justin_smith: yet, you've just answered a question that nobody yet answered :)

11:30 justin_smith: haha

11:30 noncom|2: yeah, it is lazyseq inherently..

11:30 justin_smith: one could construct a vector partition

11:30 but that would be a different function, surely

11:31 noncom|2: clojrue strangely leans toward vectors, but still, uses lists in most of its functions... thats.. umm.. funny?

11:31 or don't i understand something?

11:31 justin_smith: eg. first construct a vector of n elements, then fill it, as you walk the input

11:31 dnolen: noncom|2: lists and lazy sequences aren't the same thing

11:31 justin_smith: it prefers vectors for literals (this is good, you can construct them when compiling and reuse them, they are associative etc.)

11:32 and it prefers to generate lazy things at runtime (because this allows nice lazy algorithms)

11:33 eli-se: What is the preferred generic way to test membership in a set?

11:33 justin_smith: eli-se: contains?

11:33 eli-se: Applying the set doesn't work if the set contains false.

11:33 Ah, I see. Of course.

11:33 justin_smith: ,(contains? #{false} false)

11:33 clojurebot: true

11:33 eli-se: nice

11:33 justin_smith: ,(contains? #{nil} nil)

11:33 clojurebot: true

11:34 justin_smith: ,(contains? #{Double/NaN} Double/NaN) ; the one gotcha, but your fault for using this value

11:34 clojurebot: false

11:34 eli-se: amazing

11:35 justin_smith: nan is weird

11:40 expez: (first (reduce concat (map next-results (range 1 4000))))

11:40 ;; StackOverflowError clojure.core/seq (core.clj:133)

11:40 justin_smith: expez: cemerick has a recent article on concat

11:40 expez: How can you start consuming this lazy-seq without blowing the stack?

11:40 justin_smith: and why you should not do that

11:41 expez: justin_smith: this is from stuartsierra's post from yesterday

11:41 which is about how people get into trouble with concat

11:41 justin_smith: oh, I misremembered

11:41 he has the answer in the same blog

11:42 the problem is reduce and concat - reduce is eager, concat is lazy

11:43 if you are using reduce, use into and a vector instead of concat and a lazy-seq

11:44 expez: aha, I thought it was 'first' that forced the realization of the lazy-seq

11:44 but it does blow up anyway

11:46 justin_smith: reduce can't do lazy. It can incidentally return something that is lazy, but itself it is eager.

11:46 expez: When I read the post and saw the stacktrace I was like "Aha! so that's what that was"

12:01 TimMc: $seen djpowell

12:01 lazybot: djpowell was last seen quittingQuit: Bye 9 weeks and 6 days ago.

12:03 justin_smith: is 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:04 mdrogalis: justin_smith: I don't think so.

12:07 justin_smith: I'm tempted to test the supers so at least my code works with a concrete substitution

12:08 (contains? (supers (class (>/chan))) clojure.core.async.impl.protocols.WritePort)

12:08 something like that

12:28 amalloy: justin_smith: that's an odd way to write (instance? ...)

12:32 justin_smith: (inc amalloy)

12:32 lazybot: ⇒ 262

12:32 justin_smith: I knew there was something simpler, but it was escaping me

12:32 amalloy: also, it sounds like it's a protocol, right, not just an interface?

12:33 justin_smith: yeah

12:33 amalloy: so you'd be a bit better off using safisfies: (satisfies? (>/chan) c.c.a.i.p/WritePort)

12:33 justin_smith: yeah, but I have a condp... I may or may not be only checking protocols

12:34 and of course that condp could be a multimethod or protocol... early stages of the design

13:01 timvisher: in clojure.java.jdbc, if i have a column named `charnock_column`, should be able to `insert!` against it using `{:charnock-column "value"}`?

13:02 hiredman: no

13:02 :charnock_column

13:02 fowslslegs: Is 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:03 add two bytes*

13:03 Or rather that my result is a byte array?

13:06 puredanger: you'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:06 you can use ^bytes to hint a byte[]

13:07 timvisher: hiredman: ah. suppose if i want that sort of magic i should be going above java.jdbc...

13:10 java.jdbc does, however, seem to translate the column names on retrieval...

13:11 or actually i suppose liberator is doing that in this case...

13:18 lasergoat: i use camel-snake-kebab to translate my keys coming and going to jdbc

13:19 timvisher: lasergoat: hadn't heard of it. thanks :)

13:19 lasergoat: and yeah, java.jdbc doesn't translate them for the results either; something else must be doing that for you

13:43 m1dnight_: Is there a macroexpand-2 of some sort?

13:45 craigglennie: How 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:46 When 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:47 It'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:49 luxbock: craigglennie: I like to have a scratch buffer where I play around

13:51 craigglennie: luxbock: That's an emacs thing, right?

13:53 engblom: craigglennie: 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:55 dnolen: craigglennie: 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:57 craigglennie: engblom: 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:58 engblom: craigglennie: 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:59 craigglennie: engblom: Thanks. Maybe they'll see this. If not, I can deal with just copy-paste for now.

14:11 puredanger: cfleming is the author of Cursive

14:13 daviid: i 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:14 justin_smith: daviid: i-support.clj is not a valid file name

14:15 daviid: ij-support.clj, ok why ?

14:15 justin_smith: if the ns is called ij-support the file needs to be ij_support.clj

14:15 because java

14:15 daviid: ok

14:15 justin_smith: after the filename is correct, require or use should work

14:15 daviid: too bad but i will survive :)

14:15 let me try then

14:16 justin_smith: also, the file needs to be on your classpath in a file path that reflects the package

14:16 so if the ns is just ij-support and you have the default lein setup, it should be in src/ij_support.clj

14:16 m1dnight_: 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:17 daviid: that's indeed my second quiz, how do i inform clojure of location of things i would like to require/inport/use

14:17 justin_smith: but having some package is highly recommended (it avoids weird collisions)

14:17 daviid: it looks on its classpath, using folders as the elements of the package

14:17 so foo.bar.baz would be in src/foo/bar/baz.clj

14:18 daviid: justin_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:18 justin_smith: daviid: this is similar, but we let leiningen manage the classpath, it's easier that way

14:19 and instead of managing the classpath directly, we declare our dependencies, and it builds the apropriate path. Thus we avoid version conflicts.

14:19 daviid: actually i'd like just to use emacs [and later slime but it seems complicated to configure]

14:19 justin_smith: there are other tools like boot, or even maven, but the concept is similar

14:19 daviid: emacs is not even a factor here

14:20 daviid: ok but just using clojure

14:20 justin_smith: that's like saying "I just want to use c and not make"

14:20 engblom: daviid: All you need is any text editor, jre and leiningen. Leiningen will even provide Clojure for you

14:20 justin_smith: there are options other than lein, but the sane path is to use one of them

14:21 amalloy: m1dnight_: what would macroexpand-2 do? just be (comp macroexpand-1 macroexpand-1)?

14:21 daviid: i don't want to use Leiningen, just a clojure repl in emacs

14:21 m1dnight_: ah, i didnt think about that. But i already rolled my own in the mean while :D

14:21 justin_smith: daviid: like I said, that is like using c but not make

14:21 daviid: and alter the load-path so my ij_support.clj

14:21 justin_smith: it's silly

14:21 once you are in ij_support.clj you should be done setting your classpath

14:22 unless you are adding deps at runtime interactively

14:22 daviid: how do i set my classpath

14:22 justin_smith: it's a command line arg to java

14:22 amalloy: well, what you wrote is quite different from that

14:22 justin_smith: or use a tool that sets it up properly

14:23 m1dnight_: I know, but it did what I wanted. Show me the expansion of my two macros

14:23 daviid: as an example the file is here: /usr/lpdi/projects/clojure/cljs/ij_support.clj

14:23 m1dnight_: well, i dont know what you mean, but ill try once I get this little bastard working :D

14:23 justin_smith: daviid: 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:23 amalloy: m1dnight_: 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:23 m1dnight_: I was waiting for somebody to want to help so I could explain :)

14:24 justin_smith: daviid: 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:25 engblom: daviid: 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:25 justin_smith: daviid: 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:25 m1dnight_: 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:26 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:27 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:27 Not even a simple print. And im wondering why that could be. The expanded form looks perfect to me..

14:28 amalloy: m1dnight_: (doseq [cmd# [~@cmds]] ...)

14:28 is the first thing i would fix

14:28 m1dnight_: but isn't [~@cmds] == ~cmds ?

14:29 amalloy: &(let [cmds (range 5)] `{:yours ~cmds, :mine [~@cmds]})

14:29 lazybot: ⇒ {:yours (0 1 2 3 4), :mine [0 1 2 3 4]}

14:29 m1dnight_: :(

14:29 your solution worked

14:29 i feel stupid :p

14:29 amalloy: you see the difference, and why it matters?

14:29 m1dnight_: I know the first is a list and probably doesnt implement Seq ?

14:30 well, cant be used as a seq

14:30 or is mine interpreted as an expression?

14:30 for lack of proper jargon, mine is not interpreted as a list of data, but as an expression

14:31 amalloy: yes

14:31 you could also write (list ~@cmds)

14:31 m1dnight_: ah well, i was indeed under the assumption that those were semantically equivalent

14:32 (inc amalloy)

14:32 lazybot: ⇒ 263

14:35 gfredericks: hey a prime

14:35 justin_smith: hmm

14:35 (identity justin_smith)

14:35 lazybot: justin_smith has karma 249.

14:35 justin_smith: divisible by 3

14:35 gfredericks: boooo

14:36 daviid: java -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:36 m1dnight_: (identity m1dnight_)

14:36 lazybot: m1dnight_ has karma 1.

14:36 m1dnight_: PRIME \o/

14:36 justin_smith: daviid: it needs to be separated by :

14:36 like your shell path

14:37 daviid: you are pointlessly punishing yourself with needless complexity by doing it this way

14:37 daviid: is it not? java -cp clojure.jar:ij-core.jar:cljs [cljs is a symbolic link]

14:38 justin_smith: sorry, misread

14:38 where did ij-core.jar come from?

14:38 daviid: it's a symblic link as well but that worked for ages

14:38 justin_smith: also import does not work on namespaces, only classes

14:38 you don't import a namespace, you require it or use it

14:39 a namespace is a datastructure, not a class

14:40 also, you should rename get-particles.clj to get_particles.clj if you ever expect it to be auto-loaded

14:40 (via require or use or load)

14:41 je: looking 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:41 daviid: ok. 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:42 Poky: je: split-at ?

14:42 justin_smith: daviid: people that know clojure will waste cognitive time wondering if that file name is going to break something

14:42 je: notice 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:43 Poky: oh I'm stupid, that takes an index.

14:43 daviid: the ultimate goal is to call it get-particles

14:43 nobody should even know it is clojure...

14:43 but let me get thing working first

14:44 justin_smith: daviid: then provide a launcher script with the java invocation inside it

14:44 in fact you can embed that in a jar

14:44 the .clj file is not the right place to do that abstraction IMHO

14:44 je: Poky: 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:44 daviid: justin_smith: yes but let's do that after, it still does not work now

14:44 je: Poky: but thanks :-)

14:44 justin_smith: OK

14:45 daviid: once you want to pack it up, you can put a #!/usr/bin/java inside an uberjar

14:45 remarkably enough

14:45 daviid: here my ns def: [part of it] (ns ij-support "imagej support" (:import '(ij IJ)))

14:45 Poky: je: 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:45 daviid: the system says: Exception in thread "main" java.lang.ClassNotFoundException: quote.(ij IJ)

14:46 justin_smith: daviid: yeah, inside ns forms, you don't quote deps

14:46 it's a macro, it's already quoted for you

14:46 (:import (ij IJ))

14:47 daviid: right, now it complains with something else, let me understand and copy here

14:49 in 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:49 justin_smith: daviid: importing is per namespace

14:49 daviid: ah ok

14:49 justin_smith: if IJ is not imported, you would get that error

14:49 daviid: understood

14:50 justin_smith: daviid: in general dependencies and sources of definitions are explicit and local in clojure

14:50 it's one of the great things about the language, as far as I am concerned

14:50 daviid: same in scheme, my mistake

14:50 justin_smith: the classpath stuff actually helps with that (explicit controllable versions), despite being a little clunky

14:52 daviid: ok it seems to work now, many thanks, my first ns just borned

14:52 :)

14:53 justin_smith: cool

14:54 daviid: within the namespace i defined, i don't need to explicitly export right?

14:54 all defn are available to whom (use ...)?

14:55 j-pb: daviid: yes

14:55 daviid: [in scheme we have to export]

14:55 j-pb: daviid: you can define private functions with defn-

14:55 daviid: j-pb: ok

14:57 going afk for a little bbl, tx

15:10 borkdude: I'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:11 cfleming: craigglennie: 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:11 craigglennie: 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:12 craigglennie: If you load that NS into the REPL it should work

15:16 craigglennie: cfleming: Okay, thanks. Is there a keyboard shortcut for "send to REPL", so I don't have to go through the context menu?

15:18 TimMc: Huh, the Sonatype Central Repository's terms of service exclude "pornographic" submissions.

15:18 * TimMc is not tempted to make a porn rendering engine or something and try to submit it

15:18 TimMc: s/not/now/ :-P

15:19 Then we could have a great argument over whether a jar file is pornographic, or whether merely its possible outputs are.

15:19 cfleming: craigglennie: See https://cursiveclojure.com/userguide/keybindings.html for details

15:19 craigglennie: cfleming: t

15:19 hanks

15:22 virmundi: hello. 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:22 {action: “function () { console.log(‘worthless transaction’);}”}

15:23 I would like to embed the JavaScript structure directly in the code.

15:23 {:action (js function() { blah; blah}))

15:24 I 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:24 Am I on the right track?

15:28 stevenleeg: does anyone know what happened to to the leiningen package for debian sid?

15:28 I only see the package for wheezy

15:35 felipedvorak: I'm a web developer. I'm curious about functional programming. I should learn... ?

15:36 the-kenny: felipedvorak: Regardless of chosen programming language, FP will help you think different about problems :)

15:37 felipedvorak: 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:39 arav93: could someone say who the selected students are?

15:40 Bronsa: arav93: it's public info on the gsoc site

15:41 sveri: felipedvorak: well, it still is better than plain javascript regarding the language aspect

15:41 arav93: I'm unable to access

15:41 * gfredericks is working on a test.check generator for collections of distinct elements

15:41 Bronsa: arav93: https://www.google-melange.com/gsoc/projects/list/google/gsoc2015

15:42 sobel: TimMc: i wonder if that means they would not host open firmware for a sex toy

15:43 gfredericks: firmware in a jar?

15:43 sobel: firmware is relative

15:45 TimMc: sobel: Yeah, exactly!

15:46 Could be considered "obscene" under their rules too.

15:46 "FORTRAN is not meant to be used that way!"

15:46 Oh crap, they'll probably ban swearjure.

15:52 felipedvorak: the-kenny: :) thanks.

15:52 jason__: 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:53 felipedvorak: sveri: I see, JavaScript doesn't get a lot of love...

15:55 TimMc: jason__: In that code you are trying to call a var called schemas in a namespace *literally* called schema-ns.

15:55 What you want to do is look up the var and call that. ((resolve (name schema-ns) "schemas")) should do it.

16:04 m1dnight_: what do peopl euse for http requests? (something like requests for python, for those wwho know it)

16:04 something that handles cookies etc all easily

16:05 the-kenny: So you want a browser? :)

16:05 jason__: 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:05 m1dnight_: the-kenny: a headless browser, yes! :p

16:06 the-kenny: m1dnight_: I'm not aware of a library that handles cookies, cookie-storage, etc. for you - for other stuff, http-kit might be good

16:08 jason__: 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:10 ahh i see - just had to require the NS first. thanks TimMc

16:11 justin_smith: jason__: resolve can take the ns and var args separately, no need to do a string concat

16:11 (doc resolve)

16:11 clojurebot: "([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"

16:12 justin_smith: oh wait, I am thinking of ns-resolve

16:12 (doc ns-resolve)

16:12 clojurebot: "([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:12 justin_smith: yeah, that's the one

16:14 arohner: m1dnight_: clj-http can handle cookies for you, but it's not a browser

16:15 m1dnight_: https://github.com/dakrone/clj-http#cookie-stores

16:16 sobel: cookie handling sounds like a good idea right now (hungry)

16:21 m1dnight_: arohner: i just stumbled upon it! :)

16:21 it looks excellent!

16:21 I was guessing there would something as lean as requests.py

16:25 wasamasa: requests.py wraps three libraries that have the prefix "urllib" in common

16:25 that's not what I'd use as example of a lean library

16:25 no, 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:27 m1dnight_: thats what i meant with lean

16:27 lean as in, making an http request is as easy as one expects it to be

16:27 no hassle, no fuss. Just a request.

16:28 wasamasa: well, you're in luck then, the clojure libraries I've seen so far strive for simplicity

16:29 justin_smith: that definition of lean is the opposite of most I've seen

16:29 wasamasa: ^

16:31 the-kenny: m1dnight_: the problem is: HTTP is everything but easy. You can hide complexity, but that will break

16:37 scizo: I 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:38 justin_smith: (doc ns-unmap)

16:38 clojurebot: "([ns sym]); Removes the mappings for the symbol from the namespace."

16:39 scizo: My 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:39 justin_smith: scizo: vars are created before the forms are executed. This allows primitive recursion.

16:40 scizo: I understand that the var is created before the forms are executed, but generally not before the previous expression, correct?

16:41 justin_smith: well, Long is already mapped to java.lang.Long

16:41 scizo: It certainly behaves as I would expect in the absence of aot compilation.

16:42 justin_smith: is there a reason you need to shadow java.lang? does the issue persist if you aren't shadowing something in java.lang?

16:42 scizo: Yes. 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:44 The 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:45 justin_smith: OK.

16:45 scizo: I could also get rid of the ns-unmap and live with the WARNING everytime that namespace is evaluated, but that gets annoying.

16:46 I 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:46 justin_smith: scizo: 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:47 scizo: what if you had (defn init [] (ns-unmap *ns* 'Long) (def Long :long-exists))

16:48 usually a def inside a defn is a bad idea, but here it might make things more sensible

16:48 of course this still requires calling init

16:49 or would even the defn form cause the warning about shadowing Long?

16:51 scizo: I 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:52 justin_smith: I tried init, it causes an error

16:54 scizo: The same behavior is exhibited when trying to unmap 'map. It works without aot compilation, but doesn't with.

16:56 justin_smith: yeah, 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:50 scizo: justin_smith: Thanks for taking a look!

18:14 arohner: is there a library that *generates* html, using the data returned by clj-tagsoup lazy-parse-xml?

18:16 amalloy: i would be a little surprised if tagsoup returned xml in a format other than the one used by enlive

18:20 arohner: clj-tagsoup lazy-parse-xml is a different format from 'normal' clj-tagsoup, it returns clojure.data.xml

18:20 AFAICT, enlive uses tagsoup directly

18:20 enlive is a mess, documentation-wise, so I'm trying to avoid it

18:22 Bruce_Wayne: off topic, but does anyone know how to accept the rules on a kickstarter project?

18:22 trying to launch my project now, but says i need to accept the rules first...

18:24 amalloy: clojure.data.xml is the same as enlive's format. you should be able to use either to emit html/xml

18:30 hiredman: enlive has comment nodes

18:31 I guess clojure.data.xml does too, and I am thinking of clojure.xml

18:40 amalloy: yeah clojure.xml is pretty featureless

18:52 brehaut_: what we need is xml literals

18:59 amalloy: brehaut_: flagship new feature for 1.8.0: #xml [:people [:person {:name "x"}] [:person {:name "y"}]]

19:00 brehaut_: amalloy: point taken. i shouldnt joke about this stuff

19:02 j-pb: amalloy: and buggy

19:02 amalloy: clojure.xml is pretty broken

19:03 arohner: brehaut_: amalloy: wow, enterprise-ready, right there!

19:04 brehaut_: oh man we could have an #xslt tag that compiles XSLT from #xml notation directly into clojure code

19:05 j-pb: I'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:05 * the-kenny wants Common Lisp Literals: #cl (asdf-install:install ...)

19:06 j-pb: #clj [:map :inc [:range 10]] that is

19:13 rmanders: why 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:16 surtn: rmanders: .encode isn't a clojure function, so you can't partial it

19:16 tbaldrid_: .encode is not a function, it's actually a special form

19:16 pmonks: This works: (def encode (partial #(.encode (java.util.Base64/getEncoder) %)))

19:20 rmanders: Thanks pmonks. Is this the preferred way to treat java instance methods as clojure functions?

19:21 amalloy: rmanders: do not follow pmonks's example, it is super-weird

19:22 pmonks: ;-)

19:22 <insert usual n00b warning)

19:22 amalloy: specifically, the (partial) there might as well be (identity)

19:22 pmonks: To be fair, I wouldn't do that anyway.

19:22 I'd just write that as a normal Clojure fn.

19:22 tbaldrid_: okay, so there is memfn

19:22 ,(doc memfn)

19:22 clojurebot: "([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:23 pmonks: (defn encode [s] (.encode (java.util.Base64/getEncoder) (.getBytes s)))

19:23 tbaldrid_: but that fn ^^ is super weird and some docs even state that you should just use a function

19:23 pmonks: Perhaps with a type hint in the arg list to avoid a reflection warning.

19:23 (defn encode [^String s] ...

19:35 seancorfield: I 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:36 so far I have (some (fn [e] (when e (throw e))) (doall (map p c))) but that feels like cheating...

19:48 surtn: seancorfield: what about with reduce? http://clojurepastebin.appspot.com/13689371

19:59 seancorfield: surtn: interesting alternative... eager so it evaluates every process and returns the sequence of exceptions if any...

20:15 elvis4526: Is there a good clojure formatter for emacs ?

20:15 or probably lisp in general

20:34 justin_smith: elvis4526: https://github.com/weavejester/cljfmt

20:36 elvis4526: justin_smith: Ty

20:36 is weavejester a kind of god or something?

20:36 Half of the lib i'm using are from him

20:36 lol

20:37 justin_smith: hah, he's good at finding itches and scratching them well

20:54 gfredericks: ~weavejester is a kind of god or something

20:54 clojurebot: 'Sea, mhuise.

20:58 elvis4526: I can't find the plugin for emacs, is there any?

20:59 justin_smith: elvis4526: I think cider actually integrates it for recent versions

20:59 elvis4526: wow

21:00 justin_smith: cider can be a little finicky though (it changes fast and has frequent backward-incompatible changes)

21:38 itruslove: justin_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:39 it's in the cider installation notes https://github.com/clojure-emacs/cider/tree/v0.8.2#installation-via-packageel

21:49 justin_smith: itruslove: yeah, 0.8.2 is too old for cljfmt right?

21:50 it's the classic features vs. stability thing

21:56 itruslove: justin_smith: ah... yeah. cider.

22:00 brehaut_: whats the lib of choice for json consumption atm?

22:00 justin_smith: cheshire works for me

22:00 gfredericks: it's definitely cheshire and it's definitely data.json

22:00 it's also definitely not both of them

22:00 because it's the other one

22:00 brehaut_: thanks

22:01 justin_smith: this has been another episode of gfredericks in wonderland

22:11 gfredericks: ~this |has been| another episode of gfredericks in wonderland

22:11 clojurebot: Ik begrijp

22:46 dkropfuntucht: anyone using lobos for database migrations?

23:49 brainproxy: so the jvm's gc has more room to "breathe" when there is a lot of i/o?

23:49 I put a println in a hot loop and I'm getting far less total memory consumption than when it's not there

23:50 so I'm explaining that to myself as the gc taking advantage of i/o wait, i.e. to do its thing

23:50 hiredman: well, 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:52 brainproxy: that makes sense too; so the freq of garbage production is slowed down, ergo the gc is able to keep up better

Logging service provided by n01se.net