#clojure log - Jun 15 2014

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

0:01 catern: umpa: er, which values in particular are you trying to get?

0:02 the first and last of the first in the list, and the first and last of the last in the list?

0:02 umpa: catern: yes

0:02 catern: no offense, but it sounds like you're doing something horribly wrong...

0:02 why do you need those values in particular?

0:03 umpa: I use them as arguments

0:03 catern: for what?

0:04 umpa: for an intersection with a dpendency

0:06 catern: if you say so. you could write a function: (defun bounds [seq] (list (first seq) (last seq))) and then do (map bounds (bounds x))

0:09 TEttinger: why do you need the last of the first list?

0:09 don't you just need ffirst and (last (last ...)) ?

0:10 johnwalker: you really like partition

0:11 umpa: catern: nice

0:11 TEttinger: its a grid with corners

0:11 TEttinger: oh I get it

0:12 catern: ah, that's not that bad then

0:19 deathknight: been at this for hours...would probably take one of you guys about 5-10 minutes to help me do this

0:19 trying to auth with google with this tutorial: http://blog.knoldus.com/2014/04/05/google-sign-in-using-clojure/

0:19 When I add that to a new compojure project, I get an http 400 error

0:24 benkay: is there a dumb-dumb test-profiler kicking around?

0:26 johnwalker: by google sign-in, do you mean openid?

0:27 deathknight: or are those separate things entirely?

0:27 deathknight: Sorry for not being clear

0:27 Google uses OAuth 2

0:28 johnwalker: ahh

0:29 deathknight: As of 1 minute ago I just found an example on github that has a Google Oauth2 login handler that uses the friend lib!!

0:30 so pumped

0:30 johnwalker: oh nice

0:31 deathknight: whats nice is the 3 energy drinks

0:31 johnwalker: caffeine is bad for you

0:32 ,(def caffeine-overflow "8mg")

0:32 clojurebot: #'sandbox/caffeine-overflow

0:33 deathknight: keep going

0:33 benkay: ,(println caffeine-overflow)

0:33 clojurebot: 8mg\n

0:33 deathknight: mmmm

0:34 benkay: hm.

0:34 noonian: ,caffeine-overflow

0:34 clojurebot: "8mg"

0:34 benkay: a yeah.

0:35 thanks, noonian

0:38 noonian: hmm, 8mg is not much caffeine at all

0:39 johnwalker: lol

0:41 benkay: noonian: http://goo.gl/oWcMzB

0:42 noonian: haha, that looks dangerous

0:42 johnwalker: related: https://twitter.com/dozba/status/477917824870912000

0:43 benkay: tchyeah

0:43 systemfault: The LD50 of caffeine in humans is dependent on individual sensitivity, but is estimated to be about 150 to 200 milligrams per kilogram of body mass or roughly 80 to 100 cups of coffee for an average adult

0:44 benkay: when i was working out in the burbs and the coffee was miserable and likely moldy i was in the habit of dropping 200 mikes into 2 liters of water, and drinking one of those concoctions in the morning and after lunch

0:44 'twas GREAT

0:44 TEttinger: mikes?

0:44 http://www.amazon.com/ProLab-Caffeine-Maximum-Potency-100-Count/dp/B0011865IQ/ref=pd_sbs_hpc_17?ie=UTF8&refRID=0AA4EDD7RYQK16J99SJF these are not that different from 2 cups coffee

0:45 benkay: TEttinger: mg

0:45 TEttinger: (taking one now)

0:45 benkay: that's a 200 mike pill as well :)

0:46 TEttinger: the 2 liters water is odd though

0:46 it seems like a ton

0:46 deathknight: has anyone used friend-oauth2 to communicate with google?

0:48 luxbock: I'm having some trouble trying to merge two project files generated from templates to get the best out of both

0:48 TEttinger: luxbock, got them in a gist maybe?

0:48 benkay: TEttinger: 4L/day is a superb hydration level.

0:48 luxbock: https://gist.github.com/anonymous/70c4e04b84c1197e756e

0:49 this is what I have

0:49 TEttinger: benkay, no doubt, I drink water constantly

0:49 but finishing a 1.5 liter bottle in a sitting would be a challenge

0:49 benkay: TEttinger: i rarely made it through the whole second bottle.

0:49 luxbock: but when I start try to use cider-repl-jack-in it complains about the austin class file missing

0:50 benkay: ah well it was over the course of the pre-lunch drag and the post-lunch drag

0:50 luxbock: so basically it's not finding the stuff I have defined in the dev-profile

0:50 benkay: that job was a real drag

0:50 i've graduated to a .75L bottle always at hand. people think i'm a wino when they first see this in practice!

0:50 luxbock: reading the Leiningen profile docs it says :dev profile is automatically merged into the default profile, so I'm confused why it's not finding the :dev :plugins/dependenceis

0:51 TEttinger: WARNING Austin is not compatible with the (currently) latest ClojureScript release. (context) Use ClojureScript 0.0-2156 until the a new ClojureScript release is cut that includes the resolution of the underlying issue.

0:51 luxbock: ahhh

0:51 yeah I just did `lein ancient update` before

0:51 alright makes sense, thanks

0:52 TEttinger: so you would change the dep on line 8 to 0.0-2156 , luxbock

0:53 no prob, I actually only found it because I didn't know what austin was

0:54 luxbock: hmm, I still have the same problem

0:54 I think these issues might be unrelated

0:54 TEttinger: gah

0:55 maybe https://gist.github.com/anonymous/70c4e04b84c1197e756e#file-project-clj-L40 doesn't have it loaded by the highlighted point?

0:56 luxbock: the two templates that I'm trying to merge are https://github.com/magomimmo/om-start-template and https://github.com/bhauman/devcards-template

0:56 umpa: ,(defn coffee [sip] (coffee (inc sip)))

0:56 clojurebot: #'sandbox/coffee

0:56 luxbock: in om-start-template the :dev profile is defined in a profiles.clj file

0:56 which I moved into the project.clj file for my project, thinking it would not make a difference

0:57 but maybe that's the issue

0:57 umpa: ,(coffee 0)

0:57 clojurebot: #<StackOverflowError java.lang.StackOverflowError>

0:58 TEttinger: I dunno, I've barely touched profiles

0:59 luxbock: yeah works now, though I'm not exactly sure what's actually different from leins point of view

