#clojure logs

2014-06-15

00:01caternumpa: er, which values in particular are you trying to get?
00:02caternthe first and last of the first in the list, and the first and last of the last in the list?
00:02umpacatern: yes
00:02caternno offense, but it sounds like you're doing something horribly wrong...
00:02caternwhy do you need those values in particular?
00:03umpaI use them as arguments
00:03caternfor what?
00:04umpafor an intersection with a dpendency
00:06caternif you say so. you could write a function: (defun bounds [seq] (list (first seq) (last seq))) and then do (map bounds (bounds x))
00:09TEttingerwhy do you need the last of the first list?
00:09TEttingerdon't you just need ffirst and (last (last ...)) ?
00:10johnwalkeryou really like partition
00:11umpacatern: nice
00:11umpaTEttinger: its a grid with corners
00:11TEttingeroh I get it
00:12caternah, that's not that bad then
00:19deathknightbeen at this for hours...would probably take one of you guys about 5-10 minutes to help me do this
00:19deathknighttrying to auth with google with this tutorial: http://blog.knoldus.com/2014/04/05/google-sign-in-using-clojure/
00:19deathknightWhen I add that to a new compojure project, I get an http 400 error
00:24benkayis there a dumb-dumb test-profiler kicking around?
00:26johnwalkerby google sign-in, do you mean openid?
00:27johnwalkerdeathknight: or are those separate things entirely?
00:27deathknightSorry for not being clear
00:27deathknightGoogle uses OAuth 2
00:28johnwalkerahh
00:29deathknightAs of 1 minute ago I just found an example on github that has a Google Oauth2 login handler that uses the friend lib!!
00:30deathknightso pumped
00:30johnwalkeroh nice
00:31deathknightwhats nice is the 3 energy drinks
00:31johnwalkercaffeine is bad for you
00:32johnwalker,(def caffeine-overflow "8mg")
00:32clojurebot#'sandbox/caffeine-overflow
00:33deathknightkeep going
00:33benkay,(println caffeine-overflow)
00:33clojurebot8mg\n
00:33deathknightmmmm
00:34benkayhm.
00:34noonian,caffeine-overflow
00:34clojurebot"8mg"
00:34benkaya yeah.
00:35benkaythanks, noonian
00:38noonianhmm, 8mg is not much caffeine at all
00:39johnwalkerlol
00:41benkaynoonian: http://goo.gl/oWcMzB
00:42noonianhaha, that looks dangerous
00:42johnwalkerrelated: https://twitter.com/dozba/status/477917824870912000
00:43benkaytchyeah
00:43systemfaultThe 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
00:44benkaywhen 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
00:44benkay'twas GREAT
00:44TEttingermikes?
00:44TEttingerhttp://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
00:45benkayTEttinger: mg
00:45TEttinger(taking one now)
00:45benkaythat's a 200 mike pill as well :)
00:46TEttingerthe 2 liters water is odd though
00:46TEttingerit seems like a ton
00:46deathknighthas anyone used friend-oauth2 to communicate with google?
00:48luxbockI'm having some trouble trying to merge two project files generated from templates to get the best out of both
00:48TEttingerluxbock, got them in a gist maybe?
00:48benkayTEttinger: 4L/day is a superb hydration level.
00:48luxbockhttps://gist.github.com/anonymous/70c4e04b84c1197e756e
00:49luxbockthis is what I have
00:49TEttingerbenkay, no doubt, I drink water constantly
00:49TEttingerbut finishing a 1.5 liter bottle in a sitting would be a challenge
00:49benkayTEttinger: i rarely made it through the whole second bottle.
00:49luxbockbut when I start try to use cider-repl-jack-in it complains about the austin class file missing
00:50benkayah well it was over the course of the pre-lunch drag and the post-lunch drag
00:50luxbockso basically it's not finding the stuff I have defined in the dev-profile
00:50benkaythat job was a real drag
00:50benkayi've graduated to a .75L bottle always at hand. people think i'm a wino when they first see this in practice!
00:50luxbockreading 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
00:51TEttingerWARNING 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.
00:51luxbockahhh
00:51luxbockyeah I just did `lein ancient update` before
00:51luxbockalright makes sense, thanks
00:52TEttingerso you would change the dep on line 8 to 0.0-2156 , luxbock
00:53TEttingerno prob, I actually only found it because I didn't know what austin was
00:54luxbockhmm, I still have the same problem
00:54luxbockI think these issues might be unrelated
00:54TEttingergah
00:55TEttingermaybe https://gist.github.com/anonymous/70c4e04b84c1197e756e#file-project-clj-L40 doesn't have it loaded by the highlighted point?
00:56luxbockthe two templates that I'm trying to merge are https://github.com/magomimmo/om-start-template and https://github.com/bhauman/devcards-template
00:56umpa,(defn coffee [sip] (coffee (inc sip)))
00:56clojurebot#'sandbox/coffee
00:56luxbockin om-start-template the :dev profile is defined in a profiles.clj file
00:56luxbockwhich I moved into the project.clj file for my project, thinking it would not make a difference
00:57luxbockbut maybe that's the issue
00:57umpa,(coffee 0)
00:57clojurebot#<StackOverflowError java.lang.StackOverflowError>
00:58TEttingerI dunno, I've barely touched profiles
00:59luxbockyeah works now, though I'm not exactly sure what's actually different from leins point of view
01:02deathknightfriend-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)?
01:11johnwalkerdeathknight: if you can figure it out, it's good blog post material
01:12deathknight:D
01:12johnwalkeri would retweet it to my fifteen followers who favorite but never retweet
01:12deathknightHaha!
01:12deathknightIt'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?
01:14johnwalkerdoes ddellacosta's link work?
01:14johnwalkerer, the first one?
01:15johnwalkeroh
01:15deathknighthis google example does not work
01:15deathknighthe even addressed it in an issue on the corresponding github page
01:16johnwalkerbut the oauth2 does?
01:16deathknightso it successfully takes me to google's oauth2 page where I give consent to the app
01:16deathknightand then upon redirect, there is a failure of permission authentication
01:16deathknight(even though I gave permission)
01:17johnwalkerdoes this pr help?
01:17johnwalkerhttps://github.com/ddellacosta/friend-oauth2/pull/18
01:17deathknightnot sure -- looking in to it
01:18deathknightalso, relevant to the issue: https://github.com/ddellacosta/friend-oauth2-examples/issues/4
01:18johnwalkeroh, thats good stuff
01:19johnwalkeri don't know but i hope you figure it out
01:19deathknightthank you John!
01:20johnwalkeryou're welcome, sorry i can't help
01:20johnwalkerfriend confuses me in general
02:07benkayI don't use Friend, tbh.
02:08benkayit's a little more work, but the flexibility and power of writing my own auth handlers is pretty great.
02:08benkaydefinitely not what people coming from the webdev community at large are expecting though vis-a-vis authentication libraries.
02:38ambrosebsa seq can only be infinite if (every-pred #(instance? clojure.lang.IPending %) (complement realized?))
02:38ambrosebsright?
02:39ambrosebsI don't think that make sense.
02:39ambrosebs,((every-pred #(instance? clojure.lang.IPending %) (complement realized?)) (seq (range)))
02:39clojurebotfalse
02:40ambrosebsso I guess all bets are off if you're holding an arbitrary seq.
02:44dbaschambrosebs: it’s the halting problem essentially
02:45amalloyambrosebs: IPending is very much a "well, maybe, whatever" - it doesn't really mean anything reliable
02:47amalloyand 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))
02:57amalloy&(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
02:57lazybot⇒ (1 1 1 1 1 1 1 1 1 1)
03:10ambrosebsamalloy: interesting.
03:12ambrosebsassuming seqs are infinite is probably a cleaner solution for me anyway.
03:51sveriHi, 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?
03:57visofHello
03:58visof,(clojure.string/replace (clojure.string/replace "\"Hello\nWorld\"" #"\"" "") "\n" " ")
03:58clojurebot"Hello World"
03:58visofis there a better way to do this?
04:04TEttingerit's two separate replacements?
04:13danielcomptonvisof: so the original string is "\"Hello\nWorld\"
04:13danielcompton,(println "\"Hello\nWorld\")
04:13clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
04:13danielcompton,(println "\"Hello\nWorld\"")
04:13clojurebot"Hello\nWorld"\n
04:24sverireiddraper: pint
04:24sveri*ping
04:59ptcekDatomic 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
06:08toxmeisterwith 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?
07:45kzar$findfn {:a {:b 2} :c 3} :a :b {:c 3}
07:45lazybot[clojure.core/dissoc]
07:45kzar$findfn {:a {:b 2} :c 3} :a :b {:a {} :c 3}
07:46lazybot[]
07:46kzar$findfn {:a {:b 2 :g 4} :c 3} [:a :b] {:a {:g 4} :c 3}
07:46lazybot[]
07:47kzar$findfn {:a {:b 2 :g 4} :c 3} :a :b {:a {:g 4} :c 3}
07:47lazybot[]
07:49kzar,(update-in {:a {:b 2 :z 4} :c 3} [:a] dissoc :b)
07:50clojurebot{:c 3, :a {:z 4}}
07:52kzar,(defn dissoc-in [m keys]
07:52kzar (update-in m (butlast keys) dissoc (last keys)))
07:52clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
07:52kzar,(defn dissoc-in [m keys] (update-in m (butlast keys) dissoc (last keys)))
07:52clojurebot#'sandbox/dissoc-in
07:52kzar,(dissoc-in {:a {:b 2 :z 4} :c 3} [:a :b])
07:52clojurebot{:c 3, :a {:z 4}}
07:53lvhIs it okay for the result-expr of a case to have side effects?
07:53lvhare they only eval'd for the particular case?
08:42Jardahm
08:58visofis 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} ?
09:06sandbags,(into {} (map (fn [[k v]] [v k]) {:a 1 :b 2 :c 3})
09:06clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
09:06sandbags,(into {} (map (fn [[k v]] [v k]) {:a 1 :b 2 :c 3})))
09:06clojurebot{3 :c, 2 :b, 1 :a}
09:06sandbagsvisof: ^
09:06visofsandbags: well done
09:07sandbagsi suspect there's an even easier way, there usually is :)
09:48gfrederickswith prismatic/plumbing it'd be (for-map [[k v] m] v k)
09:51mi6x3manyway of determining if a text is a valid html?
09:53sverimi6x3m: there are some java libraries for this which I would use
09:55mi6x3msveri: yeah, I know, was wondering if there is something more clojure-ish
09:57sverimi6x3m: not that I know of, but that doesnt mean anything. Maybe enlive provides something?
09:57mi6x3mchecking it out just now :)
10:01deathknightwhat is the name of -> so that I may look up what it does?
10:05ambrosebsdeathknight: http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
10:06ambrosebsor thread-first
10:06deathknightyou rock
10:06deathknightthats the author o JOC, right?
10:06ambrosebsyes
10:06deathknight:D
10:07deathknightToday is the day I replace who sits on the throne - err, communicate with google calendar's API
10:16umpa(require 'clojure.set)
10:16umpa,(require 'clojure.set)
10:16clojurebotnil
10:16umpa,(set/difference #{1 4} #{1 4 7})
10:16clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
10:16umpa,(clojure.set/difference #{1 4} #{1 4 7})
10:16clojurebot#{}
10:17umpa,(clojure.set/difference #{1 4 7} #{1 4})
10:17clojurebot#{7}
10:17michaniskin,(clojure.set/difference #{1 4 7} #{1} #{4})
10:17clojurebot#{7}
10:18umpaHow do I get the difference no matter the order ?
10:19engblomIs 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:20ambrosebs,(require '[clojure.set :as set])
10:20clojurebotnil
10:21ambrosebs,(let [ss [#{1 4 7} #{1} #{4}]] (set/difference (apply set/union ss) (apply set/intersection ss)))
10:21clojurebot#{7 1 4}
10:21ambrosebssome combination of set operations..
10:21michaniskinheh
10:22michaniskinperhaps you want the complement of the intersection?
10:22michaniskini guess thats what ambrosebs just did
10:23ambrosebsprobably the union of all the combinations of calling difference.
10:24ambrosebs,(require 'clojure.math.combinatorics)
10:24clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/math/combinatorics__init.class or clojure/math/combinatorics.clj on classpath: >
10:24michaniskini mean order is kind of important for difference, like minus: (- 1 3) is not the same as (- 3 1)
10:26engblom,(Math/abs (- 3 1))
10:26clojurebot2
10:26engblom,(Math/abs (- 1 3))
10:26clojurebot2
10:26engblommichaniskin: ^
10:27ambrosebs(apply union (map (fn [[s1 s2]] (union (difference s1 s2) (difference s2 s1)) (comb/combinations ss 2))
10:27michaniskinengblom: i don't understand?
10:27ambrosebssomething like that?
10:27engblom<michaniskin> i mean order is kind of important for difference, like minus: (-
10:27engblom 1 3) is not the same as (- 3 1)
10:29michaniskinengblom: sure, or (Math/min -10000 (- 3 1))
10:29ambrosebsfunny enough, I just needed this kind of set operation. Useful if you already know the differences in advance.
10:29michaniskinlots of things you can do to wrap minus in something lol
10:31john2xdoes `& rest` arguments work with multi-arity functions?
10:31umpaambrosebs: the first one works
10:31ambrosebsumpa: oh. Yes you're right :P
10:32michaniskin`(defn ff ([x] :one-arg) ([x & more] :more-args))
10:32michaniskin,(defn ff ([x] :one-arg) ([x & more] :more-args))
10:32clojurebot#'sandbox/ff
10:32michaniskin,(ff :x)
10:32clojurebot:one-arg
10:32michaniskin,(ff :x :y)
10:32clojurebot:more-args
10:33michaniskinjohn2x: is that what you mean?
10:33john2xmichaniskin: oh, I mean both definitions having `& more`..
10:35michaniskinjohn2x: that would be kind of crazy, no?
10:35michaniskinalso
10:35john2xyeah..
10:36michaniskin,(defn ff ([x] :one-arg) ([[x & rest] & {:keys [opt] :as options}] :bad))
10:36clojurebot#'sandbox/ff
10:36michaniskin,(ff [:a])
10:36clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ff in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:38engblomAssuming 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:49gfredericksengblom: no, that sounds pretty specific to me
10:50gfredericks,(defn decfirst ([v] (decfirst v 0)) ([v i] (if (pos? (v i)) (assoc v i (dec (v i))) (recur v (inc i)))))
10:50clojurebot#'sandbox/decfirst
10:50gfredericks,(decfirst [0 0 3 2 2])
10:50clojurebot[0 0 2 2 2]
10:57sandbagsmaybe using partition-by and zero?
10:58michaniskin,(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:58clojurebot#'sandbox/replacefirst
10:58michaniskin,(replacefirst (complement zero?) dec [0 0 3 2 2])
10:58clojurebot[0 0 -1 0 3 ...]
10:58michaniskinwhoa nevermind
10:58michaniskinlol
11:00michaniskin,(replacefirst zero? dec [0 0 3 2 2])
11:00clojurebot[2 2 2]
11:00michaniskin,(replacefirst pos? dec [0 0 3 2 2])
11:00clojurebot[0 0 -1 0 3 ...]
11:00johnwalkerwhats the idea? update the first element in a collection that matches pred?
11:01michaniskinindeed
11:02michaniskin,(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:02clojurebot#'sandbox/replacefirst
11:03michaniskin,(replacefirst (complement zero?) dec [0 0 3 2 2])
11:03clojurebot[0 0 2 2 2]
11:03michaniskinwhew
11:05michaniskin,(replacefirst #(pos? (val %)) dec (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:05clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap$BlackVal cannot be cast to java.lang.Number>
11:06michaniskin,(replacefirst #(pos? (val %)) (juxt identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:06clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentTreeMap$BlackVal cannot be cast to java.lang.Number>
11:12johnwalker(defn update-first [pred f coll] (let [[x [t & r]] (split-with (complement pred) coll)] (concat x [(f t)] r)))
11:12mi6x3mhey, can anyone tell if this looks like something a sane clojure programmer would produce? http://pastebin.com/KdqeTb7p
11:12mi6x3mTrying to get a feeling for these things :)
11:13johnwalkeryeah looks good
11:14mi6x3mjohnwalker: thanks
11:14michaniskinah split-with, that's right
11:15michaniskinit would be useful to have the FL "construct" function in clojure: (construct [inc dec] [10 10]) => [11 9]
11:15johnwalkerwhats FL?
11:16johnwalkeri see what construct does, but haven't heard of FL
11:17michaniskinjohnwalker: http://www.thocp.net/biographies/papers/backus_turingaward_lecture.pdf
11:17michaniskinFL is pretty mindblowing
11:18michaniskinbasically in FL the expression [inc dec] is like in clojure (partial construct [inc dec])
11:18michaniskinsquare brackets indicate construction
11:19ohpauleezmichaniskin: Have you played with J?
11:19michaniskinohpauleez: hey dude! no, is it good?
11:19ohpauleezDude, you need to
11:19ohpauleezbasically all the good ideas from FP and FL
11:20ohpauleezplus some extra solid stuff
11:20ohpauleezHmm, a quick Google search shows me this: http://www.infoq.com/presentations/j-language
11:21ohpauleezAnd, like other programming languages, good history on wikipedia: http://en.wikipedia.org/wiki/J_%28programming_language%29
11:21michaniskini 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:22michaniskinit's not really easy to do that in FL or stack based languages
11:22johnwalker(map #(% %2) [inc dec] [10 11])
11:22johnwalker,(map #(% %2) [inc dec] [10 11])
11:22clojurebot(11 10)
11:22kzarIs there a way to set jruby as a dependency in my project.clj? (Not sure how to add non-clojars dependencies.)
11:22hyPiRion,(map deliver [inc dec] [10 11])
11:22clojurebot(11 10)
11:23johnwalkerahh, nice
11:23johnwalker,(doc deliver)
11:23clojurebot"([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:23hyPiRionexcept never use deliver like that
11:23michaniskinwhoa!
11:23michaniskin(inc hyPiRion)
11:23lazybot⇒ 37
11:23hyPiRion&(source deliver)
11:23lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
11:23hyPiRion,(source deliver)
11:23clojurebotSource not found\n
11:23hyPiRion$source deliver
11:23lazybotdeliver is http://is.gd/U3dg84
11:24michaniskinohpauleez: do you program in J?
11:24caternmichaniskin: (def construct (partial map apply)) ?
11:24ohpauleezkzar: You can add any clojars or maven central dep. You can also specify other maven repositories with :repositories
11:25ohpauleezmichaniskin: 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:25ohpauleezhyPiRion: How the hell did you discover that abuse?
11:26kzarohpauleez: Oh cool [org.jruby/jruby "1.7.12"] did it, thanks
11:26ohpauleezkzar: No problem, happy to help!
11:26hyPiRionohpauleez: you don't want to know
11:26michaniskin,(def construct (partial map deliver))
11:26clojurebot#'sandbox/construct
11:26michaniskin,(construct [inc dec] [10 10])
11:26clojurebot(11 9)
11:27michaniskin,(replacefirst #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:27clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: replacefirst in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:28michaniskin,(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: update-first in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:32umpa(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:32umpa(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:33umpasorry about that
11:33michaniskinit won't work because construct should really return a vector, not a seq
11:33michaniskin,(def construct (comp ver (partial map deliver)))
11:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ver in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:33michaniskin,(def construct (comp vec (partial map deliver)))
11:33clojurebot#'sandbox/construct
11:34umpa,(update-first #(pos? (val %)) (construct identity dec) (sorted-map :a 0 :b 0 :c 3 :d 3 :e 2))
11:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: update-first in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:35umpa$source identity
11:35lazybotidentity is http://is.gd/iexysV
11:38johnwalker\join #org-mode
11:39johnwalkerwoops
12:16johnny_hello!
12:16johnny_anyone around?
12:17engblomjohnwalker: 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:17engblomjohnny_: Yep
12:18johnny_yay! I'm a clojure newbie; I've done a fair bit if LISPing before... is this the place for me?
12:18engblomjohnny_: Yes, this is the place
12:18johnwalkerengblom: it's wacky destructuring
12:18johnny_engblom: grand!
12:19johnwalkerengblom: x t and r are the left values for split-with
12:20engblomjohnwalker: So even the binding in the let is not happening until you have some values?
12:22johnwalkeri'm not sure if i understand the question, but this should help:
12:22johnwalkerhttp://blog.jayfields.com/2010/07/clojure-destructuring.html
12:24engblomjohnwalker: 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:25johnwalkerthe idea is that x gets the first list
12:25johnwalkerand then [t & r] get the second
12:26johnwalkert is the first element of the second list
12:26johnwalkerand r is the rest of the second list
12:26engblomI 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:26johnwalkersplit-with isn't being evaluated in the body
12:27johnwalkerit's the right value for [x [t & r]]
12:27engblomAh! Now I see
12:27engblomThanks, that was what I failed to notice
12:27johnwalkercool. yeah, it's hard to parse on one line
12:28visofHi
12:31visofif 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:32visof,(clojure.string/replace #"$0021" (clojure.string/replace #"002C" "Hello_$002C_$0021" ",") "!")
12:32clojurebot"$0021"
12:32visof,(clojure.string/replace #"$0021" (clojure.string/replace #"$002C" "Hello_$002C_$0021" ",") "!")
12:32clojurebot"$0021"
12:32visof,(clojure.string/replace #"$002C" "Hello_$002C_$0021" ",")
12:32clojurebot"$002C"
12:33visof,(clojure.string/replace (clojure.string/replace "Hello_$002C_$0021" #"$002C" ",") #"$0021" "!")
12:33clojurebot"Hello_$002C_$0021"
12:33visof,(clojure.string/replace (clojure.string/replace "Hello_$002C_$0021" #"\$002C" ",") #"\$0021" "!")
12:33clojurebot"Hello_,_!"
12:35johnwalkeryou can do it with reduce, but it won't be very efficient
12:37visofjohnwalker: https://www.refheap.com/86611 to replace all codes by symbols, i created two lists as you can see
12:38visofjohnwalker: maybe define empty atom and change it when replace string
12:38johnwalkerno thats not a good idea
12:38visofjohnwalker: why?
12:39johnwalkerhow is using an atom in this manner different from regular mutation?
12:40johnwalkeror a global variable in general?
12:40visofso you think reduce is better?
12:40johnwalkera lot better
12:40johnwalkerbut still not ideal
12:41johnwalkerone thing you might try is
12:41johnwalkeractually nevermind, that's not a good solution either
12:42johnwalkeryou can do this and it's basically ok for small strings
12:42johnwalkerhttp://stackoverflow.com/questions/9568050/in-clojure-how-to-write-a-function-that-applies-several-string-replacements
12:46johnwalkera better way would be to compile an fsm to handle multiple replacements
12:47johnwalkerjava probably has a standard solution, but i'd also be interested in seeing a clojure implementation
12:51umpaHow 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:51justin_smith(apply str (replace {"$002C", \,, "$0021", \!} "Hello_$002C_$0021")) ;; visof: depending on how many replacements, this may make sense
12:52justin_smith,(apply str (replace {"$002C", \,, "$0021", \!} "Hello_$002C_$0021")) ;; visof
12:52clojurebot"Hello_$002C_$0021"
12:52justin_smitherr...
12:52justin_smithoh, if the things to replace were chars and not strs it would work
12:53justin_smith,(apply str (replace {\☃, \,, \✈, \!} "Hello_☃_✈"))
12:53clojurebot"Hello_,_!"
12:55hyPiRionyou guys
12:55hyPiRion,(clojure.string/replace "Hello_$002C_$0021" #"\$(\p{XDigit}{4})" (fn [b] (-> b second (Integer/parseInt 16) char str)))
12:55clojurebot"Hello_,_!"
12:56hyPiRionreplace can take a function as last argument
12:57justin_smithhyPiRion: cool, I think I misunderstood the task here - and I think you can eliminate the str from that last function
12:57justin_smithnope, str is needed
12:59johnwalkerthats badass
12:59hyPiRionvisof: ^ does that solve your problem?
13:00bbloom(doc clojure.string/replace)
13:00clojurebot"([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:02alandiperthyPiRion, mindblown.gif
13:02bbloom,(clojure.string/replace "Hello_X_X" "X" (fn [_] "Y"))
13:02clojurebot#<ClassCastException java.lang.ClassCastException: sandbox$eval25$fn__26 cannot be cast to java.lang.CharSequence>
13:02bbloomhyPiRion: seems like an implementation detail ^^
13:03bbloom,(-> #'clojure.string/replace-by meta :private)
13:03clojurebottrue
13:03bbloomi wouldn't rely on that...
13:05hyPiRionbbloom: oh what. I honestly thought it was documented that you can pass functions as replacement values for regexes.
13:06johnwalkerhold on now
13:07johnwalker,(clojure.string/replace "Hello_X_X" #"X" (fn [_] "Y"))
13:07clojurebot"Hello_Y_Y"
13:07bbloomjohnwalker: yeah, it only works if the match argument is a regex
13:07hyPiRionjohnwalker: It doesn't make sense for a string anyway. You will always get the string as argument.
13:08hyPiRionWell, unless you use mutation under covers.
13:08johnwalkeroh, you're saying that this works too
13:08bbloomhyPiRion: if you want to rely on that, i'd submit a patch with a new doc string ;-)
13:08johnwalker,(clojure.string/replace "Hello_X_X" "X" "Y")
13:08clojurebot"Hello_Y_Y"
13:08bbloomjohnwalker: right
13:09johnwalkerstill, that's inconsistent
13:09hyPiRionbbloom: Well, *I* rely on that at least (for regexes). I was just surprised that it wasn't documented.
13:09hyPiRionI have used clojure.string/replace wrong all this time.
13:09hyPiRion"wrong"
13:11bbloomhyPiRion: like i said, a doc string change would probably fix that right up :-)
13:11johnwalkershouldn't it also be extended to accept functions as the second argument for strings?
13:12johnwalkerit might not be useful but it's certainly more regular
13:13hyPiRionbbloom: 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:21umpaHow do I group-by (0 7) coll ((0 2)(1 3)(0 5)(1 7)) ?
13:23justin_smithumpa: what does (group-by (0 7) mean? group by the presence of 0 vs. 7?
13:24umpajustin_smith: in a map form maybe {0 ((0 2)(05)) 7 ((1 7))}
13:25justin_smith,(group-by #(#{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7)))
13:25clojurebot{nil [(0 2) (1 3) (0 5) (1 7)]}
13:25justin_smitherr
13:26justin_smith,(group-by #(clojure.set/intersection #{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7))) closer
13:26clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
13:26justin_smith,(require 'clojure.set)
13:26clojurebotnil
13:26justin_smith,(group-by #(clojure.set/intersection #{0 7} (into #{} %)) '((0 2)(1 3)(0 5)(1 7))) closer
13:26clojurebot{#{0} [(0 2) (0 5)], #{} [(1 3)], #{7} [(1 7)]}
13:27umpajustin_smith: neat
13:29umpa,(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:29clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
13:30umpa,(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:30clojurebot{#{} [((0 1 2) (3 4 5) (6 7 8) (0 3 6) (1 4 7) ...)]}
13:31justin_smithumpa: that happened because you changed the list of lists to a list of list of lists
13:31umpa,(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:31clojurebot{#{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:32justin_smithmaybe you want something that takes the intersection, and decides what the "most relevant" key out of that is, and returns that alone
13:33justin_smithand you would wrap the intersection call in that extractor / orderer
13:34justin_smithsomething like #(or (% 6) (% 8) (% 2) (% 0))
13:35justin_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:35clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
13:36justin_smith,(require 'clojure.set)
13:36clojurebotnil
13:36justin_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:36clojurebot{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:38umpajustin_smith: nice
13:40justin_smiththat fn could be (fn [s] (first (keep s [6 8 2 0]))) actually
13:44umpa,(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:44clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.PersistentList>
13:45umpa(doc keep)
13:45clojurebot"([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:46justin_smithumpa: the reason I was using sets was to be able to do the intersection / contains? stuff, which does not work on seqs
13:46justin_smithwell, get rather than contains? but you know
13:47justin_smithyou replaced a # with a ' to get a seq rather than a set, which made that code fail
13:49umpajustin_smith: you are abs right
13:50umpagetting tangled
13:50umpa(umpa untangle)
13:51umpa,(umpa untangle)
13:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: umpa in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:51justin_smithright, it's a one liner for clojure bot demo sake, but better to actually make it readable
13:53umpajustin_smith: whats (first (keep s []
13:53justin_smith,(keep #{0 1 2} (range 10))
13:53clojurebot(0 1 2)
13:53justin_smithbad example
13:53justin_smith,(keep #{10 1 42} (range 100))
13:53clojurebot(1 10 42)
13:54justin_smith,(first (keep #{10 1 42} (range 100)))
13:54clojurebot1
13:54justin_smithjust gives you the first member of the set, found in the collection
13:54justin_smith,(first (keep #{10 1 42} (reverse (range 100))))
13:54clojurebot42
13:56justin_smithso the ordering of the collection, decides which of its members will be returned if the set contains multiple of its members
13:56justin_smith(misplaced ,)
14:01mi6x3mhey clojure, is it idiomatic to use clojure.repl/source in other scenarios than the REPL
14:01justin_smithwhat's the context?
14:01justin_smithif you are recompiling something from a new ns based on the output of clojure.repl/source, that is just wrong
14:03mi6x3mjustin_smith: I am translating a program showing java examples to a library
14:03mi6x3mand I shows controls + a "source" tabg
14:03mi6x3mclicking on the source tab fetches the .java file's contents
14:03justin_smithahh, that should be OK :)
14:08umpa,(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:08clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
14:09umpa,(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:09clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
14:09justin_smithyou need to require clojure.set
14:09justin_smith,(require 'clojure.set)
14:09clojurebotnil
14:09umpa,(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:09clojurebot{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:09mi6x3mjustin_smith: thanks but when is the source available, to begin with?
14:10mi6x3mis it always included with the build artifacts?
14:10justin_smiththe nil key shows you which items did not contain any of the keys you were looking for
14:10justin_smithmi6x3m: most clojure code is distributed as source, or at least includes source alongside the compiled classes
14:11umpathe 2 should be {2 [(0 1 2)(2 5 8)(2 4 6] ...
14:11justin_smithumpa: than change [6 8 2 0] to [2 6 8 0]
14:11justin_smithor do you want every permutation present?
14:12umpa^
14:17justin_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:17clojurebot{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:18justin_smithhmm, but no more nil key this way
14:18justin_smithoh and I bound lsets and never used it anyway :)
14:22umpa(,)(,)
14:46benkaydoes 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:49gfredericksbenkay: you've tried (deftest ^{:kw ...} test-name ...)?
14:49justin_smith(deftest foo ...) (def (new meta) foo foo) maybe? deftest creates a var, that is effectively a defn with args of []
14:49gfredericks,(require '[clojure.test :as t])
14:49clojurebotnil
14:50gfredericks,(deftest ^:foo bar (is true))
14:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: deftest in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:50gfredericks,(t/deftest ^:foo bar (t/is true))
14:50clojurebot#'sandbox/bar
14:50gfredericks,(meta #'bar)
14:50clojurebot{:ns #<Namespace sandbox>, :name bar, :file "NO_SOURCE_PATH", :column 0, :line 0, ...}
14:50gfredericks,(:foo (meta #'bar))
14:50clojurebottrue
14:51justin_smithoh, well that's much easier isn't it
14:51justin_smithd'oh, I even do that already for test selectors
14:51benkay<gfredericks> benkay: you've tried (deftest ^{:kw ...} test-name ...)? // yup, i have a brick for a brain.
14:51gfredericksany well-behaved macro that def things will let you put metadata on the symbol
14:54johnwalkerwhat are you using metadata here for?
14:55benkayjohnwalker: 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:55benkaynow, if only i knew enough to get clojure-test-mode to only evaluate the test with metadata...
14:55benkaytest(s)
14:57gfredericksdangit people stop putting arglists on the same line as the function name
14:57technomancygfredericks: no.
14:57gfrederickstechnomancy: it leads to accidental docstring misplacement
14:57gfredericksand it's not compatible with docstrings at all
14:57johnwalkerit looks nice
14:57technomancygfredericks: sure; I don't do that on nontrivial functions
14:58gfrederickstechnomancy: I'll allow it only if the whole function is one line
14:58technomancythat does bug me though... you have to choose between having documentation and looking tidy.
14:58gfredericksnothing untidy about args having their own line
14:58gfredericksmy opinions are more valid than yours
14:58technomancyit counts against your LOC
14:58gfrederickswhy on earth would you LOC
14:59johnwalkerwhy isn't it defn foo [] "docstring" like in elisp?
14:59technomancygfredericks: for Internet Points
14:59gfrederickstechnomancy: we should count tokens
14:59dbaschjohnwalker: I don’t know, but having defn foo “several lines of docstring
14:59dbasch“ and then [args] can be hard to read
14:59technomancygfredericks: I need to keep Leiningen under an order of magnitude less than sbt
14:59technomancyit's important!
14:59gfredericksI guess this is more of a linter issue eh?
14:59johnwalkerdbasch: agreed
15:00technomancygfredericks: clojure-mode will highlight docstrings same as comments
15:00technomancyso if you see a string that highlights as a string, it's not a docstring
15:00gfrederickstechnomancy: that does not happen for me
15:00dbaschfor that matter, (> x y) is always harder for me to read that (x > y)
15:01gfredericksdo 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:01technomancygfredericks: huh... it used to
15:01dbasch*than
15:01technomancydbasch: > is pronounced "descending"
15:01gfredericksand con> is of course "condescending"
15:01technomancydbasch: the problem isn't prefix notation; the problem is calling it "greater than"
15:02johnwalker(inc gfredericks)
15:02lazybot⇒ 68
15:02gfredericksI bet 75% of my karma comes from jokes
15:02technomancyclojurebot: 正名?
15:02clojurebotIf 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:02technomancydbasch: ^
15:02gfrederickstechnomancy: that first character means Internet Explorer I posit
15:03Frozenlockjohnwalker: I think it's because you can have functions with variable number of arguments
15:03gfredericksFrozenlock: good point
15:03dbaschso, is clojure correct or will we end up standing about in helpless confusion?
15:04technomancy,(doc >)
15:04clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."
15:04johnwalkerehh
15:04technomancyunfortunately clojure doesn't ship with an IPA pronunciation guide =)
15:04johnwalkerwhat do variable number args have to do with it?
15:04Frozenlockjohnwalker: https://www.refheap.com/86637 Where would you put the docsctring otherwise?
15:04johnwalkeroh, i see what you mean now
15:04johnwalkeryeah thats a really good point
15:04benkaygfredericks: it appears that midje-mode wants nothing to do with selecting only clojure.test tests.
15:05technomancy,(alter-var-root #'> assoc :pronunciation "dɪˈsɛndiŋɡ")
15:05clojurebot#<ClassCastException java.lang.ClassCastException: clojure.core$_GT_ cannot be cast to clojure.lang.Associative>
15:06technomancy,(alter-meta #'> assoc :pronunciation "dɪˈsɛndiŋɡ")
15:06clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: alter-meta in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:06technomancy,(alter-meta! #'> assoc :pronunciation "dɪˈsɛndiŋɡ")
15:06clojurebot{:added "1.0", :ns #<Namespace clojure.core>, :name >, :file "clojure/core.clj", :inline-arities #{2}, ...}
15:06technomancythird time's the charm
15:06gfredericksclojurebot: the third time?
15:07clojurebotPardon?
15:07gfredericksclojurebot: the third time is the charm
15:07clojurebotOk.
15:07gfredericksclojurebot: the charm?
15:07clojurebotNo entiendo
15:08justin_smithclojurebot: the third time?
15:08clojurebotthe third time is the charm
15:09umpajustin_smith: why does this not work ? (reduce (assoc {} ks (filter (contains? (set ls) ks) ls)) {} ks)
15:10justin_smithreduce takes a function as the first argument
15:10benkay"tests?Note: Fixtures and test-ns-hook are mutually incompatible. If you
15:10benkayare using test-ns-hook, fixture functions will *never* be run."
15:10benkayso...
15:11benkaynow i guess i feel like an idiot for using clojure.test.
15:14benkaywell fml.
15:14benkayi guess i need to refactor my test suite to use a different test runner to refactor my app.
15:15FrozenlockI've only ever used clojure.test. Is it worth taking the time to look at other tools?
15:16benkaywell i can't specify a single test to run so i guess the answer is a resounding "yes"
15:16gfrederickswhat's up with test-ns-hook? midje uses it?
15:16benkaygotta 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:16benkaytest-ns-hook is a hook for specifying which tests to run. it ignores fixtures.
15:17gfredericksyes but why are you using it?
15:17justin_smithI think the problem is trying to use clojure.test and midge at the same time - they are different and incompatible test runners
15:17benkayso that i can focus on one failing test at a time, gfredericks.
15:17Raynesbenkay: lein test :only your.test.ns/your-test
15:17benkayjustin_smith: midje is capable of running clojure tests.
15:18justin_smithbenkay: but as we've learned, the test runners are incompatible
15:18gfredericksbenkay: does the tactic Raynes just mentioned not work?
15:19RaynesI sure hope it does.
15:19RaynesI wrote it specifically to do this exact thing. :(
15:19Raynes(run individual tests with fixtures)
15:19justin_smithbenkay: 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:20benkaygfredericks: i'm working on it. now i have to endure the jvm startup for each run of...one test.
15:20gfredericksdoesn't clojure 1.6 have a function for this too?
15:20gfredericksRaynes and I tag-teamed on it
15:20Raynesgfredericks: Yes.
15:20RaynesWe wrote test-vars.
15:20RaynesAlso to do this exact thing.
15:21RaynesWe've got so many things to do this thing, man.
15:21Raynes:P
15:21gfrederickshopefully clojure-test-mode does that, but who knows
15:22benkayjustin_smith: that's probably what i'll end up doing.
15:23benkayalthough quite frankly i'm now contemplating refactoring everything into midje facts.
15:25FrozenlockPlease tell me someone made a function to english-capitalize-title strings...
15:25gfredericksto do what?
15:26FrozenlockCapitalize words in a title. You know, only 'some' words.
15:26gfrederickslike ignoring minor words?
15:27FrozenlockYes.
15:27gfredericksI cannot tell you whether someone made such a function
15:27justin_smith,(clojure.string/join " " (map clojure.string/capitalize (clojure.string/split "this is the title of my hit movie" #" ")))
15:27clojurebot"This Is The Title Of My Hit Movie"
15:27gfredericks,(def title "this is the title of my hit movie")
15:27justin_smithplus a blacklist of articles and such I guess
15:27clojurebot#'sandbox/title
15:28gfredericks,(def minor-words #{"is" "the" "of" "my"})
15:28clojurebot#'sandbox/minor-words
15:28Frozenlockhttp://english.stackexchange.com/a/34 :-(
15:28FrozenlockI should just write everything in uppercase.
15:28FrozenlockTHIS WAY I CAN'T MAKE A MISTAKE.
15:29kelseygiit’d be a dang bazooka to hit a fly, but you could use https://github.com/eandrejko/clj-tokenizer
15:29gfredericks,(defn titlecap [s] (->> (clojure.string/split s #" ") (map #(cond-> % (not (minor-words %)) (clojure.string/capitalize))) (clojure.string/join " ")))
15:29clojurebot#'sandbox/titlecap
15:29gfredericks(titlecap title)
15:29gfredericks,(titlecap title)
15:29clojurebot"This is the Title of my Hit Movie"
15:29justin_smithIN A WORLD WHERE THE CLOJURE LIBRARIES LACK NATURAL LANGUAGE PROCESSING SUPPORT, FROZENLOCK MUST RESORT TO EXTREME MEASURES... TO WRITE HIS CODE
15:30kelseygithere’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:30justin_smiththough you could likely fake it with gfredericks' approach (good luck detecting infinitives to get the "to"
15:30justin_smith rule right)
15:31gfredericksclojurebot: you |could likely fake it| with gfredericks' approach
15:31clojurebotRoger.
16:00amalloygfredericks: is "my" a minor word for title casing? i would have guessed not
16:01gfredericksamalloy: I haven't been speaking english as long as you have
16:03amalloyreally?
16:03gfredericksI'm the youngest person in this channel excepting Raynes
16:03RaynesAre you certain?
16:03Raynesarrdem is pretty young.
16:03gfredericksI'm young so of course I'm certain
16:03Bronsame too
16:03BronsaI'm between arrdem and Raynes
16:03amalloyhow do you even know how long i've been speaking english though? i could be a well-spoken russian import
16:04arrdemRaynes: older than you, whippersnapper
16:04amalloyBronsa: we don't need to hear about your fantasies
16:04gfredericksI'm young so I make all sorts of assumptions about other people
16:04arrdem(inc amalloy)
16:04lazybot⇒ 129
16:04technomancyOVARFLOW
16:04Jarda,amalloy
16:04clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: amalloy in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:04Jarda:(
16:05RaynesIt's not really executing that code :P
16:05gfredericksin complete overhonest frankness I am yes probably rather older than all of the college kids hanging around
16:05RaynesIt's a well crafted illusion.
16:05technomancyI'll grant well-crafted when you can juxt it =)
16:05justin_smith$karma Jarda
16:05lazybotJarda has karma 0.
16:06justin_smith((juxt inc dec) technomancy) ; standard response to a laughably bad joke
16:06Bronsaamalloy: I don't even know how to reply to that
16:06arrdem(let [arrdem 21.3 Raynes 20 Bronsa (fresh)] (run (x) (< Bronsa arrdem) (> Bronsa Raynes)))
16:07arrdem,(/ 1.0 365)
16:07clojureboteval service is offline
16:07arrdemclojurebot is a steaming pile of fail
16:08Bronsathe last thing it evaluates before breaking is "amalloy". sure this proves he's all evil.
16:08arrdemBronsa: WE DO NOT SPEAK THE NAME
16:09RaynesOn June 15, 2014, Alan Malloy made Bronsa speechless.
16:09justin_smitharrdem: cool trick is (/ 365.0) does the same thing
16:09arrdemjustin_smith: yeah, I have mixed feelings about the implicit 1
16:09justin_smithmultiple arity is so fun
16:10justin_smitharrdem: I mean what else would you want implicitly if / had one arg? taking an inverse is pretty basic
16:11arrdemjustin_smith: I'd accept a type or arity error
16:11arrdem,(doc /)
16:11clojureboteval service is offline
16:11arrdem##(doc /)
16:11lazybot⇒ "([x] [x y] [x y & more]); If no denominators are supplied, returns 1/numerator, else returns numerator divided by all of the denominators."
16:11arrdemat least it _is_ documented clearly.
16:12justin_smitharrdem: it's an old behavior, common among other lisps
16:12arrdemjustin_smith: yay tradition
16:13dbaschamalloy: pronouns are typically capitalized in titles
16:15justin_smithhlship 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:18dbaschjustin_smith: I’m guessing Rich Hickey must be around 50
16:19justin_smithdbasch: well, I was talking about on this channel
16:21dbasch(> 30 (apply max (filter #(knows-irl dbasch %) clojure-irc)))
16:39technomancyanyone have last-minute issues to raise before lein 2.4.1 is released?
16:42gtraktechnomancy: Tom Cruise was in an action movie at 51 years of age.
16:43technomancyis this a bug report or a feature request
16:44RaynesIt's a glitch in the Matrix is what it is.
16:46arrdemgtrak: and Arnold is still doing them. next!
16:46gtrakwe should probably clear some caches somewhere to prevent further damage
16:47gtrakarrdem: he was _literally_ jumping around in robot suits killing things
16:47arrdemgtrak: that's Tony Stark's job
16:47dbaschtechnomancy: ship it!
16:48technomancydbasch: hokay
16:48gtrakRobert Downey Jr is only 49
16:48arrdemtechnomancy: send it
16:49arrdemclojure core's whitespace is a work of modern art...
16:52technomancyarrdem: http://nonadventures.com/2013/07/20/a-whiter-shade-of-fail/
16:52technomancyarrdem: aka M-x whitespace-mode
16:52arrdemtechnomancy: hehe
16:54arrdemtechnomancy: http://nonadventures.com/2013/08/17/wooly-bullied/ this is an awesome webcomic. thank you.
16:54technomancyarrdem: it is a gift
16:55justin_smith(inc palindromidary)
16:55lazybot⇒ 1
16:55justin_smith(inc palindromedary)
16:55lazybot⇒ 1
16:55justin_smith(it was spelled wrong the first time)
16:56metellus(dec palindromidary)
16:56lazybot⇒ 0
16:58technomancyhttp://nonadventures.com/2014/05/17/gravys-anatomy/
16:59umpa,(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:59clojurebot#'sandbox/nice
16:59umpa,(reduce (nice {} [8 2 6 0]) [8 2 6 0])
16:59clojurebot0
16:59umpajustin_smith: why does this happen ? Its something with the map
17:00justin_smithdoes (nice ...) return a function?
17:00justin_smithyou are still not using reduce properly
17:01umpa(nice {} [8 2 6 0])
17:01umpa,(nice {} [8 2 6 0])
17:01clojurebot{[8 2 6 0] ()}
17:01justin_smithso you don't get an error, because {... ...} is callable as a function
17:02justin_smithit just probably won't return anything you find interesting
17:03umpawhat kind of function does this return then ? (fn [m v] (assoc m v (filter #(contains? (set %) v) ls)))
17:03justin_smiththat is a function
17:03justin_smithand it returns an updated map
17:04justin_smiththat's why it is a valid first arg to reduce
17:05justin_smith,(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:05clojurebot{:b 1, :a 0}
17:06dbaschumpa: may I ask what you’re trying to do?
17:07justin_smithhe wants a map from elements to collections that contain those elements
17:08umpa^
17:09justin_smithumpa: you took two inputs to reduce, and threw them into one defn body for some reason
17:10justin_smithif you took that literal list off the end of "nice", nice could be the first arg to reduce
17:10justin_smithand then the list would be the last arg, the one you are reducing over
17:11umpadbasch: 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:11arrdemso I'm looking at this: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L5351
17:12arrdemthis being with-loading-context: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L5295
17:12arrdemis 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:15justin_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:15clojurebot{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:15justin_smithbut really those things should all be in one function, and bound in a let
17:21umpa,(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:21clojurebot#'sandbox/coll
17:22umpa(contains? (set coll) 0)
17:22umpa,(contains? (set coll) 0)
17:22clojurebotfalse
17:22justin_smith,(contains? (set coll) '(0 1 2))
17:22clojurebottrue
17:23umpa,(contains? (set coll) '(0))
17:23clojurebotfalse
17:23dbaschumpa: (set coll) is a set of triples, it’s not going to contain 0
17:23dbaschor not even triples, a set of sequences
17:24dbaschyou have nested sequences in there, are you trying to see if 0 is in any of your nested sequences?
17:25technomancyTimMc: hey
17:25technomancyTimMc: I think we have to revert the pom.properties change; it adds 300ms to lein startup time
17:26umpadbasch: ,(filter #(contains? (set %) [0]) coll)
17:26umpa,(filter #(contains? (set %) [0]) coll)
17:26clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: coll in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:26justin_smithumpa: filter takes each element of the coll one by one
17:27justin_smithumpa: that's why that code works
17:27dbaschumpa: where are you trying to find 0? what would be your desired output?
17:27justin_smithexcept you want 0, not [0]
17:27justin_smithdbasch: see my paste above (do (def coll ...))
17:27justin_smiththat does what he wants, he is just figuring out how it works
17:29umpa^ debugging justin_smith's code
17:29justin_smithdebugging? it has no bugs!
17:30justin_smiththough it could be omptimized better
17:31umpajustin_smith: debugging understanding
17:32umpadbasch: ((0 1 2)(0 4 7) ... etc
17:32justin_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:32justin_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:32clojurebot#'sandbox/coll
17:32justin_smith,(reduce (fn [m el] (reduce (fn [m e] (update-in m [e] (fnil conj []) el)) m el)) {} coll)
17:32clojurebot{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:32justin_smithbetter version
17:33justin_smiththough maybe not easier to read
17:33justin_smithoh wait, that gets all keys, not just the ones specified
17:35justin_smith,(def wanted #{0 2 4 6 8})
17:35clojurebot#'sandbox/wanted
17:35justin_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:35clojurebot{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:38umpajustin_smith: nice
17:40caternso many numbers aieee
17:57blaenkI'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:58blaenkat 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:58blaenkbut 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:59blaenkI'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:00blaenkwhat 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:01llasramblaenk: If I read the implementation correctly, a ref will maintain a history of values, but not necessarily a complete history
18:01justin_smithblaenk: cannot be provided while also being correct
18:01llasramblaenk: So one condition which can cause a restart is a sufficiently-old ref value not being available
18:01justin_smithblaenk: that's how the whole thing can be non-locking, by retrying if something else finalizes in the meantime
18:02justin_smithllasram: sufficiently-old ref value?
18:02blaenkso 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:03blaenkso this is basically saying that the deref is another such check for the transaction being correct?
18:03llasramblaenk, justin_smith: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LockingTransaction.java#L397-L422
18:03llasramblaenk: Note that if you're just learning Clojure, you can probably ignore refs
18:03llasramThe STM was a big exciting feature when Clojure was getting going, but I've never seen production code legitimately use refs
18:03blaenkthanks, but I'd prefer to learn them. I'm not too new to stm, I've done some of it in haskell
18:03blaenkah okay
18:04blaenkit's mainly that I was following along up to this point
18:04llasram(Not that they don't work as advertised -- just I haven't seen any code which actually needed them)
18:04justin_smithllasram: oh, shows how little I know about STM, thanks
18:05blaenkmy 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:05blaenk*changed mid-transaction by another transaction, then clearly that won't be correct, hence the retry
18:05justin_smithblaenk: I wonder if this may be related to functions like commute
18:05llasramExactly
18:06justin_smithwith commute, even if your order is off, your calculation can be correct, since the f is commutative
18:06blaenkright
18:06llasramFunction which don't update or only commute don't need the most recent value, just consistent values from all refs read
18:07blaenkand that's the case where maintaining a history would help that situation
18:07llasramExactly (is my understanding)
18:07blaenkthat'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:08blaenkI mean, why isn't a history of size 1 enough
18:08blaenkbecause it's talking about tuning the history size etc
18:08llasramOh, 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:09blaenkohhh it doesn't, ok
18:09blaenksomehow 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:09blaenk"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:09llasramThe Clojure compiler is about as dumb as you can get, but intentionally so as a design commitment to radical simplicity
18:09blaenkhttp://clojure.org/refs
18:10blaenkI understand
18:10blaenkI'm just not sure what that quote means then
18:10llasramYep. It's an illllusion. It uses tricks like maintaining history and restarting transactions to allow produce the effect described in that quote
18:10blaenkohhh okay
18:12blaenksince 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:12blaenkin some other way then, they just know that the ref's state has changed, and retry the transaction?
18:12blaenkor do they also run into the problem of not having enough history
18:13llasramblaenk: That I don't know off the top of my head. If you're really interested, I'd suggest digging into the implementation
18:13blaenkbecause 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:13blaenkalright, thanks
18:13llasramThe Compiler classes are unnecessarily hairy, but most of the core stuff like the STM is pretty approachable Java
18:13llasramOne day we will be self-hosting...
18:13llasram(inc Bronsa)
18:13lazybot⇒ 23
18:14blaenkthat'd be cool
18:14llasramYah. And Bronsa is working hard on the Clojure-in-Clojure implementation which will lead us to the promised land
18:14llasramNo pressure
18:15blaenkhaha
18:16_JokerDoom(inc Bronsa) -> 23?
18:17llasramkarma mechanism
18:17llasram$karma lazybot
18:17lazybotlazybot has karma 26.
18:17llasram(inc lazybot)
18:17lazybot⇒ 27
18:17llasram$karma lazybot
18:17lazybotlazybot has karma 27.
18:17_JokerDoomfun
18:17_JokerDoom$karma _JokerDoom
18:17lazybot_JokerDoom has karma 0.
18:17_JokerDoomlol
18:18justin_smithas is apropriate, the "inc" for karma has nothing to do with clojure's inc
18:18justin_smith(well, maybe half a thing to do with it)
18:18llasramI think of it as part of a macro-based DSL which just happens to use s-expressions
18:18justin_smithright
18:20blaenkllasram: would you happen to know which part of the code you linked has to do with alter?
18:21llasramblaenk: 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:21blaenkno worries, thanks
18:21blaenklooks like it delegates to doSet
18:28martinklepschI 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:31Raynes&(merge-with #(zipmap [:file :database] %&) {:a 1 :b 2} {:a 15 :b 16})
18:31lazybot⇒ {:a {:database 15, :file 1}, :b {:database 16, :file 2}}
18:32Raynesmartinklepsch: ^
18:33blaenkRaynes: what's that &() syntax?
18:33blaenkis it specific to lazybot?
18:33RaynesThat's not syntax.
18:33blaenkalright, what's that not-syntax
18:33RaynesThe & is the evaluation prefix for lazybot
18:33blaenkah thanks, figured
18:33RaynesIt wouldn't know what to evaluate otherwise.
18:33blaenkgot it
18:33caternwhy use lazybot over clojurebot?
18:33RaynesBecause I wrote one of them and not the other.
18:34caterngood reason
18:34RaynesEither one of them generally works fine.
18:34blaenkhe wrote clojurebot, is ashamed
18:34caternhaha
18:34Rayneslol
18:34Rayneslazybot can ##(println "also evaluate stuff in the middle of messages, which clojurebot cannot do")
18:34lazybot⇒ also evaluate stuff in the middle of messages, which clojurebot cannot do nil
18:35RaynesSo if you want to do that, that's an excellent reason to use lazybot.
18:36blaenknice
18:37nooniantesting #10 lazybot
18:37nooniantesting ##10 lazybot
18:37Raynesnoonian: Only matches ()
18:37RaynesYou'd be incredibly likely to set it off accidentally otherwise.
18:37RaynesBecause ##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:38noonianhmm, i had no idea
18:38justin_smithalso, there's ##:meta-hashtags
18:38justin_smithwhich are hashtags about hashtags
18:39Raynes##hashtag
18:41noonian#poundsign
18:42justin_smithI like ##:octothorpe
18:43mdeboardThis 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:44mdeboard(I'm asking about line 329-355)
18:44Rayneshttps://github.com/mattdeboard/ticket-to-ride/blob/master/src/ttr/board.clj#L329-L355
18:45mdeboardthanks
18:45Raynesmdeboard: shift click a second line number to highlight a section
18:45mdeboardgotcha, thanks
18:46mdeboardI really don't like the `(apply count (rest %))` bit
18:46mdeboard,(apply count (rest [:red [:red :red :red]]))
18:46clojurebot3
18:46mdeboardidk if that's idiomatic-enough
18:47justin_smith(filterv (fn [[k v]] (and (>= (count v) cost) (#{(name k) :gray} color))) (group-by identity @cards))
18:47justin_smithmaybe soemthing like that?
18:47mdeboardI 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:47justin_smithit's more concise, and unless I made a thinko has the same semantics
18:47mdeboardjustin_smith: well fortunately I have tests for this function, so I'll give it a whirl
18:47Raynes&(count (last [:red [:red :red :red]]))
18:47lazybot⇒ 3
18:48mdeboard,(rest [:a [:a :a :a]])
18:48clojurebot([:a :a :a])
18:48mdeboardaha
18:48mdeboardRaynes: nice, that's good too
18:48justin_smithoh, not fn [k v], fn [k & v]
18:48justin_smithoh, never mind, k v was right
18:48justin_smithbleh
18:49martinklepschRaynes, thanks that's working great and is nice and simple :)
18:49justin_smithI think bindings like k (for key) and v (for value) are more clear than first rest when mapping across a map
18:49mdeboardRaynes: thanks, that's working great and is nice and simple :(
18:49mdeboard:)*
18:49Rayneslol
18:50mdeboardjustin_smith: Oh right, I didn't notice that destructuring in yours
18:50mdeboardI like that muhc better too
18:50martinklepschRaynes, what does the %& do?
18:51justin_smithmartinklepsch: it is like [arg & rest] in a normal fn
18:51Raynesmartinklepsch: (fn [& args] (zipmap [:file :database] args))
18:51martinklepschjustin_smith, ah ok. thought so thanks!
18:51martinklepschhave a good day/night! cheers!
18:52mdeboardfedora*
18:52RaynesHe only likes me for my merge-withs
18:53mdeboardbtw if anyone here is going to Austin Clojure meetup tomorrow, I'm gonna head up there
18:53mdeboard(I'm on a trip here atm)
18:55mdeboardjustin_smith: To use `fn [k v]` I'd have to call `apply` first
18:55mdeboardoh maybe it's `fn [[k v]]` ?
18:55Raynesmdeboard: I totally would have done (map (partial hash-map :name) ["Atlanta" "Boston" ...])
18:55justin_smithmdeboard: why apply? I did have it as fn [[k v]] right?
18:55RaynesBecause it would have made me feel lazier.
18:55mdeboardjustin_smith: Oh, if you did I misread, sorry
18:56xeqidevn: losingkeys = bendyworks person?
18:56RaynesAlso holy God did you associate a ref with every one of these
18:56Raynesmdeboard: plz no
18:56mdeboardevery one of what
18:56Raynesedges
18:56RaynesEvery edge has a ref
18:56mdeboardya
18:56mdeboarddon't hurt my feelings
18:58Raynesmdeboard: In these kinds of situations, usually you want one ref/atom holding all state rather than one for every single piece of state.
18:58RaynesIt's generally better to have as little state as possible.
18:58RaynesAlso, you don't seem to be using the features of refs that warrant their usage.
18:58Raynesatoms would suffice here as far as I can tell
18:59mdeboardYeah, probably, not updating several in a single transaction
18:59mdeboardnot now, anyway
18:59RaynesUnless you need to do coordinated updates of more than one ref inside of transactions, not very useful.
18:59RaynesAnd if you only have one atom instead of a billion refs, it'll never be necessary! :p
19:00mdeboardbut 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:01mdeboarde.g. https://github.com/mattdeboard/ticket-to-ride/blob/master/src/ttr/cards.clj#L94-L125
19:02mdeboardso 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:03RaynesHow about not using atoms *or* refs! :D
19:03RaynesJust pass state from function to function.
19:03RaynesPurely functional ticket to ride
19:03RaynesYou can write your own ticket, mdeboard.
19:04mdeboardbecause 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:04mdeboardand 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:05mdeboardna'mean
19:06RaynesI refuse to accept your excuses.
19:06Raynesoff*
19:06noonian+1 million on the purely functional implementation
19:07kelseygiirc commands: not mutate-able!
19:13mdeboardRaynes: pull requests gladly accepted btw
19:13RaynesI've never played ticket to ride nor do I have the foggiest clue how it is played.
19:14mdeboardOh, well, you're missing out.
19:14RaynesI'm certain
19:18justin_smithmdeboard: what Raynes describes with passing state is a code stability / design optimization
19:18justin_smithin other words, its something that pays off most if you do it from the beginning
19:18justin_smithand the longer you wait to switch to the technique, the more you pay for it
19:19justin_smith(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:19mdeboardI se
19:19mdeboarde
19:20mdeboardI've never actually done anything with games or anything, I just have always understood them to require a lot of state
19:20mdeboardI'm definitely forcing some OOP concepts into this design
19:20mdeboardbut trying to keep it in check wihtout sacrificing gtd
19:20justin_smithmdeboard: passing an arg can provably do anything state can (plus things state can't do easily)
19:21mdeboardCan you give an example? I have trouble modeling this in my head
19:21mdeboardespecially in a "loop" like a game
19:21justin_smithwell, loop creates a binding, and recur passes a binding
19:22justin_smithso when you recur, you pass in the updated "state of the world", which is actually an immutible object
19:22mdeboardorite
19:22mdeboardI see, I see
19:22justin_smithall "modifications of state", are new versions of the state of the world (usually efficient, because we are using persistent data structures)
19:22noonianright, instead of modifying the contents of the deck you could write a function that takes a deck and returns a different deck
19:22mdeboardYeah that was enough for a light bulb to come on
19:23justin_smithright
19:23mdeboardright
19:23mdeboardright
19:23mdeboardAnyway, I understand. I may revisit that once I figure out the thing I'm trying to solve now
19:23justin_smithadvantages including the fact that you can save and restore and replay games trivially
19:24justin_smithsince it is right there in one immutible thing already, why not fork it if you want to play things out multiple directions
19:24justin_smithplaying the game in reverse, etc. etc.
19:25justin_smiththings that are very hard in the mutable version become trivial in this one
19:26mdeboardjustin_smith: Interesting
19:26mdeboardvery interesting
19:26mdeboardThat gets at an annoying issue I have had to deal with in tests :P
19:27mdeboardjustin_smith: line 16, 28, 40
19:27mdeboardresetting state
19:27mdeboardIt's one of those deals wher eyou know it's dumb
19:27mdeboardlike as you're typing it
19:30mdeboardI 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:30justin_smithalso, add a constrained tree search on moves with simulated opponent moves, and you get an ai for playing the game
19:30mdeboardYeah AI is the second thing I'm working on
19:31justin_smithyeah, another bonus of the "state" just being a function argument is that suddenly testing is much easier
19:31justin_smithright, 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:43umpathis filter (filter #(contains? (set %) [0 1) ((1 2 3)(4 5 6))) why you no work ?
19:44llasramumpa: Well, syntax errors at least
19:44RaynesWell, that's not valid Clojure for starters.
19:45technomancy(1 2 3) is not a function you can call
19:45umpa,(filter #(contains? (set %) [0 1]) ((1 2 3)(4 5 6)))
19:45clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
19:45justin_smithalso the nesting is off
19:46umpa,(filter #(contains? (set %) [0 1]) '((1 2 3)(4 5 6)))
19:46clojurebot()
19:46justin_smithand you probably want to test intersection rather than membership
19:46llasramumpa: What do you expect to happen here?
19:46justin_smithI think he wants to filter the lists that contain a 0 or 1
19:46llasramOk...
19:47umpa^
19:47llasramumpa: `contains?`'s second argument is a single value
19:47llasramSo ##(contains? #{[0 1]} [0 1])
19:47lazybot⇒ true
19:47llasramBut not ##(contains? #{0 1} [0 1])
19:47lazybot⇒ false
19:49justin_smith,(do (require '[clojure.set :as s]) (filter #(s/intersection #{0 1} (set %)) '((1 2 3) (4 5 6) (0 1 2))))
19:49clojurebot((1 2 3) (4 5 6) (0 1 2))
19:49llasram,(filter (partial some #{0 1}) '((1 2 3) (4 5 6)))
19:49justin_smitherr
19:49clojurebot((1 2 3))
19:50justin_smiththat's a good way to do it
19:51umpajustin_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:51lazybot⇒ {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:51justin_smithoh yeah, empty sets are truthy
19:52justin_smithbecause that was reducing across individual elements
19:52umpa(doc truthy)
19:52clojurebotNo entiendo
19:53justin_smithumpa: http://blog.jayfields.com/2011/02/clojure-truthy-and-falsey.html
19:54mdeboardugh now all I see is how OO I made this
19:54mdeboardTHANKS
19:54mdeboardI'm disgusted with myself
19:54mdeboardIt's like the Garden of Eden
19:54justin_smithumpa: because of other lisps, I sometimes lapse and expect empty things to act as false. It's a bad habit
19:54mdeboardI realize I'm naked, and I'm ashamed
19:54justin_smithmdeboard: hah
19:57benkaydoes anyone else have problems with running 2 repls in 2 projects at the same time?
19:57benkayusing cider
19:57mdeboardbenkay: I don't do that, as a rule. I had trouble with nrepl back in the day
19:58mdeboardrunning 2 repls
19:58mdeboardi don't remember what it entailed
19:58benkaybuuuh
19:58justin_smithbenkay: 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:58justin_smiththis is one of those things where jacking in just makes it more complex
19:58benkayah yes, i suppose it's worth mentioning i'm working from emacs.
19:58benkay*sigh*
19:59justin_smithbenkay: this is from emacs, just using nrepl.el
19:59benkayso the answer to "can i use code navigation on two projects at once?" is "no"?
19:59justin_smithcider.el should be similar
19:59benkayjustin_smith: neat. that's a protip for sure.
19:59mdeboardjustin_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:00benkaydoes nrepl (and hopefully cider, but i know you don't know) then pin the relevant connection to the relevant projects?
20:00justin_smithalso, if you haven't tried it, try "C-u M-x cider-jack-in" to start your second repl
20:00mdeboardOr C-c M-j
20:00justin_smithmdeboard: can't player specific state be a key under the state object?
20:00mdeboard(by default, anyway)
20:00umpa##(def x nil)
20:00lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
20:01umpa,(def x nil)
20:01clojurebot#'sandbox/x
20:01umpa(false? x)
20:01umpa,(false? x)
20:01clojurebotfalse
20:01mdeboardjustin_smith: It can, I just am having a tough time conceptually :P
20:01llasramumpa: only `false` is `false?`. `nil` is false-y
20:01llasram,(boolean nil)
20:01clojurebotfalse
20:01benkayjustin_smith: yeah, cider gets confused when i jack in to two separate projects.
20:02llasram,(false? (boolean nil))
20:02clojurebottrue
20:02justin_smithwell that sucks! nrepl handles it OK if I start the projects via lein repl and connect to that, at least
20:02llasrambenkay: cider 0.5.0 is fine with multiple projects
20:02benkaygrrrrrrrrr clojure startup time has ruined my weekend
20:02llasramat least in my experience
20:03llasrambenkay: how so?
20:03umpa,(def x false)
20:03clojurebot#'sandbox/x
20:03benkayhm llasram how do i check a package version in emacs? list packages?
20:03llasrambenkay: ya
20:03umpa,(false? x)
20:03clojurebottrue
20:04benkayllasram: i've been doing a bunch of refactoring and having to restart the jvm proc and clojure with it is murdering my productivity.
20:04benkayimplementing a reloaded workflow on something that was never meant to have one...
20:04umpajustin_smith: how does truthy apply to the filter ?
20:05mdeboardI guess https://gist.github.com/mattdeboard/c8b163b88152f2d3fb1f ? idk captain
20:05justin_smithumpa: because I wrongly expected an empty intersection of sets to act as a false value
20:05justin_smithwrapping it in seq fixes it though (that generates nil for an empty set)
20:05justin_smith,(do (require '[clojure.set :as s]) (filter #(seq (s/intersection #{0 1} (set %))) '((1 2 3) (4 5 6) (0 1 2))))
20:05clojurebot((1 2 3) (0 1 2))
20:05llasrambenkay: What are you refactoring that's requiring restarts?
20:06benkaysilly little webapp.
20:06justin_smithhe's moving things between clojure.test and midge, iirc
20:06benkayno, i straight up gave up on midje.
20:06llasramHmm. Still shouldn't be necessary to restart
20:06llasramYou can just kill namespaces and reload them
20:06justin_smithbenkay: good plan, imho
20:06llasramagreed
20:07mdeboardwhy so
20:07mdeboardtoo fat?
20:07benkayllasram: definitely in the workflow, and yet i keep getting SLIMEd.
20:08llasrammdeboard: 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:08llasrambenkay: Not quite following
20:08benkayhttps://github.com/clojure-emacs/cider-nrepl // build: failing
20:08benkayyay tooling
20:09justin_smithmdeboard: 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:09mdeboardI see
20:10benkayby the way, i also completely failed at running individual tests with clojure.test
20:10benkay(run-test 'my-test-ns/test-i-want-run-dammit) just returns nil
20:10justin_smithdoes it print anything?
20:11benkaylol nil
20:11Raynesbenkay: What version of clojure are you using?
20:12benkayRaynes: 1.5.1
20:12Raynesbenkay: Any reason you can't use 1.6.0?
20:13benkayaside from being *-deep in a refactor that's consuming my life already?
20:13Raynesbenkay: https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/test-vars
20:13Raynestest-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:14benkayah yes, i did actually mean test-var, apologies.
20:14benkay(test-var 'my-test-ns/test-...)
20:15benkayholy heck does test-var not use fixtures?
20:15mdeboardI reckon the simplest refactor here would be to take the state off the edges/routes and just associate that state with the player
20:16llasrambenkay: Fixures only applying when running the tests for an entire namespace are standing issue with clojure.test
20:16Raynesbenkay: I suppose it doesn't, which I imagine is in fact the reason I added test-vars.
20:16llasramI 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:16RaynesIt isn't a standing issue because test-vars exists now.
20:16llasramah
20:17RaynesBut prior to 1.6.0, it was indeed an issue.
20:17llasramI missed that
20:17benkayRaynes: thou art a scholar
20:17llasramObvs didn't read the changelog closely enough :-)
20:17Rayneshttps://github.com/clojure/clojure/blob/919a7100ddf327d73bc2d50d9ee1411d4a0e8921/src/clj/clojure/test.clj#L710
20:17technomancyRaynes actually succeeded in getting a commit applied to clojure.test
20:17technomancyclearly he is the chosen one of the prophecy
20:17RaynesI'm pretty sure it took over a year.
20:17Rayneslol
20:17RaynesA year + gfredericks.
20:18llasramI probably saw the entry, but my mind elided it because it was obviously impossible
20:18technomancysome interpretations of the prophecy mention the chosen two
20:19RaynesI don't think 1.6 had actual breaking changes over 1.5.1, did it?
20:19RaynesI've been knee deep in Python for like 5 months though, so I could be wrong.
20:20taliosI don't believe it do.
20:20llasramThe hash changes lead to requiring updates of some Clojure-aware collection libraries
20:20llasramBut I think that's it
20:22benkaywell thanks, all.
20:25Raynesbenkay: 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:25benkayi now have an entirely different set of errors from my tests to look over, so i guess that's progress...
20:25benkaynot at all, Raynes! and as a matter of fact thanks for your work on that.
20:25benkayi feel like a complete and total moron for having seen test-var and not test-vars
20:27mdeboardlol
20:28gfredericksbenkay: that's a mistake a regular person would make, not a complete and total moron
20:28mdeboardbenkay: 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:28RaynesYeah, it's not like you're gfredericks or anything
20:28clojurebotIt's greek to me.
20:28Raynes<3
20:28Raynesjk ily gf
20:28gfrederickslol
20:29benkayi am extremely tempted to throw everything out and upgrade to 1.6.0 just for test-vars, actually.
20:30gfredericksclojurebot: test-vars is the killer app of clojure 1.6.0
20:30clojurebotc'est bon!
20:30benkayRaynes: does test-vars work as a ns-hook?
20:30RaynesI've never really used much in the way of fancy testing hooksy thingies.
20:31RaynesBut all test-vars does is look up metadata on namespaces to get fixtures.
20:31RaynesSo as long as it can do that, it should work anywhere.
20:32gfredericksDear Randall Munroe: what would happen if you actually crossed every crossable thing?
20:32benkaylol okay 1.6 great looking fine but where'd the output from clojure test mode go
20:32benkaywaaah
20:34gfrederickswhat would it take to start using maven for emacs packages
20:34mdeboard...
20:34johnwalkerdon't
20:34clojurebotexcusez-moi
20:34mdeboardwhat.
20:34johnwalkerplease don't
20:34mdeboardsrs
20:35johnwalkerfor your sake
20:35gfredericksmy sake is already ragged from being on the bleeding edge all the time
20:35johnwalkerbleeding edge 6 years ago?
20:35johnwalkercome on man, you gotta do grails for emacs packages
20:36gfredericksI mean the normal emacs package manager
20:36gfrederickswhich only gives you the latest of everything
20:36johnwalkeroh
20:36johnwalkerwell there's marmalade stable
20:37johnwalkererr, melpa stable
20:53umpa,coll
20:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: coll in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:54umpa,col
20:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: col in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:54mdeboardumpa: coll just means collection
20:55umpa,(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:55clojurebot#'sandbox/col
20:55umpa,(def ks [8 2 6 0])
20:55clojurebot#'sandbox/ks
20:56umpa,((fn [ks ls] (reduce (fn [m v] (assoc m v (filter #(set/intersection (set %) (set v)) ls))) {} ks)) ks col)
20:56clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
20:56umpathis is not working
20:56akhudekclojure.set
20:57umpa,(require 'clojure.set :as set)
20:57clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>
20:57akhudekjust use it directly
20:57umpa,(require 'clojure.set as set)
20:57clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: as in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:57akhudek(clojure.set/intersection … )
20:57umpa,((fn [ks ls] (reduce (fn [m v] (assoc m v (filter #(clojure.set/intersection (set %) (set v)) ls))) {} ks)) ks col)
20:57clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:03umpaisn't reduce suppose to take values from coll and ks one by one and apply the filter
21:07technomancygfredericks: nix for emacs packages makes like seventeen times more sense
21:07technomancyerr--guix rather
21:08gfrederickstechnomancy: hokay hokay I'll go for that
21:08gfredericksI just don't know it as good
21:09technomancyit's worth getting to know
21:09gfredericksoh I use it for at least half of my junk
21:35technomancyguix or nix?
21:35RaynesBoth
21:48gfrederickstechnomancy: nix
21:48gfredericksI have no idea what guix is
21:48gfredericksso I probably shouldn't have responded so confidently
21:51justin_smithgfredericks: wait, do you actually use nixos?
21:55RaynesSomebody has to
21:56justin_smithit looks interesting
21:56RaynesSo does space travel, but I ain't looking to go to Mars any time soon.
21:59justin_smithfunny, that does sound like what an experimental Linux distro would do
22:00johnwalkerdo you like nixos?
22:08dpathakjthere’s nix, the package manager, and nixos, the linux distribution
22:08dpathakjseems like you could get away with one without the ohter
22:10technomancyyeah, nix works great on debian
22:11technomancygfredericks: guix is nix without the weird one-off package language; it uses guile instead
22:11technomancyand it also actually has standards for licensing instead of just accepting any random shit
22:15gfredericksjustin_smith: no just the package manager
22:15gfrederickstechnomancy: "is nix" meaning it's part of their ecosystem or it just instantiated the core concepts in some other way?
22:16technomancygfredericks: it's compatible with the same package sources and shares a good deal of code
22:16gfredericksdoesn't sound absolutely terrible so far
22:16technomancyafaict it's like a new language that compiles to the same runtime, like clojure
22:16gfredericksmetaphors how do they work
22:16technomancybut nix is already pretty obscure, and the guix community is smaller still
22:17technomancyanyway, 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:17technomancy(modulo lein/emacs obvs)
22:17gfredericksI should stick to popular software communities like clojure
22:17technomancyclojure is "mature"
22:19dpathakjtechnomancy: 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:19technomancydpathakj: it's libre licenses only
22:20technomancydpathakj: it just bans crazy stuff like the adobe flash player, which I was dismayed to learn that nix ships, apparently illegally
22:20technomancyiirc it's basically limited to dfsg-free plus gfdl
22:24dpathakjtechnomancy: thanks. makes sense.
22:25johnwalkertechnomancy: do you use a gnu distribution now?
22:26johnwalkerit sounds like you use debian
22:32mdeboardjustin_smith, Raynes: Well I hope you're happy.
22:32RaynesIn general, yes.
22:32justin_smithmdeboard: things are pretty peachy
22:33mdeboardI've been refactoring for "pure functional" blah blah blah
22:33justin_smithso you made the switch to an explicit game state object passed between functions?
22:33mdeboardLucky for you I wrote things in such a manner that it makes such refactoring straightforward
22:33justin_smithlucky for me
22:33mdeboardLUCKILY
22:34mdeboardYou've squeaked by, by the skin of your teeth.
22:34taliosmdeboard - are you doing any form of clojure based monad foo there as part of being pure?
22:34mdeboardtalios: All I know about monads is that they're like astronauts eating a burrito
22:34gfredericks~monad
22:34clojurebotmonad is monads
22:34gfredericks~monads
22:34clojurebotmonads are #=(str "super" "awesome")
22:35gfredericksSupera Wes o' Me
22:36justin_smithtalios: 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:36mdeboard(defer)
22:37justin_smithor maybe the usage of delays or something
22:37justin_smithyeah
22:37mdeboard(force)
22:37mdeboard:o
22:37justin_smithoh yuck
22:37mdeboard(defn chastity-belt (conj force defer))
22:37mdeboardthrow a [] in there
22:37taliosforce sounds rapey
22:37justin_smithfits with the whole "promise keepers" thing I guess
22:37mdeboardhahaa
22:37mdeboardnice
22:37mdeboard@ promise keeper
22:38technomancyjohnwalker: yeah, I'm on debian
22:39gws,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac m1)
22:39clojurebot#'sandbox/m1
22:40gws,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"})
22:40clojurebot#'sandbox/m1
22:40gwsso that's not gonna work in IRC, but can anyone tell me why the first one prints nil and the second prints "v"?
22:41justin_smith(do ,(def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"}))
22:41justin_smith,(do (def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac {:k "v"}))
22:41clojurebotv\n
22:41gwsha, thanks
22:42gws,(do (def m1 {:k "v"}) (defmacro mac [{v :k}] `(println ~v)) (mac m1))
22:42clojurebotnil\n
22:42gwsi'm trying to wrap my head around the difference there
22:43gfredericks,(let [{v :k} 'm1] ["My v is" v])
22:43clojurebot["My v is" nil]
22:43dbaschgws: macroexpand-1
22:43johnwalkertechnomancy: cool
22:45amalloygws: remember that a macro receives unevaluated symbols as its arguments
22:45amalloynot the values to which those symbols may be bound in some particular evaluation context
22:47gwsah, alright. i see it now
22:49gwsdbasch: i had that, but I was missing was the "why" - unevaluated symbols made it click
22:50gwsamalloy: thanks, i appreciate it
23:58kelseygihey i’ve got a string
23:58kelseygi& i need to split it on a separator
23:58mdeboardnice
23:58lazybotjava.lang.RuntimeException: Unable to resolve symbol: i in this context
23:58kelseygibut i need to do something different with the last substring depending on whether it ended in the separator or not
23:58kelseygieverything i can think of is super imperative-y
23:59mdeboard,(clojure.string/split "a,b,c,d," #",")
23:59clojurebot["a" "b" "c" "d"]
23:59mdeboard?
23:59kelseygi,(clojure.string/split "a,b,c,d" #",")
23:59clojurebot["a" "b" "c" "d"]
23:59kelseygii wanna be able to tell the diff between those two