1:02 deathknight: friend-oauth2-example's google example doesn't work -- it's not up to date with friend-oauth2's new :credential-fn. Is anyone familiar with how I can adapt this (https://github.com/ddellacosta/friend-oauth2-examples/blob/master/src/friend_oauth2_examples/google_handler.clj) to work correctly with this (https://github.com/ddellacosta/friend-oauth2/blob/master/test/friend_oauth2/test_helpers.clj#L65-L67)?

1:11 johnwalker: deathknight: if you can figure it out, it's good blog post material

1:12 deathknight: :D

1:12 johnwalker: i would retweet it to my fifteen followers who favorite but never retweet

1:12 deathknight: Haha!

1:12 It's super over my head at the moment in the sense that I'm not sure where to start looking for the answer. Is there a direction your finger can point in so I can understand the problem?

1:14 johnwalker: does ddellacosta's link work?

1:14 er, the first one?

1:15 oh

1:15 deathknight: his google example does not work

1:15 he even addressed it in an issue on the corresponding github page

1:16 johnwalker: but the oauth2 does?

1:16 deathknight: so it successfully takes me to google's oauth2 page where I give consent to the app

1:16 and then upon redirect, there is a failure of permission authentication

1:16 (even though I gave permission)

1:17 johnwalker: does this pr help?

1:17 https://github.com/ddellacosta/friend-oauth2/pull/18

1:17 deathknight: not sure -- looking in to it

1:18 also, relevant to the issue: https://github.com/ddellacosta/friend-oauth2-examples/issues/4

1:18 johnwalker: oh, thats good stuff

1:19 i don't know but i hope you figure it out

1:19 deathknight: thank you John!

1:20 johnwalker: you're welcome, sorry i can't help

1:20 friend confuses me in general

2:07 benkay: I don't use Friend, tbh.

2:08 it's a little more work, but the flexibility and power of writing my own auth handlers is pretty great.

2:08 definitely not what people coming from the webdev community at large are expecting though vis-a-vis authentication libraries.

2:38 ambrosebs: a seq can only be infinite if (every-pred #(instance? clojure.lang.IPending %) (complement realized?))

2:38 right?

2:39 I don't think that make sense.

2:39 ,((every-pred #(instance? clojure.lang.IPending %) (complement realized?)) (seq (range)))

2:39 clojurebot: false

2:40 ambrosebs: so I guess all bets are off if you're holding an arbitrary seq.

2:44 dbasch: ambrosebs: it’s the halting problem essentially

2:45 amalloy: ambrosebs: IPending is very much a "well, maybe, whatever" - it doesn't really mean anything reliable

2:47 and the ISeq type is open, so i can easily create an instance of it which is infinite but doesn't implement IPending, with something like (reify ISeq (first [this] 1) (more [this] this))

2:57 &(take 10 (reify clojure.lang.ISeq (first [this] 1) (more [this] this) clojure.lang.Seqable (seq [this] this) clojure.lang.Sequential)) ;; to be specific, this is apparently the minimum list of interfaces you need to implement to be printable

2:57 lazybot: ⇒ (1 1 1 1 1 1 1 1 1 1)

3:10 ambrosebs: amalloy: interesting.

3:12 assuming seqs are infinite is probably a cleaner solution for me anyway.

3:51 sveri: Hi, I am struggling to check if a function call generates an assertion with test.check. In a normal test I would call (is (thrown? Assert (function... But how do I do that with test.check?

3:57 visof: Hello

3:58 ,(clojure.string/replace (clojure.string/replace "\"Hello\nWorld\"" #"\"" "") "\n" " ")

3:58 clojurebot: "Hello World"

3:58 visof: is there a better way to do this?

4:04 TEttinger: it's two separate replacements?

4:13 danielcompton: visof: so the original string is "\"Hello\nWorld\"

4:13 ,(println "\"Hello\nWorld\")

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

4:13 danielcompton: ,(println "\"Hello\nWorld\"")

4:13 clojurebot: "Hello\nWorld"\n

4:24 sveri: reiddraper: pint

4:24 *ping

4:59 ptcek: Datomic users here? How to upsert entity when having :db/id stored in var? I am getting symbol cannot be cast to number error... https://www.refheap.com/86602

6:08 toxmeister: with fressian, how important is it to use write-footer? can't seem to find any docs and it seems to work without… do I only need to use it when writing more than a single object?

7:45 kzar: $findfn {:a {:b 2} :c 3} :a :b {:c 3}

7:45 lazybot: [clojure.core/dissoc]

7:45 kzar: $findfn {:a {:b 2} :c 3} :a :b {:a {} :c 3}

7:46 lazybot: []

7:46 kzar: $findfn {:a {:b 2 :g 4} :c 3} [:a :b] {:a {:g 4} :c 3}

7:46 lazybot: []

7:47 kzar: $findfn {:a {:b 2 :g 4} :c 3} :a :b {:a {:g 4} :c 3}

7:47 lazybot: []

7:49 kzar: ,(update-in {:a {:b 2 :z 4} :c 3} [:a] dissoc :b)

7:50 clojurebot: {:c 3, :a {:z 4}}

7:52 kzar: ,(defn dissoc-in [m keys]

7:52 (update-in m (butlast keys) dissoc (last keys)))

7:52 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

7:52 kzar: ,(defn dissoc-in [m keys] (update-in m (butlast keys) dissoc (last keys)))

7:52 clojurebot: #'sandbox/dissoc-in

7:52 kzar: ,(dissoc-in {:a {:b 2 :z 4} :c 3} [:a :b])

7:52 clojurebot: {:c 3, :a {:z 4}}

7:53 lvh: Is it okay for the result-expr of a case to have side effects?

7:53 are they only eval'd for the particular case?

8:42 Jarda: hm

8:58 visof: is there a fast and good way to make values of hash as a keys? as example {1 2 3 4} tobe {2 1 4 3} ?

9:06 sandbags: ,(into {} (map (fn [[k v]] [v k]) {:a 1 :b 2 :c 3})

9:06 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

9:06 sandbags: ,(into {} (map (fn [[k v]] [v k]) {:a 1 :b 2 :c 3})))

9:06 clojurebot: {3 :c, 2 :b, 1 :a}

9:06 sandbags: visof: ^

9:06 visof: sandbags: well done

9:07 sandbags: i suspect there's an even easier way, there usually is :)

9:48 gfredericks: with prismatic/plumbing it'd be (for-map [[k v] m] v k)

9:51 mi6x3m: anyway of determining if a text is a valid html?

9:53 sveri: mi6x3m: there are some java libraries for this which I would use

9:55 mi6x3m: sveri: yeah, I know, was wondering if there is something more clojure-ish

9:57 sveri: mi6x3m: not that I know of, but that doesnt mean anything. Maybe enlive provides something?

9:57 mi6x3m: checking it out just now :)

10:01 deathknight: what is the name of -> so that I may look up what it does?

10:05 ambrosebs: deathknight: http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/

10:06 or thread-first

10:06 deathknight: you rock

10:06 thats the author o JOC, right?

10:06 ambrosebs: yes

10:06 deathknight: :D

10:07 Today is the day I replace who sits on the throne - err, communicate with google calendar's API

10:16 umpa: (require 'clojure.set)

10:16 ,(require 'clojure.set)

10:16 clojurebot: nil

10:16 umpa: ,(set/difference #{1 4} #{1 4 7})

10:16 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>

10:16 umpa: ,(clojure.set/difference #{1 4} #{1 4 7})

10:16 clojurebot: #{}

10:17 umpa: ,(clojure.set/difference #{1 4 7} #{1 4})

10:17 clojurebot: #{7}

10:17 michaniskin: ,(clojure.set/difference #{1 4 7} #{1} #{4})

10:17 clojurebot: #{7}

10:18 umpa: How do I get the difference no matter the order ?

10:19 engblom: Is there a ready function in core that would be similar to map, but only changing the first element matching a condition. For example if you want to decrese the first non-zero element in a collection.

10:20 ambrosebs: ,(require '[clojure.set :as set])

10:20 clojurebot: nil

10:21 ambrosebs: ,(let [ss [#{1 4 7} #{1} #{4}]] (set/difference (apply set/union ss) (apply set/intersection ss)))

10:21 clojurebot: #{7 1 4}

10:21 ambrosebs: some combination of set operations..

10:21 michaniskin: heh

10:22 perhaps you want the complement of the intersection?

10:22 i guess thats what ambrosebs just did

10:23 ambrosebs: probably the union of all the combinations of calling difference.

10:24 ,(require 'clojure.math.combinatorics)

10:24 clojurebot: #<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/math/combinatorics__init.class or clojure/math/combinatorics.clj on classpath: >

10:24 michaniskin: i mean order is kind of important for difference, like minus: (- 1 3) is not the same as (- 3 1)

10:26 engblom: ,(Math/abs (- 3 1))

10:26 clojurebot: 2

10:26 engblom: ,(Math/abs (- 1 3))

10:26 clojurebot: 2

10:26 engblom: michaniskin: ^

10:27 ambrosebs: (apply union (map (fn [[s1 s2]] (union (difference s1 s2) (difference s2 s1)) (comb/combinations ss 2))

10:27 michaniskin: engblom: i don't understand?

10:27 ambrosebs: something like that?

10:27 engblom: <michaniskin> i mean order is kind of important for difference, like minus: (-

10:27 1 3) is not the same as (- 3 1)

10:29 michaniskin: engblom: sure, or (Math/min -10000 (- 3 1))

10:29 ambrosebs: funny enough, I just needed this kind of set operation. Useful if you already know the differences in advance.

10:29 michaniskin: lots of things you can do to wrap minus in something lol

10:31 john2x: does `& rest` arguments work with multi-arity functions?

10:31 umpa: ambrosebs: the first one works

10:31 ambrosebs: umpa: oh. Yes you're right :P

10:32 michaniskin: `(defn ff ([x] :one-arg) ([x & more] :more-args))

10:32 ,(defn ff ([x] :one-arg) ([x & more] :more-args))

10:32 clojurebot: #'sandbox/ff

10:32 michaniskin: ,(ff :x)

10:32 clojurebot: :one-arg

10:32 michaniskin: ,(ff :x :y)

10:32 clojurebot: :more-args

10:33 michaniskin: john2x: is that what you mean?

10:33 john2x: michaniskin: oh, I mean both definitions having `& more`..

10:35 michaniskin: john2x: that would be kind of crazy, no?

10:35 also

10:35 john2x: yeah..

10:36 michaniskin: ,(defn ff ([x] :one-arg) ([[x & rest] & {:keys [opt] :as options}] :bad))

10:36 clojurebot: #'sandbox/ff

10:36 michaniskin: ,(ff [:a])

10:36 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ff in this context, compiling:(NO_SOURCE_PATH:0:0)>

10:38 engblom: Assuming I have [0 0 3 2 2] and I want to decrease the first non-zero element to get [0 0 2 2 2], is there any ready function I can pass #(not (zero? %)) and dec and the vector to and it will take care of it?

10:49 gfredericks: engblom: no, that sounds pretty specific to me

10:50 ,(defn decfirst ([v] (decfirst v 0)) ([v i] (if (pos? (v i)) (assoc v i (dec (v i))) (recur v (inc i)))))

10:50 clojurebot: #'sandbox/decfirst

10:50 gfredericks: ,(decfirst [0 0 3 2 2])

10:50 clojurebot: [0 0 2 2 2]

10:57 sandbags: maybe using partition-by and zero?

10:58 michaniskin: ,(defn replacefirst [pred f coll] (let [head (take-while (complement pred) coll), [item & tail] (drop-while pred coll)] (into (empty coll) (concat head (cons (f item) tail)))))

10:58 clojurebot: #'sandbox/replacefirst

10:58 michaniskin: ,(replacefirst (complement zero?) dec [0 0 3 2 2])

10:58 clojurebot: [0 0 -1 0 3 ...]

10:58 michaniskin: whoa nevermind

10:58 lol

11:00 ,(replacefirst zero? dec [0 0 3 2 2])

11:00 clojurebot: [2 2 2]

11:00 michaniskin: ,(replacefirst pos? dec [0 0 3 2 2])

11:00 clojurebot: [0 0 -1 0 3 ...]

11:00 johnwalker: whats the idea? update the first element in a collection that matches pred?

11:01 michaniskin: indeed

11:02 ,(defn replacefirst [pred f coll] (let [head (take-while (complement pred) coll), [item & tail] (drop-while (complement pred) coll)] (into (empty coll) (concat head (cons (f item) tail)))))

11:02 clojurebot: #'sandbox/replacefirst

11:03 michaniskin: ,(replacefirst (complement zero?) dec [0 0 3 2 2])

11:03 clojurebot: [0 0 2 2 2]

11:03 michaniskin: whew

11:05 ,(replacefirst #(pos? (val %)) dec (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:05 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap$BlackVal cannot be cast to java.lang.Number>

11:06 michaniskin: ,(replacefirst #(pos? (val %)) (juxt identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:06 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap$BlackVal cannot be cast to java.lang.Number>

11:12 johnwalker: (defn update-first [pred f coll] (let [[x [t & r]] (split-with (complement pred) coll)] (concat x [(f t)] r)))

11:12 mi6x3m: hey, can anyone tell if this looks like something a sane clojure programmer would produce? http://pastebin.com/KdqeTb7p

11:12 Trying to get a feeling for these things :)

11:13 johnwalker: yeah looks good

11:14 mi6x3m: johnwalker: thanks

11:14 michaniskin: ah split-with, that's right

11:15 it would be useful to have the FL "construct" function in clojure: (construct [inc dec] [10 10]) => [11 9]

11:15 * nDuff scowls at the pastebin.com link (it's full of ads!)

11:15 johnwalker: whats FL?

11:16 i see what construct does, but haven't heard of FL

11:17 michaniskin: johnwalker: http://www.thocp.net/biographies/papers/backus_turingaward_lecture.pdf

11:17 FL is pretty mindblowing

11:18 basically in FL the expression [inc dec] is like in clojure (partial construct [inc dec])

11:18 square brackets indicate construction

11:19 ohpauleez: michaniskin: Have you played with J?

11:19 michaniskin: ohpauleez: hey dude! no, is it good?

11:19 ohpauleez: Dude, you need to

11:19 basically all the good ideas from FP and FL

11:20 plus some extra solid stuff

11:20 Hmm, a quick Google search shows me this: http://www.infoq.com/presentations/j-language

11:21 And, like other programming languages, good history on wikipedia: http://en.wikipedia.org/wiki/J_%28programming_language%29

11:21 michaniskin: i was really into FL at one point, and i was a little obsessed with forth, but i find that applications need to be expressed as trees

11:22 it's not really easy to do that in FL or stack based languages

11:22 johnwalker: (map #(% %2) [inc dec] [10 11])

11:22 ,(map #(% %2) [inc dec] [10 11])

11:22 clojurebot: (11 10)

11:22 kzar: Is there a way to set jruby as a dependency in my project.clj? (Not sure how to add non-clojars dependencies.)

11:22 hyPiRion: ,(map deliver [inc dec] [10 11])

11:22 clojurebot: (11 10)

11:23 johnwalker: ahh, nice

11:23 ,(doc deliver)

11:23 clojurebot: "([promise val]); Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a promise will have no effect."

11:23 hyPiRion: except never use deliver like that

11:23 michaniskin: whoa!

11:23 (inc hyPiRion)

11:23 lazybot: ⇒ 37

11:23 hyPiRion: &(source deliver)

11:23 lazybot: java.lang.RuntimeException: Unable to resolve symbol: source in this context

11:23 hyPiRion: ,(source deliver)

11:23 clojurebot: Source not found\n

11:23 hyPiRion: $source deliver

11:23 lazybot: deliver is http://is.gd/U3dg84

11:24 michaniskin: ohpauleez: do you program in J?

11:24 catern: michaniskin: (def construct (partial map apply)) ?

11:24 ohpauleez: kzar: You can add any clojars or maven central dep. You can also specify other maven repositories with :repositories

11:25 michaniskin: Nope, just briefly studied some time ago (I was digging through FL and FP, and stumbled upon it when I asked, "Has anyone taken these in a new direction?"

11:25 hyPiRion: How the hell did you discover that abuse?

11:26 kzar: ohpauleez: Oh cool [org.jruby/jruby "1.7.12"] did it, thanks

11:26 ohpauleez: kzar: No problem, happy to help!

11:26 hyPiRion: ohpauleez: you don't want to know

11:26 michaniskin: ,(def construct (partial map deliver))

11:26 clojurebot: #'sandbox/construct

11:26 michaniskin: ,(construct [inc dec] [10 10])

11:26 clojurebot: (11 9)

11:27 michaniskin: ,(replacefirst #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:27 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: replacefirst in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:28 michaniskin: ,(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:28 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: update-first in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:32 umpa: (update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:32 (update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:33 sorry about that

11:33 michaniskin: it won't work because construct should really return a vector, not a seq

11:33 ,(def construct (comp ver (partial map deliver)))

11:33 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ver in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:33 michaniskin: ,(def construct (comp vec (partial map deliver)))

11:33 clojurebot: #'sandbox/construct

11:34 umpa: ,(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))

11:34 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: update-first in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:35 umpa: $source identity

11:35 lazybot: identity is http://is.gd/iexysV

11:38 johnwalker: \join #org-mode

11:39 woops

12:16 johnny_: hello!

12:16 anyone around?

12:17 engblom: johnwalker: In your solution for update-first, how is that let working as t and r are not yet set at that moment? (defn update-first [pred f coll] (let [[x [t & r]] (split-with (complement pred) coll)] (concat x [(f t)] r)))

12:17 johnny_: Yep

12:18 johnny_: yay! I'm a clojure newbie; I've done a fair bit if LISPing before... is this the place for me?

12:18 engblom: johnny_: Yes, this is the place

12:18 johnwalker: engblom: it's wacky destructuring

12:18 johnny_: engblom: grand!

12:19 johnwalker: engblom: x t and r are the left values for split-with

12:19 * johnny_ will probably stop back in later but has to go now :'(

12:20 engblom: johnwalker: So even the binding in the let is not happening until you have some values?

12:22 johnwalker: i'm not sure if i understand the question, but this should help:

12:22 http://blog.jayfields.com/2010/07/clojure-destructuring.html

12:24 engblom: johnwalker: This is the first destructuring I simply have really difficulties to grasp. I will look at that page to see if I get the point.

12:25 johnwalker: the idea is that x gets the first list

12:25 and then [t & r] get the second

12:26 t is the first element of the second list

12:26 and r is the rest of the second list

12:26 engblom: I always assumed the [] in let was evaluated before the body of let. Not having f & t when let begins causes my trouble to understand

12:26 johnwalker: split-with isn't being evaluated in the body

12:27 it's the right value for [x [t & r]]

12:27 engblom: Ah! Now I see

12:27 Thanks, that was what I failed to notice

12:27 johnwalker: cool. yeah, it's hard to parse on one line

12:28 visof: Hi

12:31 if i can a string like "Hello_$002C_$0021", and i want to replace all unicode chars like $002C which is "," and $0021 "!" that's easy to do with 2 replace statements one inside another, but how can i do this for undetermined n of unicodes ?

12:32 ,(clojure.string/replace #"$0021" (clojure.string/replace #"002C" "Hello_$002C_$0021" ",") "!")

12:32 clojurebot: "$0021"

12:32 visof: ,(clojure.string/replace #"$0021" (clojure.string/replace #"$002C" "Hello_$002C_$0021" ",") "!")

12:32 clojurebot: "$0021"

12:32 visof: ,(clojure.string/replace #"$002C" "Hello_$002C_$0021" ",")

12:32 clojurebot: "$002C"

12:33 visof: ,(clojure.string/replace (clojure.string/replace "Hello_$002C_$0021" #"$002C" ",") #"$0021" "!")

12:33 clojurebot: "Hello_$002C_$0021"

12:33 visof: ,(clojure.string/replace (clojure.string/replace "Hello_$002C_$0021" #"\$002C" ",") #"\$0021" "!")

12:33 clojurebot: "Hello_,_!"

12:35 johnwalker: you can do it with reduce, but it won't be very efficient

12:37 visof: johnwalker: https://www.refheap.com/86611 to replace all codes by symbols, i created two lists as you can see

12:38 johnwalker: maybe define empty atom and change it when replace string

12:38 johnwalker: no thats not a good idea

12:38 visof: johnwalker: why?

12:39 johnwalker: how is using an atom in this manner different from regular mutation?

12:40 or a global variable in general?

12:40 visof: so you think reduce is better?

12:40 johnwalker: a lot better

12:40 but still not ideal

12:41 one thing you might try is

12:41 actually nevermind, that's not a good solution either

12:42 you can do this and it's basically ok for small strings

12:42 http://stackoverflow.com/questions/9568050/in-clojure-how-to-write-a-function-that-applies-several-string-replacements

12:46 a better way would be to compile an fsm to handle multiple replacements

12:47 java probably has a standard solution, but i'd also be interested in seeing a clojure implementation

12:51 umpa: How do i group list elements ((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)) given intersect dependency (0 2 6 8) to arrive at ( 0 ((0 1 2) (0 3 6) (0 4 8)) 2 ((0 1 2)(2 5 8) etc..))

12:51 justin_smith: (apply str (replace {"$002C", \,, "$0021", \!} "Hello_$002C_$0021")) ;; visof: depending on how many replacements, this may make sense

12:52 ,(apply str (replace {"$002C", \,, "$0021", \!} "Hello_$002C_$0021")) ;; visof

12:52 clojurebot: "Hello_$002C_$0021"

12:52 justin_smith: err...

12:52 oh, if the things to replace were chars and not strs it would work

12:53 ,(apply str (replace {\☃, \,, \✈, \!} "Hello_☃_✈"))

12:53 clojurebot: "Hello_,_!"

12:55 hyPiRion: you guys

12:55 ,(clojure.string/replace "Hello_$002C_$0021" #"\$(\p{XDigit}{4})" (fn [b] (-> b second (Integer/parseInt 16) char str)))

12:55 clojurebot: "Hello_,_!"

12:56 hyPiRion: replace can take a function as last argument

12:57 justin_smith: hyPiRion: cool, I think I misunderstood the task here - and I think you can eliminate the str from that last function

12:57 nope, str is needed

12:59 johnwalker: thats badass

12:59 hyPiRion: visof: ^ does that solve your problem?

13:00 bbloom: (doc clojure.string/replace)

13:00 clojurebot: "([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first. The replacement is literal (i.e. none of its characters are treated specially) for all cases above except pattern / string. For pattern / string, $1, $2, etc. in the replacement string are substituted with the string that

13:02 alandipert: hyPiRion, mindblown.gif

13:02 bbloom: ,(clojure.string/replace "Hello_X_X" "X" (fn [_] "Y"))

13:02 clojurebot: #<ClassCastException java.lang.ClassCastException: sandbox$eval25$fn__26 cannot be cast to java.lang.CharSequence>

13:02 bbloom: hyPiRion: seems like an implementation detail ^^

13:03 ,(-> #'clojure.string/replace-by meta :private)

13:03 clojurebot: true

13:03 bbloom: i wouldn't rely on that...

13:05 hyPiRion: bbloom: oh what. I honestly thought it was documented that you can pass functions as replacement values for regexes.

13:06 johnwalker: hold on now

13:07 ,(clojure.string/replace "Hello_X_X" #"X" (fn [_] "Y"))

13:07 clojurebot: "Hello_Y_Y"

13:07 bbloom: johnwalker: yeah, it only works if the match argument is a regex

13:07 hyPiRion: johnwalker: It doesn't make sense for a string anyway. You will always get the string as argument.

13:08 Well, unless you use mutation under covers.

13:08 johnwalker: oh, you're saying that this works too

13:08 bbloom: hyPiRion: if you want to rely on that, i'd submit a patch with a new doc string ;-)

13:08 johnwalker: ,(clojure.string/replace "Hello_X_X" "X" "Y")

13:08 clojurebot: "Hello_Y_Y"

13:08 bbloom: johnwalker: right

13:09 johnwalker: still, that's inconsistent

13:09 hyPiRion: bbloom: Well, *I* rely on that at least (for regexes). I was just surprised that it wasn't documented.

13:09 I have used clojure.string/replace wrong all this time.

13:09 "wrong"

13:11 bbloom: hyPiRion: like i said, a doc string change would probably fix that right up :-)

13:11 johnwalker: shouldn't it also be extended to accept functions as the second argument for strings?

13:12 it might not be useful but it's certainly more regular

13:13 hyPiRion: bbloom: Sure, I'd be happy if someone were to file a patch for that. Seems super useful to let other people know about it

13:21 umpa: How do I group-by (0 7) coll ((0 2)(1 3)(0 5)(1 7)) ?

13:23 justin_smith: umpa: what does (group-by (0 7) mean? group by the presence of 0 vs. 7?

13:24 umpa: justin_smith: in a map form maybe {0 ((0 2)(05)) 7 ((1 7))}

13:25 justin_smith: ,(group-by #(#{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7)))

13:25 clojurebot: {nil [(0 2) (1 3) (0 5) (1 7)]}

13:25 justin_smith: err

13:26 ,(group-by #(clojure.set/intersection #{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7))) closer

13:26 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>

13:26 justin_smith: ,(require 'clojure.set)

13:26 clojurebot: nil

13:26 justin_smith: ,(group-by #(clojure.set/intersection #{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7))) closer

13:26 clojurebot: {#{0} [(0 2) (0 5)], #{} [(1 3)], #{7} [(1 7)]}

13:27 umpa: justin_smith: neat

13:29 ,(group-by #(clojure.set/intersection #{0 2 6 8} (into #{} %)) (((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6))))

13:29 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

13:30 umpa: ,(group-by #(clojure.set/intersection #{0 2 6 8} (into #{} %)) '(((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6))))

13:30 clojurebot: {#{} [((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...)]}

13:31 justin_smith: umpa: that happened because you changed the list of lists to a list of list of lists

13:31 umpa: ,(group-by #(clojure.set/intersection #{0 2 6 8} (into #{} %)) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

13:31 clojurebot: {#{0 2} [(0 1 2)], #{} [(3 4 5) (1 4 7)], #{6 8} [(6 7 8)], #{0 6} [(0 3 6)], #{2 8} [(2 5 8)], ...}

13:32 justin_smith: maybe you want something that takes the intersection, and decides what the "most relevant" key out of that is, and returns that alone

13:33 and you would wrap the intersection call in that extractor / orderer

13:34 something like #(or (% 6) (% 8) (% 2) (% 0))

13:35 ,(group-by #( (fn [s] (or (s 6) (s 8) (s 2) (s 0))) (clojure.set/intersection #{0 2 6 8} (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

13:35 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>

13:36 justin_smith: ,(require 'clojure.set)

13:36 clojurebot: nil

13:36 justin_smith: ,(group-by #( (fn [s] (or (s 6) (s 8) (s 2) (s 0))) (clojure.set/intersection #{0 2 6 8} (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

13:36 clojurebot: {2 [(0 1 2)], nil [(3 4 5) (1 4 7)], 6 [(6 7 8) (0 3 6) (2 4 6)], 8 [(2 5 8) (0 4 8)]}

13:38 umpa: justin_smith: nice

13:40 justin_smith: that fn could be (fn [s] (first (keep s [6 8 2 0]))) actually

13:44 umpa: ,(group-by #((fn [s] (first (keep s [6 8 2 0]))) (clojure.set/intersection '(0 2 6 8) (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6))) like that ?

13:44 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.PersistentList>

13:45 umpa: (doc keep)

13:45 clojurebot: "([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."

13:46 justin_smith: umpa: the reason I was using sets was to be able to do the intersection / contains? stuff, which does not work on seqs

13:46 well, get rather than contains? but you know

13:47 you replaced a # with a ' to get a seq rather than a set, which made that code fail

13:49 umpa: justin_smith: you are abs right

13:50 getting tangled

13:50 (umpa untangle)

13:51 ,(umpa untangle)

13:51 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: umpa in this context, compiling:(NO_SOURCE_PATH:0:0)>

13:51 justin_smith: right, it's a one liner for clojure bot demo sake, but better to actually make it readable

13:53 umpa: justin_smith: whats (first (keep s []

13:53 justin_smith: ,(keep #{0 1 2} (range 10))

13:53 clojurebot: (0 1 2)

13:53 justin_smith: bad example

13:53 ,(keep #{10 1 42} (range 100))

13:53 clojurebot: (1 10 42)

13:54 justin_smith: ,(first (keep #{10 1 42} (range 100)))

13:54 clojurebot: 1

13:54 justin_smith: just gives you the first member of the set, found in the collection

13:54 ,(first (keep #{10 1 42} (reverse (range 100))))

13:54 clojurebot: 42

13:56 justin_smith: so the ordering of the collection, decides which of its members will be returned if the set contains multiple of its members

13:56 (misplaced ,)

14:01 mi6x3m: hey clojure, is it idiomatic to use clojure.repl/source in other scenarios than the REPL

14:01 justin_smith: what's the context?

14:01 if you are recompiling something from a new ns based on the output of clojure.repl/source, that is just wrong

14:03 mi6x3m: justin_smith: I am translating a program showing java examples to a library

14:03 and I shows controls + a "source" tabg

14:03 clicking on the source tab fetches the .java file's contents

14:03 justin_smith: ahh, that should be OK :)

14:08 umpa: ,(group-by #((fn [s] (first (keep s [6 8 2 0]))) (clojure.set/intersection #{0 2 6 8} (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6))) some matches are missing

14:08 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>

14:09 umpa: ,(group-by #((fn [s] (first (keep s [6 8 2 0]))) (clojure.set/intersection #{0 2 6 8} (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

14:09 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>

14:09 justin_smith: you need to require clojure.set

14:09 ,(require 'clojure.set)

14:09 clojurebot: nil

14:09 umpa: ,(group-by #((fn [s] (first (keep s [6 8 2 0]))) (clojure.set/intersection #{0 2 6 8} (into #{} %))) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

14:09 clojurebot: {2 [(0 1 2)], nil [(3 4 5) (1 4 7)], 6 [(6 7 8) (0 3 6) (2 4 6)], 8 [(2 5 8) (0 4 8)]}

14:09 mi6x3m: justin_smith: thanks but when is the source available, to begin with?

14:10 is it always included with the build artifacts?

14:10 justin_smith: the nil key shows you which items did not contain any of the keys you were looking for

14:10 mi6x3m: most clojure code is distributed as source, or at least includes source alongside the compiled classes

14:11 umpa: the 2 should be {2 [(0 1 2)(2 5 8)(2 4 6] ...

14:11 justin_smith: umpa: than change [6 8 2 0] to [2 6 8 0]

14:11 or do you want every permutation present?

14:12 umpa: ^

14:17 justin_smith: ,((fn [ks ls] (let [lsets (map set ls)] (reduce (fn [m v] (assoc m v (filter #(contains? (set %) v) ls))) {} ks))) [0 2 6 8] '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

14:17 clojurebot: {8 ((6 7 8) (2 5 8) (0 4 8)), 6 ((6 7 8) (0 3 6) (2 4 6)), 2 ((0 1 2) (2 5 8) (2 4 6)), 0 ((0 1 2) (0 3 6) (0 4 8))}

14:18 justin_smith: hmm, but no more nil key this way

14:18 oh and I bound lsets and never used it anyway :)

14:22 umpa: (,)(,)

14:46 benkay: does anyone know how to add metadata to clojure.test tests in such a way that midje will pick up on that metadata? i've tried wrapping the whole deftest in a (with-meta... :kw), wrapping just the (is...), wrapping the (test...), and i'm fully stumped.

14:49 gfredericks: benkay: you've tried (deftest ^{:kw ...} test-name ...)?

14:49 justin_smith: (deftest foo ...) (def (new meta) foo foo) maybe? deftest creates a var, that is effectively a defn with args of []

14:49 gfredericks: ,(require '[clojure.test :as t])

14:49 clojurebot: nil

14:50 gfredericks: ,(deftest ^:foo bar (is true))

14:50 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: deftest in this context, compiling:(NO_SOURCE_PATH:0:0)>

14:50 gfredericks: ,(t/deftest ^:foo bar (t/is true))

14:50 clojurebot: #'sandbox/bar

14:50 gfredericks: ,(meta #'bar)

14:50 clojurebot: {:ns #<Namespace sandbox>, :name bar, :file "NO_SOURCE_PATH", :column 0, :line 0, ...}

14:50 gfredericks: ,(:foo (meta #'bar))

14:50 clojurebot: true

14:51 justin_smith: oh, well that's much easier isn't it

14:51 d'oh, I even do that already for test selectors

14:51 benkay: <gfredericks> benkay: you've tried (deftest ^{:kw ...} test-name ...)? // yup, i have a brick for a brain.

14:51 gfredericks: any well-behaved macro that def things will let you put metadata on the symbol

14:54 johnwalker: what are you using metadata here for?

14:55 benkay: johnwalker: epic refactor in proecss. using midje to only run one test at a time so i can focus on one problem at a time.

14:55 now, if only i knew enough to get clojure-test-mode to only evaluate the test with metadata...

14:55 test(s)

14:57 gfredericks: dangit people stop putting arglists on the same line as the function name

14:57 technomancy: gfredericks: no.

14:57 gfredericks: technomancy: it leads to accidental docstring misplacement

14:57 and it's not compatible with docstrings at all

14:57 johnwalker: it looks nice

14:57 technomancy: gfredericks: sure; I don't do that on nontrivial functions

14:58 gfredericks: technomancy: I'll allow it only if the whole function is one line

14:58 technomancy: that does bug me though... you have to choose between having documentation and looking tidy.

14:58 gfredericks: nothing untidy about args having their own line

14:58 my opinions are more valid than yours

14:58 technomancy: it counts against your LOC

14:58 gfredericks: why on earth would you LOC

14:59 johnwalker: why isn't it defn foo [] "docstring" like in elisp?

14:59 technomancy: gfredericks: for Internet Points

14:59 gfredericks: technomancy: we should count tokens

14:59 dbasch: johnwalker: I don’t know, but having defn foo “several lines of docstring

14:59 “ and then [args] can be hard to read

14:59 technomancy: gfredericks: I need to keep Leiningen under an order of magnitude less than sbt

14:59 it's important!

14:59 gfredericks: I guess this is more of a linter issue eh?

14:59 johnwalker: dbasch: agreed

15:00 technomancy: gfredericks: clojure-mode will highlight docstrings same as comments

15:00 so if you see a string that highlights as a string, it's not a docstring

15:00 gfredericks: technomancy: that does not happen for me

15:00 dbasch: for that matter, (> x y) is always harder for me to read that (x > y)

15:01 gfredericks: do I need to go force-delete my clojure-mode from my ~/.emacs/elpa and cross my fingers and hope I won't get a Bad Gateway from the emacs repo again?

15:01 technomancy: gfredericks: huh... it used to

15:01 dbasch: *than

15:01 technomancy: dbasch: > is pronounced "descending"

15:01 gfredericks: and con> is of course "condescending"

15:01 technomancy: dbasch: the problem isn't prefix notation; the problem is calling it "greater than"

15:02 johnwalker: (inc gfredericks)

15:02 lazybot: ⇒ 68

15:02 gfredericks: I bet 75% of my karma comes from jokes

15:02 technomancy: clojurebot: 正名?

15:02 clojurebot: If language is not correct, then what is said is not what is meant; if what is said is not what is meant, then what must be done remains undone; if this remains undone, morals and art will deteriorate; if justice goes astray, the people will stand about in helpless confusion. Hence there must be no arbitrariness in what is said. This matters above everything.

15:02 technomancy: dbasch: ^

15:02 gfredericks: technomancy: that first character means Internet Explorer I posit

15:03 Frozenlock: johnwalker: I think it's because you can have functions with variable number of arguments

15:03 gfredericks: Frozenlock: good point

15:03 dbasch: so, is clojure correct or will we end up standing about in helpless confusion?

15:04 technomancy: ,(doc >)

15:04 clojurebot: "([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."

15:04 johnwalker: ehh

15:04 technomancy: unfortunately clojure doesn't ship with an IPA pronunciation guide =)

15:04 johnwalker: what do variable number args have to do with it?

15:04 Frozenlock: johnwalker: https://www.refheap.com/86637 Where would you put the docsctring otherwise?

15:04 johnwalker: oh, i see what you mean now

15:04 yeah thats a really good point

15:04 benkay: gfredericks: it appears that midje-mode wants nothing to do with selecting only clojure.test tests.

15:05 * gfredericks knows anything about midje-mode heck if

15:05 technomancy: ,(alter-var-root #'> assoc :pronunciation "dɪˈsɛndiŋɡ")

15:05 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.core$_GT_ cannot be cast to clojure.lang.Associative>

15:06 * benkay goes off into the weeds of test-ns-hook

15:06 technomancy: ,(alter-meta #'> assoc :pronunciation "dɪˈsɛndiŋɡ")

15:06 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: alter-meta in this context, compiling:(NO_SOURCE_PATH:0:0)>

15:06 technomancy: ,(alter-meta! #'> assoc :pronunciation "dɪˈsɛndiŋɡ")

15:06 clojurebot: {:added "1.0", :ns #<Namespace clojure.core>, :name >, :file "clojure/core.clj", :inline-arities #{2}, ...}

15:06 technomancy: third time's the charm

15:06 gfredericks: clojurebot: the third time?

15:07 clojurebot: Pardon?

15:07 gfredericks: clojurebot: the third time is the charm

15:07 clojurebot: Ok.

15:07 gfredericks: clojurebot: the charm?

15:07 clojurebot: No entiendo

15:08 justin_smith: clojurebot: the third time?

15:08 clojurebot: the third time is the charm

15:09 umpa: justin_smith: why does this not work ? (reduce (assoc {} ks (filter (contains? (set ls) ks) ls)) {} ks)

15:10 justin_smith: reduce takes a function as the first argument

15:10 benkay: "tests?Note: Fixtures and test-ns-hook are mutually incompatible. If you

15:10 are using test-ns-hook, fixture functions will *never* be run."

15:10 so...

15:11 now i guess i feel like an idiot for using clojure.test.

15:14 well fml.

15:14 i guess i need to refactor my test suite to use a different test runner to refactor my app.

15:15 Frozenlock: I've only ever used clojure.test. Is it worth taking the time to look at other tools?

15:16 benkay: well i can't specify a single test to run so i guess the answer is a resounding "yes"

15:16 gfredericks: what's up with test-ns-hook? midje uses it?

15:16 benkay: gotta wonder what's more insane: refactoring everything to use midje or writing some macros to get the fixtures that i already have to run around the tests.

15:16 test-ns-hook is a hook for specifying which tests to run. it ignores fixtures.

15:17 gfredericks: yes but why are you using it?

15:17 justin_smith: I think the problem is trying to use clojure.test and midge at the same time - they are different and incompatible test runners

15:17 benkay: so that i can focus on one failing test at a time, gfredericks.

15:17 Raynes: benkay: lein test :only your.test.ns/your-test

15:17 benkay: justin_smith: midje is capable of running clojure tests.

15:18 justin_smith: benkay: but as we've learned, the test runners are incompatible

15:18 gfredericks: benkay: does the tactic Raynes just mentioned not work?

15:19 Raynes: I sure hope it does.

15:19 I wrote it specifically to do this exact thing. :(

15:19 (run individual tests with fixtures)

15:19 justin_smith: benkay: also, as I mentioned above, a deftest form creates a var that is effectively a function of 0 arguments, you could simply write a function that calls that wrapped in your fixtures

15:20 benkay: gfredericks: i'm working on it. now i have to endure the jvm startup for each run of...one test.

15:20 gfredericks: doesn't clojure 1.6 have a function for this too?

15:20 Raynes and I tag-teamed on it

15:20 Raynes: gfredericks: Yes.

15:20 We wrote test-vars.

15:20 Also to do this exact thing.

15:21 We've got so many things to do this thing, man.

15:21 :P

15:21 gfredericks: hopefully clojure-test-mode does that, but who knows

15:22 benkay: justin_smith: that's probably what i'll end up doing.

15:23 although quite frankly i'm now contemplating refactoring everything into midje facts.

15:25 Frozenlock: Please tell me someone made a function to english-capitalize-title strings...

15:25 gfredericks: to do what?

15:26 Frozenlock: Capitalize words in a title. You know, only 'some' words.

15:26 gfredericks: like ignoring minor words?

15:27 Frozenlock: Yes.

15:27 gfredericks: I cannot tell you whether someone made such a function

15:27 justin_smith: ,(clojure.string/join " " (map clojure.string/capitalize (clojure.string/split "this is the title of my hit movie" #" ")))

15:27 clojurebot: "This Is The Title Of My Hit Movie"

15:27 gfredericks: ,(def title "this is the title of my hit movie")

15:27 justin_smith: plus a blacklist of articles and such I guess

15:27 clojurebot: #'sandbox/title

15:28 gfredericks: ,(def minor-words #{"is" "the" "of" "my"})

15:28 clojurebot: #'sandbox/minor-words

15:28 Frozenlock: http://english.stackexchange.com/a/34 :-(

15:28 I should just write everything in uppercase.

15:28 THIS WAY I CAN'T MAKE A MISTAKE.

15:29 kelseygi: it’d be a dang bazooka to hit a fly, but you could use https://github.com/eandrejko/clj-tokenizer

15:29 gfredericks: ,(defn titlecap [s] (->> (clojure.string/split s #" ") (map #(cond-> % (not (minor-words %)) (clojure.string/capitalize))) (clojure.string/join " ")))

15:29 clojurebot: #'sandbox/titlecap

15:29 gfredericks: (titlecap title)

15:29 ,(titlecap title)

15:29 clojurebot: "This is the Title of my Hit Movie"

15:29 justin_smith: IN A WORLD WHERE THE CLOJURE LIBRARIES LACK NATURAL LANGUAGE PROCESSING SUPPORT, FROZENLOCK MUST RESORT TO EXTREME MEASURES... TO WRITE HIS CODE

15:30 kelseygi: there’s also a section on stop words in this nlp-focused clojure tutorial http://writingcoding.blogspot.com/2008/06/clojure-series-table-of-contents.html

15:30 justin_smith: though you could likely fake it with gfredericks' approach (good luck detecting infinitives to get the "to"

15:30 rule right)

15:31 gfredericks: clojurebot: you |could likely fake it| with gfredericks' approach

15:31 clojurebot: Roger.

16:00 amalloy: gfredericks: is "my" a minor word for title casing? i would have guessed not

16:01 * gfredericks knows heck if

16:01 gfredericks: amalloy: I haven't been speaking english as long as you have

16:03 amalloy: really?

16:03 gfredericks: I'm the youngest person in this channel excepting Raynes

16:03 Raynes: Are you certain?

16:03 arrdem is pretty young.

16:03 gfredericks: I'm young so of course I'm certain

16:03 Bronsa: me too

16:03 I'm between arrdem and Raynes

16:03 amalloy: how do you even know how long i've been speaking english though? i could be a well-spoken russian import

16:04 arrdem: Raynes: older than you, whippersnapper

16:04 amalloy: Bronsa: we don't need to hear about your fantasies

16:04 gfredericks: I'm young so I make all sorts of assumptions about other people

16:04 arrdem: (inc amalloy)

16:04 lazybot: ⇒ 129

16:04 technomancy: OVARFLOW

16:04 Jarda: ,amalloy

16:04 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0:0)>

16:04 Jarda: :(

16:05 Raynes: It's not really executing that code :P

16:05 gfredericks: in complete overhonest frankness I am yes probably rather older than all of the college kids hanging around

16:05 Raynes: It's a well crafted illusion.

16:05 technomancy: I'll grant well-crafted when you can juxt it =)

16:05 justin_smith: $karma Jarda

16:05 lazybot: Jarda has karma 0.

16:06 justin_smith: ((juxt inc dec) technomancy) ; standard response to a laughably bad joke

16:06 Bronsa: amalloy: I don't even know how to reply to that

16:06 arrdem: (let [arrdem 21.3 Raynes 20 Bronsa (fresh)] (run (x) (< Bronsa arrdem) (> Bronsa Raynes)))

16:06 * arrdem fucked up the querry

16:07 arrdem: ,(/ 1.0 365)

16:07 clojurebot: eval service is offline

16:07 arrdem: clojurebot is a steaming pile of fail

16:08 Bronsa: the last thing it evaluates before breaking is "amalloy". sure this proves he's all evil.

16:08 arrdem: Bronsa: WE DO NOT SPEAK THE NAME

16:09 Raynes: On June 15, 2014, Alan Malloy made Bronsa speechless.

16:09 justin_smith: arrdem: cool trick is (/ 365.0) does the same thing

16:09 arrdem: justin_smith: yeah, I have mixed feelings about the implicit 1

16:09 justin_smith: multiple arity is so fun

16:10 arrdem: I mean what else would you want implicitly if / had one arg? taking an inverse is pretty basic

16:11 arrdem: justin_smith: I'd accept a type or arity error

16:11 ,(doc /)

16:11 clojurebot: eval service is offline

16:11 arrdem: ##(doc /)

16:11 lazybot: ⇒ "([x] [x y] [x y & more]); If no denominators are supplied, returns 1/numerator, else returns numerator divided by all of the denominators."

16:11 arrdem: at least it _is_ documented clearly.

16:12 justin_smith: arrdem: it's an old behavior, common among other lisps

16:12 arrdem: justin_smith: yay tradition

16:13 dbasch: amalloy: pronouns are typically capitalized in titles

16:14 * dbasch wonders if he’s the oldest person in this channel

16:15 justin_smith: hlship is not much older than me, but the oldest clojurian whose age I know (we actually met in person, or I wouldn't even know)

16:18 dbasch: justin_smith: I’m guessing Rich Hickey must be around 50

16:19 justin_smith: dbasch: well, I was talking about on this channel

16:21 dbasch: (> 30 (apply max (filter #(knows-irl dbasch %) clojure-irc)))

16:39 technomancy: anyone have last-minute issues to raise before lein 2.4.1 is released?

16:42 gtrak: technomancy: Tom Cruise was in an action movie at 51 years of age.

16:43 technomancy: is this a bug report or a feature request

16:44 Raynes: It's a glitch in the Matrix is what it is.

16:46 arrdem: gtrak: and Arnold is still doing them. next!

16:46 gtrak: we should probably clear some caches somewhere to prevent further damage

16:47 arrdem: he was _literally_ jumping around in robot suits killing things

16:47 arrdem: gtrak: that's Tony Stark's job

16:47 dbasch: technomancy: ship it!

16:48 technomancy: dbasch: hokay

16:48 gtrak: Robert Downey Jr is only 49

16:48 * arrdem checks the wind downrange

16:48 arrdem: technomancy: send it

16:49 clojure core's whitespace is a work of modern art...

16:52 technomancy: arrdem: http://nonadventures.com/2013/07/20/a-whiter-shade-of-fail/

16:52 arrdem: aka M-x whitespace-mode

16:52 arrdem: technomancy: hehe

16:54 technomancy: http://nonadventures.com/2013/08/17/wooly-bullied/ this is an awesome webcomic. thank you.

16:54 technomancy: arrdem: it is a gift

16:55 justin_smith: (inc palindromidary)

16:55 lazybot: ⇒ 1

16:55 justin_smith: (inc palindromedary)

16:55 lazybot: ⇒ 1

16:55 justin_smith: (it was spelled wrong the first time)

16:56 metellus: (dec palindromidary)

16:56 lazybot: ⇒ 0

16:58 technomancy: http://nonadventures.com/2014/05/17/gravys-anatomy/

16:59 umpa: ,(defn nice [m v] (assoc m v (filter #(contains? (set %) v) '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))))

16:59 clojurebot: #'sandbox/nice

16:59 umpa: ,(reduce (nice {} [8 2 6 0]) [8 2 6 0])

16:59 clojurebot: 0

16:59 umpa: justin_smith: why does this happen ? Its something with the map

17:00 justin_smith: does (nice ...) return a function?

17:00 you are still not using reduce properly

17:01 umpa: (nice {} [8 2 6 0])

17:01 ,(nice {} [8 2 6 0])

17:01 clojurebot: {[8 2 6 0] ()}

17:01 justin_smith: so you don't get an error, because {... ...} is callable as a function

17:02 it just probably won't return anything you find interesting

17:03 umpa: what kind of function does this return then ? (fn [m v] (assoc m v (filter #(contains? (set %) v) ls)))

17:03 justin_smith: that is a function

17:03 and it returns an updated map

17:04 that's why it is a valid first arg to reduce

17:05 ,(reduce (fn [m [k v]] (assoc m k v)) {} [[:a 0] [:b 1]]) ; not the best way to do this task, but it should help clarify what the first arg to reduce does

17:05 clojurebot: {:b 1, :a 0}

17:06 dbasch: umpa: may I ask what you’re trying to do?

17:07 justin_smith: he wants a map from elements to collections that contain those elements

17:08 umpa: ^

17:09 justin_smith: umpa: you took two inputs to reduce, and threw them into one defn body for some reason

17:10 if you took that literal list off the end of "nice", nice could be the first arg to reduce

17:10 and then the list would be the last arg, the one you are reducing over

17:11 umpa: dbasch: coll: ((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)) elements: [8 2 6 0] output form {0 ((0 1 2) (0 3 6) (0 4 8)), 2 ( ...

17:11 arrdem: so I'm looking at this: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L5351

17:12 this being with-loading-context: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L5295

17:12 is there a reason for the anonymous function call? seems to me like it's just there for no reason when a do would suffice.

17:15 justin_smith: ,(do (def coll '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6))) (defn nice [m v] (assoc m v (filter #(contains? (set %) v) coll))) (reduce nice {} [8 2 6 0])) umpa

17:15 clojurebot: {0 ((0 1 2) (0 3 6) (0 4 8)), 6 ((6 7 8) (0 3 6) (2 4 6)), 2 ((0 1 2) (2 5 8) (2 4 6)), 8 ((6 7 8) (2 5 8) (0 4 8))}

17:15 justin_smith: but really those things should all be in one function, and bound in a let

17:21 umpa: ,(def coll '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

17:21 clojurebot: #'sandbox/coll

17:22 umpa: (contains? (set coll) 0)

17:22 ,(contains? (set coll) 0)

17:22 clojurebot: false

17:22 justin_smith: ,(contains? (set coll) '(0 1 2))

17:22 clojurebot: true

17:23 umpa: ,(contains? (set coll) '(0))

17:23 clojurebot: false

17:23 dbasch: umpa: (set coll) is a set of triples, it’s not going to contain 0

17:23 or not even triples, a set of sequences

17:24 you have nested sequences in there, are you trying to see if 0 is in any of your nested sequences?

17:25 technomancy: TimMc: hey

17:25 TimMc: I think we have to revert the pom.properties change; it adds 300ms to lein startup time

17:26 umpa: dbasch: ,(filter #(contains? (set %) [0]) coll)

17:26 ,(filter #(contains? (set %) [0]) coll)

17:26 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: coll in this context, compiling:(NO_SOURCE_PATH:0:0)>

17:26 justin_smith: umpa: filter takes each element of the coll one by one

17:27 umpa: that's why that code works

17:27 dbasch: umpa: where are you trying to find 0? what would be your desired output?

17:27 justin_smith: except you want 0, not [0]

17:27 dbasch: see my paste above (do (def coll ...))

17:27 that does what he wants, he is just figuring out how it works

17:29 umpa: ^ debugging justin_smith's code

17:29 justin_smith: debugging? it has no bugs!

17:30 though it could be omptimized better

17:31 umpa: justin_smith: debugging understanding

17:32 dbasch: ((0 1 2)(0 4 7) ... etc

17:32 justin_smith: (def coll '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

17:32 ,(def coll '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

17:32 clojurebot: #'sandbox/coll

17:32 justin_smith: ,(reduce (fn [m el] (reduce (fn [m e] (update-in m [e] (fnil conj []) el)) m el)) {} coll)

17:32 clojurebot: {8 [(6 7 8) (2 5 8) (0 4 8)], 7 [(6 7 8) (1 4 7)], 6 [(6 7 8) (0 3 6) (2 4 6)], 5 [(3 4 5) (2 5 8)], 4 [(3 4 5) (1 4 7) (0 4 8) (2 4 6)], ...}

17:32 justin_smith: better version

17:33 though maybe not easier to read

17:33 oh wait, that gets all keys, not just the ones specified

17:35 ,(def wanted #{0 2 4 6 8})

17:35 clojurebot: #'sandbox/wanted

17:35 justin_smith: ,(reduce (fn [m el] (reduce (fn [m e] (if (contains? wanted e) (update-in m [e] (fnil conj []) el) m)) m el)) {} coll)

17:35 clojurebot: {8 [(6 7 8) (2 5 8) (0 4 8)], 6 [(6 7 8) (0 3 6) (2 4 6)], 4 [(3 4 5) (1 4 7) (0 4 8) (2 4 6)], 2 [(0 1 2) (2 5 8) (2 4 6)], 0 [(0 1 2) (0 3 6) (0 4 8)]}

17:38 umpa: justin_smith: nice

17:40 catern: so many numbers aieee

17:57 blaenk: I'm reading about clojure's STM and I'm kind of confused with the concept of deref prompting a transaction retry and the notion of a history of values somehow mitigating that

17:58 at first my understanding was that at the beginning of the transaction, a snapshot of all (?) refs' states was taken, the so called in-transaction values

17:58 but now the book I'm reading is saying that deref can cause a retry, because "if a new value is committed by another transaction since the beginning of the current transaction, the value of the ref as of the start of the transaction cannot be provided"

17:59 I'm not sure I understand why it's saying that that value cannot be provided, if my understanding was that the value of that ref was 'snapshotted' at the beginning of the transaction

18:00 what I'm confused about is mainly why it's saying that the value of the ref as of the start of the transaction cannot be provided

18:01 llasram: blaenk: If I read the implementation correctly, a ref will maintain a history of values, but not necessarily a complete history

18:01 justin_smith: blaenk: cannot be provided while also being correct

18:01 llasram: blaenk: So one condition which can cause a restart is a sufficiently-old ref value not being available

18:01 justin_smith: blaenk: that's how the whole thing can be non-locking, by retrying if something else finalizes in the meantime

18:02 llasram: sufficiently-old ref value?

18:02 blaenk: so for example, with alter, if the value it altered isn't the same at the beginning of the transaction as it is now at point of committing, then it retries, I understand that part, because then the work would have been done on an outdated value

18:03 so this is basically saying that the deref is another such check for the transaction being correct?

18:03 llasram: blaenk, justin_smith: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LockingTransaction.java#L397-L422

18:03 blaenk: Note that if you're just learning Clojure, you can probably ignore refs

18:03 The STM was a big exciting feature when Clojure was getting going, but I've never seen production code legitimately use refs

18:03 blaenk: thanks, but I'd prefer to learn them. I'm not too new to stm, I've done some of it in haskell

18:03 ah okay

18:04 it's mainly that I was following along up to this point

18:04 llasram: (Not that they don't work as advertised -- just I haven't seen any code which actually needed them)

18:04 justin_smith: llasram: oh, shows how little I know about STM, thanks

18:05 blaenk: my main confusion is the following: it makes it sound like, if the value being derefernced has changed mid-transaction, then clearly that won't be correct, because it'll be computing off of an outdated value, no? but then, how would maintaining a history of this value mitigate this? if, again, it would be being based off of an outdated value?

18:05 *changed mid-transaction by another transaction, then clearly that won't be correct, hence the retry

18:05 justin_smith: blaenk: I wonder if this may be related to functions like commute

18:05 llasram: Exactly

18:06 justin_smith: with commute, even if your order is off, your calculation can be correct, since the f is commutative

18:06 blaenk: right

18:06 llasram: Function which don't update or only commute don't need the most recent value, just consistent values from all refs read

18:07 blaenk: and that's the case where maintaining a history would help that situation

18:07 llasram: Exactly (is my understanding)

18:07 blaenk: that's what I was thinking, but why would a history need to be maintained, and not just the snapshot of the ref as it was at the beginning of the transaction, like it does with other things?

18:08 I mean, why isn't a history of size 1 enough

18:08 because it's talking about tuning the history size etc

18:08 llasram: Oh, because ref access is dynamic. When building the code for a transaction the compiler doesn't know ahead of time which refs are accessed

18:09 blaenk: ohhh it doesn't, ok

18:09 somehow I got the impression that it somehow knew which ones were accessed, and took a snapshot of them at the beginning of the transaction

18:09 "All reads of Refs will see a consistent snapshot of the 'Ref world' as of the starting point of the transaction (its 'read point'). The transaction will see any changes it has made. This is called the in-transaction-value."

18:09 llasram: The Clojure compiler is about as dumb as you can get, but intentionally so as a design commitment to radical simplicity

18:09 blaenk: http://clojure.org/refs

18:10 I understand

18:10 I'm just not sure what that quote means then

18:10 llasram: Yep. It's an illllusion. It uses tricks like maintaining history and restarting transactions to allow produce the effect described in that quote

18:10 blaenk: ohhh okay

18:12 since it just now introduced the concept of history of values, with deref in a transaction, I take it that modification operations aren't affected by this somehow?

18:12 in some other way then, they just know that the ref's state has changed, and retry the transaction?

18:12 or do they also run into the problem of not having enough history

18:13 llasram: blaenk: That I don't know off the top of my head. If you're really interested, I'd suggest digging into the implementation

18:13 blaenk: because the way I had previously (mistakenly) understood it was that they would take a snapshot of the state at the start of the transaction, and if that differed from its state at the point of committing, then it would retry

18:13 alright, thanks

18:13 llasram: The Compiler classes are unnecessarily hairy, but most of the core stuff like the STM is pretty approachable Java

18:13 One day we will be self-hosting...

18:13 (inc Bronsa)

18:13 lazybot: ⇒ 23

18:14 blaenk: that'd be cool

18:14 llasram: Yah. And Bronsa is working hard on the Clojure-in-Clojure implementation which will lead us to the promised land

18:14 No pressure

18:15 blaenk: haha

18:16 _JokerDoom: (inc Bronsa) -> 23?

18:17 llasram: karma mechanism

18:17 $karma lazybot

18:17 lazybot: lazybot has karma 26.

18:17 llasram: (inc lazybot)

18:17 lazybot: ⇒ 27

18:17 llasram: $karma lazybot

18:17 lazybot: lazybot has karma 27.

18:17 _JokerDoom: fun

18:17 $karma _JokerDoom

18:17 lazybot: _JokerDoom has karma 0.

18:17 _JokerDoom: lol

18:18 justin_smith: as is apropriate, the "inc" for karma has nothing to do with clojure's inc

18:18 (well, maybe half a thing to do with it)

18:18 llasram: I think of it as part of a macro-based DSL which just happens to use s-expressions

18:18 justin_smith: right

18:20 blaenk: llasram: would you happen to know which part of the code you linked has to do with alter?

18:21 llasram: blaenk: I'm afraid I do not off the top of my head. You can probably find it about as quickly as I can recall it :-)

18:21 blaenk: no worries, thanks

18:21 looks like it delegates to doSet

18:28 martinklepsch: I want to "merge" two maps like so: {:a 1 :b 2} {:a 15 :b 16} ;; => {:a {:file 1 :database 15} :b {:file 2 :database 16}}

18:31 Raynes: &(merge-with #(zipmap [:file :database] %&) {:a 1 :b 2} {:a 15 :b 16})

18:31 lazybot: ⇒ {:a {:database 15, :file 1}, :b {:database 16, :file 2}}

18:32 Raynes: martinklepsch: ^

18:33 blaenk: Raynes: what's that &() syntax?

18:33 is it specific to lazybot?

18:33 Raynes: That's not syntax.

18:33 blaenk: alright, what's that not-syntax

18:33 Raynes: The & is the evaluation prefix for lazybot

18:33 blaenk: ah thanks, figured

18:33 Raynes: It wouldn't know what to evaluate otherwise.

18:33 blaenk: got it

18:33 catern: why use lazybot over clojurebot?

18:33 Raynes: Because I wrote one of them and not the other.

18:34 catern: good reason

18:34 Raynes: Either one of them generally works fine.

18:34 blaenk: he wrote clojurebot, is ashamed

18:34 catern: haha

18:34 Raynes: lol

18:34 lazybot can ##(println "also evaluate stuff in the middle of messages, which clojurebot cannot do")

18:34 lazybot: ⇒ also evaluate stuff in the middle of messages, which clojurebot cannot do nil

18:35 Raynes: So if you want to do that, that's an excellent reason to use lazybot.

18:36 blaenk: nice

18:37 noonian: testing #10 lazybot

18:37 testing ##10 lazybot

18:37 Raynes: noonian: Only matches ()

18:37 You'd be incredibly likely to set it off accidentally otherwise.

18:37 Because ##channels are often prefixed with two hashes to indicate that the person who created them don't actually own the name of the channel.

18:38 noonian: hmm, i had no idea

18:38 justin_smith: also, there's ##:meta-hashtags

18:38 which are hashtags about hashtags

18:39 Raynes: ##hashtag

18:41 noonian: #poundsign

18:42 justin_smith: I like ##:octothorpe

18:43 mdeboard: This is kind of a terrible question, but I'd like to know if there's a more concise way of expressing this logic here https://github.com/mattdeboard/ticket-to-ride/blob/master/src/ttr/board.clj#L329 `@cards` derefs into a vector of keywords like `[:red :red :blue :yellow :white :blue]`

18:44 (I'm asking about line 329-355)

18:44 Raynes: https://github.com/mattdeboard/ticket-to-ride/blob/master/src/ttr/board.clj#L329-L355

18:45 mdeboard: thanks

18:45 Raynes: mdeboard: shift click a second line number to highlight a section

18:45 mdeboard: gotcha, thanks

18:46 I really don't like the `(apply count (rest %))` bit

18:46 ,(apply count (rest [:red [:red :red :red]]))

18:46 clojurebot: 3

18:46 mdeboard: idk if that's idiomatic-enough

18:47 justin_smith: (filterv (fn [[k v]] (and (>= (count v) cost) (#{(name k) :gray} color))) (group-by identity @cards))

18:47 maybe soemthing like that?

18:47 mdeboard: I find it p hard to remember what is happening there, it's pretty dense syntax. "Get the last element of this vector, then unpack that and count the elements in it"

18:47 justin_smith: it's more concise, and unless I made a thinko has the same semantics

18:47 mdeboard: justin_smith: well fortunately I have tests for this function, so I'll give it a whirl

18:47 Raynes: &(count (last [:red [:red :red :red]]))

18:47 lazybot: ⇒ 3

18:48 mdeboard: ,(rest [:a [:a :a :a]])

18:48 clojurebot: ([:a :a :a])

18:48 mdeboard: aha

18:48 Raynes: nice, that's good too

18:48 justin_smith: oh, not fn [k v], fn [k & v]

18:48 oh, never mind, k v was right

18:48 bleh

18:49 martinklepsch: Raynes, thanks that's working great and is nice and simple :)

18:49 justin_smith: I think bindings like k (for key) and v (for value) are more clear than first rest when mapping across a map

18:49 mdeboard: Raynes: thanks, that's working great and is nice and simple :(

18:49 :)*

18:49 Raynes: lol

18:50 mdeboard: justin_smith: Oh right, I didn't notice that destructuring in yours

18:50 I like that muhc better too

18:50 martinklepsch: Raynes, what does the %& do?

18:51 justin_smith: martinklepsch: it is like [arg & rest] in a normal fn

18:51 Raynes: martinklepsch: (fn [& args] (zipmap [:file :database] args))

18:51 martinklepsch: justin_smith, ah ok. thought so thanks!

18:51 have a good day/night! cheers!

18:51 * Raynes tips his hat

18:52 mdeboard: fedora*

18:52 Raynes: He only likes me for my merge-withs

18:53 mdeboard: btw if anyone here is going to Austin Clojure meetup tomorrow, I'm gonna head up there

18:53 (I'm on a trip here atm)

18:55 justin_smith: To use `fn [k v]` I'd have to call `apply` first

18:55 oh maybe it's `fn [[k v]]` ?

18:55 Raynes: mdeboard: I totally would have done (map (partial hash-map :name) ["Atlanta" "Boston" ...])

18:55 justin_smith: mdeboard: why apply? I did have it as fn [[k v]] right?

18:55 Raynes: Because it would have made me feel lazier.

18:55 mdeboard: justin_smith: Oh, if you did I misread, sorry

18:56 xeqi: devn: losingkeys = bendyworks person?

18:56 Raynes: Also holy God did you associate a ref with every one of these

18:56 mdeboard: plz no

18:56 mdeboard: every one of what

18:56 Raynes: edges

18:56 Every edge has a ref

18:56 mdeboard: ya

18:56 don't hurt my feelings

18:58 Raynes: mdeboard: In these kinds of situations, usually you want one ref/atom holding all state rather than one for every single piece of state.

18:58 It's generally better to have as little state as possible.

18:58 Also, you don't seem to be using the features of refs that warrant their usage.

18:58 atoms would suffice here as far as I can tell

18:59 mdeboard: Yeah, probably, not updating several in a single transaction

18:59 not now, anyway

18:59 Raynes: Unless you need to do coordinated updates of more than one ref inside of transactions, not very useful.

18:59 And if you only have one atom instead of a billion refs, it'll never be necessary! :p

19:00 mdeboard: but that's a little legacy of first iteration, I had state being managed all over the place. Once I corralled all the state manipulation into one place I found I didn't need refs after all... but i've got other stuff that I need to work on before I optimize

19:01 e.g. https://github.com/mattdeboard/ticket-to-ride/blob/master/src/ttr/cards.clj#L94-L125

19:02 so once I do make time for replacing with atoms, it'll be really easy since all the state manipulation is handled in very few places

19:03 Raynes: How about not using atoms *or* refs! :D

19:03 Just pass state from function to function.

19:03 Purely functional ticket to ride

19:03 You can write your own ticket, mdeboard.

19:04 mdeboard: because I'm just trying to get a full-featured simulation of the game running before I start making optimizations, otherwise I'll just tinker forever

19:04 and the thing that actually interests me about this is using neo4j, but I need a working game before I can start doing meaningful stuff there

19:05 na'mean

19:06 Raynes: I refuse to accept your excuses.

19:06 * Raynes storms of.

19:06 Raynes: off*

19:06 noonian: +1 million on the purely functional implementation

19:07 kelseygi: irc commands: not mutate-able!

19:08 * mdeboard mumbles something about peanut gallery

19:13 mdeboard: Raynes: pull requests gladly accepted btw

19:13 Raynes: I've never played ticket to ride nor do I have the foggiest clue how it is played.

19:14 mdeboard: Oh, well, you're missing out.

19:14 Raynes: I'm certain

19:18 justin_smith: mdeboard: what Raynes describes with passing state is a code stability / design optimization

19:18 in other words, its something that pays off most if you do it from the beginning

19:18 and the longer you wait to switch to the technique, the more you pay for it

19:19 (I have switched a mature codebase to arg passing - I was glad I did it, but it would have been much easier if I had done things that way in the first place)

19:19 mdeboard: I se

19:19 e

19:20 I've never actually done anything with games or anything, I just have always understood them to require a lot of state

19:20 I'm definitely forcing some OOP concepts into this design

19:20 but trying to keep it in check wihtout sacrificing gtd

19:20 justin_smith: mdeboard: passing an arg can provably do anything state can (plus things state can't do easily)

19:21 mdeboard: Can you give an example? I have trouble modeling this in my head

19:21 especially in a "loop" like a game

19:21 justin_smith: well, loop creates a binding, and recur passes a binding

19:22 so when you recur, you pass in the updated "state of the world", which is actually an immutible object

19:22 mdeboard: orite

19:22 I see, I see

19:22 justin_smith: all "modifications of state", are new versions of the state of the world (usually efficient, because we are using persistent data structures)

19:22 noonian: right, instead of modifying the contents of the deck you could write a function that takes a deck and returns a different deck

19:22 mdeboard: Yeah that was enough for a light bulb to come on

19:23 justin_smith: right

19:23 mdeboard: right

19:23 right

19:23 Anyway, I understand. I may revisit that once I figure out the thing I'm trying to solve now

19:23 justin_smith: advantages including the fact that you can save and restore and replay games trivially

19:24 since it is right there in one immutible thing already, why not fork it if you want to play things out multiple directions

19:24 playing the game in reverse, etc. etc.

19:25 things that are very hard in the mutable version become trivial in this one

19:26 mdeboard: justin_smith: Interesting

19:26 very interesting

19:26 That gets at an annoying issue I have had to deal with in tests :P

19:27 justin_smith: line 16, 28, 40

19:27 resetting state

19:27 It's one of those deals wher eyou know it's dumb

19:27 like as you're typing it

19:30 I think I've lessened the impact on refactoring to something less stateful by making sure state's not being mutated all over the place

19:30 justin_smith: also, add a constrained tree search on moves with simulated opponent moves, and you get an ai for playing the game

19:30 mdeboard: Yeah AI is the second thing I'm working on

19:31 justin_smith: yeah, another bonus of the "state" just being a function argument is that suddenly testing is much easier

19:31 right, and for the ai to branch, you either have to play crazy games with state (very brittle), or just have a proper state argument with no global binding

19:43 umpa: this filter (filter #(contains? (set %) [0 1) ((1 2 3)(4 5 6))) why you no work ?

19:44 llasram: umpa: Well, syntax errors at least

19:44 Raynes: Well, that's not valid Clojure for starters.

19:45 technomancy: (1 2 3) is not a function you can call

19:45 umpa: ,(filter #(contains? (set %) [0 1]) ((1 2 3)(4 5 6)))

19:45 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

19:45 justin_smith: also the nesting is off

19:46 umpa: ,(filter #(contains? (set %) [0 1]) '((1 2 3)(4 5 6)))

19:46 clojurebot: ()

19:46 justin_smith: and you probably want to test intersection rather than membership

19:46 llasram: umpa: What do you expect to happen here?

19:46 justin_smith: I think he wants to filter the lists that contain a 0 or 1

19:46 llasram: Ok...

19:47 umpa: ^

19:47 llasram: umpa: `contains?`'s second argument is a single value

19:47 So ##(contains? #{[0 1]} [0 1])

19:47 lazybot: ⇒ true

19:47 llasram: But not ##(contains? #{0 1} [0 1])

19:47 lazybot: ⇒ false

19:49 justin_smith: ,(do (require '[clojure.set :as s]) (filter #(s/intersection #{0 1} (set %)) '((1 2 3) (4 5 6) (0 1 2))))

19:49 clojurebot: ((1 2 3) (4 5 6) (0 1 2))

19:49 llasram: ,(filter (partial some #{0 1}) '((1 2 3) (4 5 6)))

19:49 justin_smith: err

19:49 clojurebot: ((1 2 3))

19:50 justin_smith: that's a good way to do it

19:51 umpa: justin_smith: why did the v in filter work ##((fn [ks ls](reduce (fn [m v] (assoc m v (filter #(contains? (set %) v) ls) )) {} ks))[8 2 6 0] '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

19:51 lazybot: ⇒ {0 ((0 1 2) (0 3 6) (0 4 8)), 6 ((6 7 8) (0 3 6) (2 4 6)), 2 ((0 1 2) (2 5 8) (2 4 6)), 8 ((6 7 8) (2 5 8) (0 4 8))}

19:51 justin_smith: oh yeah, empty sets are truthy

19:52 because that was reducing across individual elements

19:52 umpa: (doc truthy)

19:52 clojurebot: No entiendo

19:53 justin_smith: umpa: http://blog.jayfields.com/2011/02/clojure-truthy-and-falsey.html

19:54 mdeboard: ugh now all I see is how OO I made this

19:54 THANKS

19:54 I'm disgusted with myself

19:54 It's like the Garden of Eden

19:54 justin_smith: umpa: because of other lisps, I sometimes lapse and expect empty things to act as false. It's a bad habit

19:54 mdeboard: I realize I'm naked, and I'm ashamed

19:54 justin_smith: mdeboard: hah

19:55 * mdeboard grumbles

19:57 benkay: does anyone else have problems with running 2 repls in 2 projects at the same time?

19:57 using cider

19:57 mdeboard: benkay: I don't do that, as a rule. I had trouble with nrepl back in the day

19:58 running 2 repls

19:58 i don't remember what it entailed

19:58 benkay: buuuh

19:58 justin_smith: benkay: in nrepl I start each repl in a terminal, and do C-u m-x nrepl, so that each one gets its own repl

19:58 this is one of those things where jacking in just makes it more complex

19:58 benkay: ah yes, i suppose it's worth mentioning i'm working from emacs.

19:58 *sigh*

19:59 justin_smith: benkay: this is from emacs, just using nrepl.el

19:59 benkay: so the answer to "can i use code navigation on two projects at once?" is "no"?

19:59 justin_smith: cider.el should be similar

19:59 benkay: justin_smith: neat. that's a protip for sure.

19:59 mdeboard: justin_smith: like I get the loop example, and "recur until some condition is met", but I guess I don't understand how minimal state can get. I can't envision how to do this without each player having some "bag of state"

20:00 benkay: does nrepl (and hopefully cider, but i know you don't know) then pin the relevant connection to the relevant projects?

20:00 justin_smith: also, if you haven't tried it, try "C-u M-x cider-jack-in" to start your second repl

20:00 mdeboard: Or C-c M-j

20:00 justin_smith: mdeboard: can't player specific state be a key under the state object?

20:00 mdeboard: (by default, anyway)

20:00 umpa: ##(def x nil)

20:00 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

20:01 umpa: ,(def x nil)

20:01 clojurebot: #'sandbox/x

20:01 umpa: (false? x)

20:01 ,(false? x)

20:01 clojurebot: false

20:01 mdeboard: justin_smith: It can, I just am having a tough time conceptually :P

20:01 llasram: umpa: only `false` is `false?`. `nil` is false-y

20:01 ,(boolean nil)

20:01 clojurebot: false

20:01 benkay: justin_smith: yeah, cider gets confused when i jack in to two separate projects.

20:02 llasram: ,(false? (boolean nil))

20:02 clojurebot: true

20:02 justin_smith: well that sucks! nrepl handles it OK if I start the projects via lein repl and connect to that, at least

20:02 llasram: benkay: cider 0.5.0 is fine with multiple projects

20:02 benkay: grrrrrrrrr clojure startup time has ruined my weekend

20:02 llasram: at least in my experience

20:03 benkay: how so?

20:03 umpa: ,(def x false)

20:03 clojurebot: #'sandbox/x

20:03 benkay: hm llasram how do i check a package version in emacs? list packages?

20:03 llasram: benkay: ya

20:03 umpa: ,(false? x)

20:03 clojurebot: true

20:04 benkay: llasram: i've been doing a bunch of refactoring and having to restart the jvm proc and clojure with it is murdering my productivity.

20:04 implementing a reloaded workflow on something that was never meant to have one...

20:04 umpa: justin_smith: how does truthy apply to the filter ?

20:05 mdeboard: I guess https://gist.github.com/mattdeboard/c8b163b88152f2d3fb1f ? idk captain

20:05 justin_smith: umpa: because I wrongly expected an empty intersection of sets to act as a false value

20:05 wrapping it in seq fixes it though (that generates nil for an empty set)

20:05 ,(do (require '[clojure.set :as s]) (filter #(seq (s/intersection #{0 1} (set %))) '((1 2 3) (4 5 6) (0 1 2))))

20:05 clojurebot: ((1 2 3) (0 1 2))

20:05 llasram: benkay: What are you refactoring that's requiring restarts?

20:06 benkay: silly little webapp.

20:06 justin_smith: he's moving things between clojure.test and midge, iirc

20:06 benkay: no, i straight up gave up on midje.

20:06 llasram: Hmm. Still shouldn't be necessary to restart

20:06 You can just kill namespaces and reload them

20:06 justin_smith: benkay: good plan, imho

20:06 llasram: agreed

20:07 mdeboard: why so

20:07 too fat?

20:07 benkay: llasram: definitely in the workflow, and yet i keep getting SLIMEd.

20:08 llasram: mdeboard: Not exactly... It's got some nice ideas, but (a) I've never found it to play entirely nicely with a "normal" Clojure workflow, and (b) it is essentially it's own non-Clojure mini-language implemented by interpreting the s-expressions its macros get passed

20:08 benkay: Not quite following

20:08 benkay: https://github.com/clojure-emacs/cider-nrepl // build: failing

20:08 yay tooling

20:09 justin_smith: mdeboard: whereas clojure.test is built on functions and defs and metadata in a very idiomatic way, which means it is easy to use standard clojure composition / abstraction techniques to make it do what you want

20:09 mdeboard: I see

20:10 benkay: by the way, i also completely failed at running individual tests with clojure.test

20:10 (run-test 'my-test-ns/test-i-want-run-dammit) just returns nil

20:10 justin_smith: does it print anything?

20:11 benkay: lol nil

20:11 Raynes: benkay: What version of clojure are you using?

20:12 benkay: Raynes: 1.5.1

20:12 Raynes: benkay: Any reason you can't use 1.6.0?

20:13 benkay: aside from being *-deep in a refactor that's consuming my life already?

20:13 Raynes: benkay: https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/test-vars

20:13 test-var existed in clojure 1.5 though, so if you really only need to run one specific test, it may work fine for you.

20:14 benkay: ah yes, i did actually mean test-var, apologies.

20:14 (test-var 'my-test-ns/test-...)

20:15 holy heck does test-var not use fixtures?

20:15 mdeboard: I reckon the simplest refactor here would be to take the state off the edges/routes and just associate that state with the player

20:16 llasram: benkay: Fixures only applying when running the tests for an entire namespace are standing issue with clojure.test

20:16 Raynes: benkay: I suppose it doesn't, which I imagine is in fact the reason I added test-vars.

20:16 llasram: I personally just avoid clojure.test fixtures for that reason -- it's just as easy to write your fixtures such that you explicitly apply their functions/macros in each test

20:16 Raynes: It isn't a standing issue because test-vars exists now.

20:16 llasram: ah

20:17 Raynes: But prior to 1.6.0, it was indeed an issue.

20:17 llasram: I missed that

20:17 benkay: Raynes: thou art a scholar

20:17 llasram: Obvs didn't read the changelog closely enough :-)

20:17 Raynes: https://github.com/clojure/clojure/blob/919a7100ddf327d73bc2d50d9ee1411d4a0e8921/src/clj/clojure/test.clj#L710

20:17 technomancy: Raynes actually succeeded in getting a commit applied to clojure.test

20:17 clearly he is the chosen one of the prophecy

20:17 Raynes: I'm pretty sure it took over a year.

20:17 lol

20:17 A year + gfredericks.

20:18 llasram: I probably saw the entry, but my mind elided it because it was obviously impossible

20:18 technomancy: some interpretations of the prophecy mention the chosen two

20:19 * benkay ponders how best to handle current wip for a 1.6 upgrade

20:19 Raynes: I don't think 1.6 had actual breaking changes over 1.5.1, did it?

20:19 I've been knee deep in Python for like 5 months though, so I could be wrong.

20:20 talios: I don't believe it do.

20:20 llasram: The hash changes lead to requiring updates of some Clojure-aware collection libraries

20:20 But I think that's it

20:22 benkay: well thanks, all.

20:25 Raynes: benkay: Sorry I'm being so aggressive with the test-vars. It's approximately the only thing I've felt strongly enough about to go through the contribution process to add :P

20:25 benkay: i now have an entirely different set of errors from my tests to look over, so i guess that's progress...

20:25 not at all, Raynes! and as a matter of fact thanks for your work on that.

20:25 i feel like a complete and total moron for having seen test-var and not test-vars

20:27 mdeboard: lol

20:28 gfredericks: benkay: that's a mistake a regular person would make, not a complete and total moron

20:28 mdeboard: benkay: If it makes you feel any better, I just spent 3 minutes trying to figure out why (get "foo" {"foo" "bar"}) kept returning nil (backward params)

20:28 Raynes: Yeah, it's not like you're gfredericks or anything

20:28 clojurebot: It's greek to me.

20:28 Raynes: <3

20:28 jk ily gf

20:28 gfredericks: lol

20:29 benkay: i am extremely tempted to throw everything out and upgrade to 1.6.0 just for test-vars, actually.

20:30 gfredericks: clojurebot: test-vars is the killer app of clojure 1.6.0

20:30 clojurebot: c'est bon!

20:30 benkay: Raynes: does test-vars work as a ns-hook?

20:30 Raynes: I've never really used much in the way of fancy testing hooksy thingies.

20:31 But all test-vars does is look up metadata on namespaces to get fixtures.

20:31 So as long as it can do that, it should work anywhere.

20:31 * benkay crosses every crossable thing and prays

20:32 gfredericks: Dear Randall Munroe: what would happen if you actually crossed every crossable thing?

20:32 benkay: lol okay 1.6 great looking fine but where'd the output from clojure test mode go

20:32 waaah

20:33 * benkay dives willy-nilly into new emacs packages

20:34 gfredericks: what would it take to start using maven for emacs packages

20:34 mdeboard: ...

20:34 johnwalker: don't

20:34 clojurebot: excusez-moi

20:34 mdeboard: what.

20:34 johnwalker: please don't

20:34 mdeboard: srs

20:35 johnwalker: for your sake

20:35 gfredericks: my sake is already ragged from being on the bleeding edge all the time

20:35 johnwalker: bleeding edge 6 years ago?

20:35 come on man, you gotta do grails for emacs packages

20:36 gfredericks: I mean the normal emacs package manager

20:36 which only gives you the latest of everything

20:36 johnwalker: oh

20:36 well there's marmalade stable

20:37 err, melpa stable

20:53 umpa: ,coll

20:53 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: coll in this context, compiling:(NO_SOURCE_PATH:0:0)>

20:54 umpa: ,col

20:54 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: col in this context, compiling:(NO_SOURCE_PATH:0:0)>

20:54 mdeboard: umpa: coll just means collection

20:55 umpa: ,(def col '((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) (2 5 8) (0 4 8) (2 4 6)))

20:55 clojurebot: #'sandbox/col

20:55 umpa: ,(def ks [8 2 6 0])

20:55 clojurebot: #'sandbox/ks

20:56 umpa: ,((fn [ks ls] (reduce (fn [m v] (assoc m v (filter #(set/intersection (set %) (set v)) ls))) {} ks)) ks col)

20:56 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>

20:56 umpa: this is not working

20:56 akhudek: clojure.set

20:57 umpa: ,(require 'clojure.set :as set)

20:57 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>

20:57 akhudek: just use it directly

20:57 umpa: ,(require 'clojure.set as set)

20:57 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: as in this context, compiling:(NO_SOURCE_PATH:0:0)>

20:57 akhudek: (clojure.set/intersection … )

20:57 umpa: ,((fn [ks ls] (reduce (fn [m v] (assoc m v (filter #(clojure.set/intersection (set %) (set v)) ls))) {} ks)) ks col)

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

21:03 umpa: isn't reduce suppose to take values from coll and ks one by one and apply the filter

21:07 technomancy: gfredericks: nix for emacs packages makes like seventeen times more sense

21:07 err--guix rather

21:08 gfredericks: technomancy: hokay hokay I'll go for that

21:08 I just don't know it as good

21:09 technomancy: it's worth getting to know

21:09 gfredericks: oh I use it for at least half of my junk

21:35 technomancy: guix or nix?

21:35 Raynes: Both

21:48 gfredericks: technomancy: nix

21:48 I have no idea what guix is

21:48 so I probably shouldn't have responded so confidently

21:51 justin_smith: gfredericks: wait, do you actually use nixos?

21:55 Raynes: Somebody has to

21:56 justin_smith: it looks interesting

21:56 Raynes: So does space travel, but I ain't looking to go to Mars any time soon.

21:59 * justin_smith installs nixos, only to find out too late that this dooms him to a cold lonely death far from humanity, never to see his friends or loved ones again.

21:59 justin_smith: funny, that does sound like what an experimental Linux distro would do

22:00 johnwalker: do you like nixos?

22:08 dpathakj: there’s nix, the package manager, and nixos, the linux distribution

22:08 seems like you could get away with one without the ohter

22:10 technomancy: yeah, nix works great on debian

22:11 gfredericks: guix is nix without the weird one-off package language; it uses guile instead

22:11 and it also actually has standards for licensing instead of just accepting any random shit

22:15 gfredericks: justin_smith: no just the package manager

22:15 technomancy: "is nix" meaning it's part of their ecosystem or it just instantiated the core concepts in some other way?

22:16 technomancy: gfredericks: it's compatible with the same package sources and shares a good deal of code

22:16 gfredericks: doesn't sound absolutely terrible so far

22:16 technomancy: afaict it's like a new language that compiles to the same runtime, like clojure

22:16 gfredericks: metaphors how do they work

22:16 technomancy: but nix is already pretty obscure, and the guix community is smaller still

22:17 anyway, as soon as I find something that wheezy's versions are too old for imma try guix, but it hasn't actually happened yet

22:17 (modulo lein/emacs obvs)

22:17 gfredericks: I should stick to popular software communities like clojure

22:17 technomancy: clojure is "mature"

22:18 * technomancy strokes his beard, which spills over voluminously to the floor

22:19 dpathakj: technomancy: re: ‘standards for licensing’: do you know if guix is gpl-only, or are more permissive but still free licenses like MIT allowed by guix’s maintainers?

22:19 technomancy: dpathakj: it's libre licenses only

22:20 dpathakj: it just bans crazy stuff like the adobe flash player, which I was dismayed to learn that nix ships, apparently illegally

22:20 iirc it's basically limited to dfsg-free plus gfdl

22:24 dpathakj: technomancy: thanks. makes sense.

22:25 johnwalker: technomancy: do you use a gnu distribution now?

22:26 it sounds like you use debian

22:32 mdeboard: justin_smith, Raynes: Well I hope you're happy.

22:32 Raynes: In general, yes.

22:32 justin_smith: mdeboard: things are pretty peachy

22:33 mdeboard: I've been refactoring for "pure functional" blah blah blah

22:33 justin_smith: so you made the switch to an explicit game state object passed between functions?

22:33 mdeboard: Lucky for you I wrote things in such a manner that it makes such refactoring straightforward

22:33 justin_smith: lucky for me

22:33 mdeboard: LUCKILY

22:34 You've squeaked by, by the skin of your teeth.

22:34 talios: mdeboard - are you doing any form of clojure based monad foo there as part of being pure?

22:34 mdeboard: talios: All I know about monads is that they're like astronauts eating a burrito

22:34 gfredericks: ~monad

22:34 * talios gets visions of a "purity pledge" and "technical virgin"

22:34 clojurebot: monad is monads

22:34 gfredericks: ~monads

22:34 clojurebot: monads are #=(str "super" "awesome")

22:35 gfredericks: Supera Wes o' Me

22:36 justin_smith: talios: that's funny, because the purity talk we had at my first highschool was "I'm worth waiting for", which I could interpret to be relevant to the usefulness of laziness in pure functional programming

22:36 mdeboard: (defer)

22:37 justin_smith: or maybe the usage of delays or something

22:37 yeah

22:37 mdeboard: (force)

22:37 :o

22:37 justin_smith: oh yuck

22:37 mdeboard: (defn chastity-belt (conj force defer))

22:37 throw a [] in there

22:37 talios: force sounds rapey

22:37 justin_smith: fits with the whole "promise keepers" thing I guess

22:37 mdeboard: hahaa

22:37 nice

22:37 @ promise keeper

22:38 technomancy: johnwalker: yeah, I'm on debian

22:39 gws: ,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac m1)

22:39 clojurebot: #'sandbox/m1

22:40 gws: ,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"})

22:40 clojurebot: #'sandbox/m1

22:40 gws: so that's not gonna work in IRC, but can anyone tell me why the first one prints nil and the second prints "v"?

22:41 justin_smith: (do ,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"}))

22:41 ,(do (def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"}))

22:41 clojurebot: v\n

22:41 gws: ha, thanks

22:42 ,(do (def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac m1))

22:42 clojurebot: nil\n

22:42 gws: i'm trying to wrap my head around the difference there

22:43 gfredericks: ,(let [{v :k} 'm1] ["My v is" v])

22:43 clojurebot: ["My v is" nil]

22:43 dbasch: gws: macroexpand-1

22:43 johnwalker: technomancy: cool

22:45 amalloy: gws: remember that a macro receives unevaluated symbols as its arguments

22:45 not the values to which those symbols may be bound in some particular evaluation context

22:47 gws: ah, alright. i see it now

22:49 dbasch: i had that, but I was missing was the "why" - unevaluated symbols made it click

22:50 amalloy: thanks, i appreciate it

23:58 kelseygi: hey i’ve got a string

23:58 & i need to split it on a separator

23:58 mdeboard: nice

23:58 lazybot: java.lang.RuntimeException: Unable to resolve symbol: i in this context

23:58 kelseygi: but i need to do something different with the last substring depending on whether it ended in the separator or not

23:58 everything i can think of is super imperative-y

23:59 mdeboard: ,(clojure.string/split "a,b,c,d," #",")

23:59 clojurebot: ["a" "b" "c" "d"]

23:59 mdeboard: ?

23:59 kelseygi: ,(clojure.string/split "a,b,c,d" #",")

23:59 clojurebot: ["a" "b" "c" "d"]

23:59 kelseygi: i wanna be able to tell the diff between those two

Logging service provided by n01se.net