#clojure logs

2015-08-12

01:09justin_smithemperorcezar: not much, and typically questions here will get a quicker response
01:10justin_smithemperorcezar: I think you can turn off structural editing to fix your cursive problem
01:10justin_smith(temporarily turn it off)
01:10justin_smithor paste the paren you need (though entering a paren manually doesn't work as expected, cut/copy/paste should not be effected)
03:58luxbockI'd like to have one namespace for my schema definitions that every other namespace requires
03:58luxbockbut some of those schemas build up on things defined in other namespaces, which wouldn't be a problem if they were just depending on the schemas themselves
03:59justin_smithluxbock: can a schema specify that a field must be a collection implementing some protocol? if so you could define the protocols alongside the schemas, then make sure the collections implement the right protocols
03:59luxbockbut now I have a record in namespace foobar.x, which I'd like to use as a component of another schema definition in my foobar.schemas namespace
04:00luxbockjustin_smith: not sure I follow
04:01luxbockI'm basically trying to get around circular namespace dependencies, but I'm not sure if it's possible
04:01justin_smithluxbock: instead of specifying concrete record types, you could hypothetically specify that a given field must be a record implementing some protocol, the protocol could be defined in the same file with the schemas
04:01justin_smithluxbock: yes, and protocols are a great way to fix circular namespace dependencies
04:01luxbockjustin_smith: ah I see, yeah that's an interesting approach
04:02luxbockyeah I'll give that a try, thanks
04:04luxbockI forgot that in this case I wasn't actually using a record but potemkin/def-map-type
04:05luxbockperhaps I should just get rid of it
04:05luxbockif I can remember why I was using it in the first place
04:18Olajyd Given a string: ”12/34/900" I want to write a function that uses a Delimiter of "/" would return "900”.? any ideas
04:19Kauko-(fn [str] "900") :^D
04:20perplexaOlajyd: https://clojuredocs.org/clojure.string/split
04:20hyPiRionyeah, just do last on a split
04:20perplexayeah last or nth
04:22Kauko-(defn foo [mystring] (last (clojure.string/split mystring #"/")))
04:24Olajydthanks Kauko
04:28perplexa¬_¬
04:51TEttingerOlajyd: re-seq is also handy for this. ##(last (re-seq #"[^/]+" "12/34/900"))
04:51lazybot⇒ "900"
04:59oddcullyor if you ever craved more java interop: ,(let [s "12/34/900" ofs (.lastIndexOf s "/")] (subs s (inc ofs)))
05:29pydave6377What do I need in .gitignore for a Leiningen 'app' project?
05:29PupenoI have an empty route table with compojure and it’s still able to server static files from public. Any ideas why?
05:29pydave6377Ignore that - I just saw it generates one for me!
08:58CookedGryphonI'm trying to write a test for a patch I'm submitting to clojure core, for not running static initialisers at aot compile time... Any ideas how to write that test? Should I be calling compile on a file? Eval on a quoted form?
08:58CookedGryphonwhat's actually going to test this
09:00justin_smithCookedGryphon: compile-file on some file
09:02CookedGryphonI get an ioexception no such file or directory when doing that
09:03CookedGryphonI wonder if the *compile-path* has been lost at this point...
09:28justin_smith(doc compile-file)
09:28clojurebotIt's greek to me.
09:29justin_smithCookedGryphon: oh, my bad, you can just use compile, and provide a namespace symbol as the argument
09:29justin_smithCookedGryphon: http://clojure.org/compilation
09:37CookedGryphonYeah, that's not working for me in the context of the clojure tests...
09:37CookedGryphonnot sure why
09:43CookedGryphonaleoh
09:44CookedGryphonoh* turns out my test was working, and failing, and now I fixed it
09:56wes_ellis Does anyone use JavaFX for GUIs?
10:53dumptruckmananyone else using nightcode notice that it does not change the font color of most function names?
10:53dumptruckmanit only seems to do it for a select few from the core
11:08Olajydcan I implement a substring function that will do this (subs “clojure” -1 4) to give something like “jur”
11:13vijaykiranOlajyd: yes, you can :)
11:21Olajydhow do i go about implementing a substring function that will do this (subs “clojure” -1 4) to give something like “jur”?
11:22pbxOlajyd, what have you tried?
11:32justin_smithOlajyd: it should be easy if you know how to use let, count, and subs
11:35gfredericks`,(defrecord Heyo [x])
11:35clojurebotsandbox.Heyo
11:35gfredericks`,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.MapEntry x) [(str (key x)) (val x)] x)) x))
11:35clojurebot#error {\n :cause "clojure.walk"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.walk, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.walk"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [...
11:35gfredericks`(require 'clojure.walk)
11:36gfredericks`,(require 'clojure.walk)
11:36clojurebotnil
11:36gfredericks`,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.MapEntry x) [(str (key x)) (val x)] x)) x))
11:36clojurebot#'sandbox/stringify-keys
11:36gfredericks`,(stringify-keys (map->Heyo {:x 42}))
11:36clojurebot#sandbox.Heyo{:x 42}
11:36gfredericks`,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.IMapEntry x) [(str (key x)) (val x)] x)) x))
11:36clojurebot#'sandbox/stringify-keys
11:36gfredericks`,(stringify-keys (map->Heyo {:x 42}))
11:36clojurebot#sandbox.Heyo{:x 42, ":x" 42}
11:36gfredericks`^ am I misunderstanding how prewalk works or does that look like a bug?
11:37gfredericks`maybe a better example is when it's not a basis key
11:37gfredericks`,(defrecord NoKeys [])
11:37clojurebotsandbox.NoKeys
11:37gfredericks`,(stringify-keys (map->NoKeys {:x 42}))
11:37clojurebot#sandbox.NoKeys{:x 42, ":x" 42}
11:37gfredericks`,(stringify-keys (map->NoKeys {93 42}))
11:37clojurebot#sandbox.NoKeys{93 42, "93" 42}
11:37gfredericks`^ seems to not be related to basis keys or keywords in general
11:40justin_smithgfredericks`: odd!
11:40justin_smith,(stringify-keys {:a 0})
11:40clojurebot{":a" 0}
11:40justin_smith,(stringify-keys (map->NoKeys {:a 0}))
11:40clojurebot#sandbox.NoKeys{:a 0, ":a" 0}
11:40justin_smithsomething is fishy in recordtown
11:41gfredericks`back in my day it would just crash if you gave it a record I think
11:41gfredericks`I wonder if it uses (into rec (something with rec))
11:42sdegutisWhat's your favorite Clojure function and why?
11:42justin_smith(source clojure.walk/walk)
11:42justin_smithgfredericks`: the source to that function makes it clear - the base case for the reduce is the record itself
11:42justin_smithwhich means it can only be added to / have keys replaced, no keys can be removed by a pre or post walk on a record
11:43gfredericks`I'm guessing that was a hack for trying to not remove the basis keys
11:43justin_smithyeah, but a bit over-eager clearly
11:43gfredericks`,(-> (NoKeys) class .getBasis)
11:43clojurebot#error {\n :cause "Expecting var, but NoKeys is mapped to class sandbox.NoKeys"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Expecting var, but NoKeys is mapped to class sandbox.NoKeys, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.RuntimeException\n :message "Expecting va...
11:43gfredericks`,(NoKeys/getBasis)
11:43clojurebot[]
11:44justin_smith,(Heyo/getBasis)
11:44clojurebot[x]
11:44justin_smithso this could be used to do it the proper way?
11:44gfredericks`not sure if you can do it without reflection?
11:45gfredericks`the question muddles my head
11:45justin_smitheg. make the base case (select-keys form (.getBasis (type form)))
11:45justin_smith,(.getBasis Heyo)
11:45clojurebot#error {\n :cause "No matching field found: getBasis for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: getBasis for class java.lang.Class"\n :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}]\n :trace\n [[clojure.lang.Reflector getInstanceField "Reflector.java" 271]\n [clojure.lang.Reflector invokeNoArgInstanc...
11:45justin_smithhrmph
11:45devnI have a go-loop inside of a stuartsierra component. How do properly shutdown a component containing a go-loop?
11:45gfredericks`devn: have a shutdown channel?
11:45justin_smithdevn: use alts with a special shutdown channel
11:46justin_smithdevn: that's what I do at least, I think that's the standard thing
11:46justin_smithdevn: other less traditional options include a promise where the loop checks if that promise has been delivered
11:46devnyeah, kind of figured -- was wondering if i could just keep a handle around to the go-loop and then call close! on it or something
11:47justin_smithkeep a handle to the magic kill-channel
11:48gfredericksthe promise thing doesn't work as well because then the go loop has to separately poll the promise, which sounds more difficult than using alts
11:49justin_smithgfredericks: eh, (when-not (realized? p) (recur)) is simple enough, but alts with a poison channel is definitely more idiomatic
11:50gfredericksjustin_smith: yeah but you have to do that separate from whatever other "blocking" thing the go loop does
11:50justin_smithoh, true, that is a problem
11:50gfredericksso you have to use timeouts to keep it checking, or run the risk that it's blocked forever and never looks at the promise
11:50justin_smith(dec justin_smith)
11:50lazybotYou can't adjust your own karma.
11:50gfredericks,(println "(dec justin_smith)")
11:50clojurebot(dec justin_smith)\n
11:51justin_smith,(print "(dec justin_smith)")
11:51clojurebot(dec justin_smith)
11:51lazybot⇒ 283
11:51justin_smithhax
11:51gfredericks,(print "(inc clojurebot)")
11:51clojurebot(inc clojurebot)
11:51lazybotYou can't adjust your own karma.
11:52blkcathah :D
11:56justin_smith,'(inc gfredericks)
11:56clojurebot(inc gfredericks)
11:56lazybot⇒ 144
11:56justin_smithbecause of course i had to golf it
12:04ebzzryis anybody having problems with clojars, too?
12:04tcrawleyebzzry: what sort of problems?
12:04justin_smitherror-id:"216e53a5-e0c9-4df0-ba04-62e7405a5cec"
12:04ebzzryerror-id:"dd398dc2-e870-4582-ad43-ebd91e75ec48"
12:04justin_smithtcrawley: getting oops from the front page of clojars.org
12:04tcrawleyone sec
12:05ebzzryhttp://i.imgur.com/4ascJLd.png
12:05justin_smithebzzry: yeah, except for the uuid, identical to what I get
12:05tcrawleylooks like a corrupt DB. yay! I'll see what I can do
12:06ebzzrytcrawley, thanks!
12:06justin_smith(inc tcrawley)
12:06lazybot⇒ 3
12:07tcrawleythe root cause looks like a full filesystem
12:07tcrawleylooking to see what's eating all the space now
12:07ebzzryaw :)
12:08oddcullyall that jars - the immutable past ;)
12:09wes_ellisis there a more idiomatic version of (take n (drop x coll)) ?
12:10justin_smithwes_ellis: depending on what else you are doing, there is (->> coll (drop x) (take n))
12:10wes_ellisthanks
12:10justin_smith(where context decides which version is clearer)
12:10justin_smithbut there isn't a simpler function for that
12:11gfredericksunless it's a vector
12:11gfredericksand then there is subvec
12:11justin_smithoh yeah, excellent point
12:13tcrawleyebzzry: justin_smith: you should be back in business
12:13ebzzrytcrawley, thanks
12:13tcrawleyebzzry: thanks for reporting it!
12:13ebzzrytcrawley, np
12:15pepijndevosIs there a name for a knapsack where all items have the same size, but their values depend on other items in the knapsack?
12:17pepijndevosA shipping-container problem if you will. But a container of torches is more valuable when there is a container of batteries onboard.
12:17pepijndevosSo you can't just sort by value and (take n)
12:18gfrederickssounds too specific of a problem to have an abstract name
12:18justin_smithI don't know what that is, but it sounds np to me
12:18justin_smithpepijndevos: reminds me of a few things in graph theory (eg. min-cut)
12:19gfredericksdoes torch mean flashlight?
12:19justin_smithyeah, it's britishese
12:19pepijndevoshaha
12:19oddcullyi'd say yes, because of the battery context
12:19gfredericksI think south african for traffic light is "robot"
12:19gfrederickswhich I bet makes scifi a lot weirder now that I think about it
12:20justin_smithgfredericks: the movie chappy must be very confusing
12:20TEttingerlike lorry and nappy and other funny british terms
12:21TEttingerand of course america has funny terms like "doritos locos tacos from taco bell"
12:21justin_smithTEttinger: boot, pants, footy
12:22TEttingerpants are a british term?
12:22pepijndevosI'm neither British nor American, so I get to pick the nice words from both.
12:22TEttingerdo americans just wear shorts?
12:22justin_smithTEttinger: it's a different term in british
12:23justin_smithTEttinger: in british, showing up to work wearing pants and a shirt is much sillier than it is in 'murica
12:23TEttingeralso showing up in a boot is bad
12:24gfredericksI once had a canadian on my team and I printed him a namesign that said "Ask me a boot" and nobody thought it was as funny as I did
12:24justin_smithpepijndevos: I think this structure you are talking about would be one of those cases where optimizing the selected contents given some range of potential items is np-hard
12:24pepijndevosBut back to the knapsack. I could maybe use the dynamic solution. Take the best single element and then add one element at the time that adds the most value combined with the rest.
12:25justin_smithpepijndevos: you'd have a local optima problem
12:25pepijndevosyea...
12:25justin_smithsimulated annealing is more likely to get you a truly optimum result
12:26pepijndevosjustin_smith that looks promising.
12:29xemdetiahillclimb with random restart if you are lazy
12:29justin_smithxemdetia: that's just annealing with a bad thermostat :)
12:32xemdetiajustin_smith, sounds like my refridgerator
12:32pepijndevosjustin_smith so I start out wit N items, and replacing an item is a "neighbour"? And then the probability of visiting that neighbour is the improvement, but such that even if it gets worse, it has a non-zero probability.
12:41kwladykais any common way to show in doc it is map entry not map? {[col row] :piece-type}
12:56justin_smithpepijndevos: the idea with annealing is you have a "heat", and the higher the heat, the more willing you are to try longer chains of alternate options - but you still trim down to the ones that reach the best results
12:57TEttingerjustin_smith: is this at all related to gradient map pathfinding?
12:58TEttingeralso called dijkstra map since the 2d array of distances from goals/heat sources can be generated as a side effect of pathfinding with dijkstra's algorithm
12:58justin_smithTEttinger: I don't know actually, is this a neural net related thing, or a gaming thing?
12:58TEttingerboth
12:59justin_smithaha, no wonder I was confused
12:59TEttingerdijkstra can be used to pathfind on any graph, and a lot of search engine stuff is graph based
13:00justin_smithTEttinger: I found a SO post with no answers addressing that interesting question http://stackoverflow.com/questions/24070685/simulated-annealing-and-path-finding
13:00justin_smithbut the comments are interesting
13:00TEttingerhttp://www.roguebasin.com/index.php?title=Dijkstra
13:00TEttingera friend made this visualization
13:01TEttingerTSP?
13:02justin_smithTEttinger: I think that full SA is avoided with those kinds of maps because the range of choices is more linear
13:02justin_smithTEttinger: and SA really starts to become valuable when your search space is actually too large to enumerate
13:02kwladykajustin_smith, can i please you about code review (code is very short)?
13:02justin_smithkwladyka: got a paste?
13:03kwladykajustin_smith, do you preffer bitbucker or github?
13:03kwladyka*bitbucket
13:03justin_smithgithub is nice
13:03kwladykai will prepare repo
13:03kwladykaok, give me a sec.
13:03TEttingeryeah except when more than just pathfinding is involved in games. like when you have 10 different spells, all with different ranges and areas of effect, and can move 6 spaces and cast a spell at any point (this is D&D 5th edition's style)
13:03justin_smithTEttinger: oh yeah, then your space of options is starting to look like something you would use SA with
13:04justin_smithTEttinger: especially when you have multiple variables you are trying to optimize in parallel (experience points, hit points, gold, etc.)
13:04TEttingerI have a halfway decent pathfinder actually written in java that can find an optimal location for an AOE to be centered a lot of the time
13:04TEttingerthere's some issues with it currently
13:09justin_smithTEttinger: here's a dude who used simulated annealing to make a regular expression that would correctly pick the winner of every presidential election http://blog.podsnap.com/xkcd1313.html
13:12wes_ellis(repeat 3 'a) => (a a a) ... (repeat 3 [[1 2 3] [1 3 2]]) => ([[1 2 3] [1 3 2]] [[1 2 3] [1 3 2]] [[1 2 3] [1 3 2]]) ... I want (apply repeat 3 [[1 2 3] [1 3 2]]) => ([1 2 3] [1 3 2] [1 2 3] [1 3 2] [1 2 3] [1 3 2]) ... how?
13:13justin_smith,(apply concat (repeat 3 [[1 2 3] [1 3 2]]))
13:13clojurebot([1 2 3] [1 3 2] [1 2 3] [1 3 2] [1 2 3] ...)
13:13justin_smithwes_ellis: is that what you want?
13:14wes_ellisyeah
13:14justin_smith,(take 6 (cycle [[1 2 3] [1 3 2]])) ; another option
13:15clojurebot([1 2 3] [1 3 2] [1 2 3] [1 3 2] [1 2 3] ...)
13:16wes_ellisActually I have a seq made of 35 seqs that I just want to repeat infinitely
13:16justin_smithwes_ellis: then you could just use cycle directly!
13:16justin_smithsimplist answer, I bet
13:17wes_ellisawesome
13:17TEttinger,(let [sos (repeatedly 35 #(map (partial + (rand-int 1000)) (range 10)))] (cycle sos))
13:17clojurebot((891 892 893 894 895 ...) (187 188 189 190 191 ...) (341 342 343 344 345 ...) (118 119 120 121 122 ...) (732 733 734 735 736 ...) ...)
13:18TEttingerbetter example uh
13:18TEttinger,(let [sos (repeatedly 4 #(map (partial + (rand-int 1000)) (range 4)))] (cycle sos))
13:18clojurebot((202 203 204 205) (326 327 328 329) (289 290 291 292) (735 736 737 738) (202 203 204 205) ...)
13:44skalar_can anyone comment on the first edition vs second edition of "The Joy of Clojure"
13:49kungiskalar_: second one has more pages :-)
13:51skalar_kungi: haha i noticed that. is the content roughly the same? i know 2nd includes 1.6. I am looking for something that will help me to learn how to think idiomatically in designing an application the clojure/functional way
13:52kungiskalar_: if this is your intention then it does not matter if you read the first or second edition.
13:52skalar_kungi: do you recommend the book in general? or is there something better for this purpose?
13:53kungiskalar_: yes I recommend it! It is just great! Something better ... I don't know
13:54skalar_kungi: Thanks!! I will probably get 2nd.. I just wanted to be sure it wasn't worse. reviews on amazon are a bit less favorable.
13:54kungiskalar_: in my opinion the second edition expands on the first on in every way.
13:55skalar_kungi: that sounds great. but it's not necessary to cover the 1st ed first right?
13:55kungiskalar_: no
13:55skalar_kungi: perfect. thanks for your help!
13:56justin_smith,(+ 1 1)
13:56clojurebot#error {\n :cause "Unable to resolve symbol: (+ in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: (+ in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: (+ in this context"...
13:56justin_smithhaha, quite different from the error that provokes locally
13:57amalloyjustin_smith: really? i'd expect them to be the same
13:57amalloyand that's the error i get locally
13:57justin_smithamalloy: somehow locally my reader decides that (+ is two different inputs...
13:58amalloycider?
13:58clojurebotcider is Try #clojure-emacs for more help with Cider
13:58justin_smithoh weird now I can't reproduce it
13:58justin_smithit's like some artifact of copy/pasting the parens, then typing in the code
13:59justin_smithso I can probably blame it on readline or my terminal, neverm ind
14:01amalloyblaming things on a terminal is rarely too far wrong
14:23AtarianAnyone know why cider was obsoleted from Melpa?
14:25kwladykaPlease if you have time give me code review https://github.com/kwladyka/chess-challenge pull request https://github.com/kwladyka/chess-challenge/commit/9f142a464b418be73be8d3b68ea1eb727af4f407
14:25kwladykajustin_smith, ^
14:26justin_smithkwladyka: why (first {safe-square piece}) instead of [safe-square piece] ?
14:27kwladykajustin_smith, i am using this form in board notation like {[1 2] :queen [1 4] :king}
14:27kwladykajustin_smith, so i wanted use map entry for notation
14:28justin_smithkwladyka: OK, I'm just saying ##(= (first {[1 2] :queen}) [[1 2] :queen])
14:28lazybot⇒ true
14:28kwladykajustin_smith, oh... thx
14:34fikuszdoes anyone know what cider (git) keeps asking about when it asks me if I want to assoc my connection to a project? what's a project in cider?
14:38justin_smithfikusz: usually your classpath will be unique to a given project, which is defined by a project.clj file, and would encompass any code in subdirectories below that project.clj
14:38justin_smithfikusz: since lein doesn't do globally installed deps, you need a defined project to know which deps should be available beyond the defaults
14:45kwladykajustin_smith, what do you think about code, tests, etc.?
14:59kwladykajustin_smith, hmm i tried with [safe-square piece] and i have error java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry in function chess_challenge.pieces/capture?
15:00kwladykaso it is not the same
15:00kwladykaor i dont understand something :)
15:04amalloykwladyka: map entries are vectors, but not all vectors are map entries
15:05Bronsathey will be in 1.8
15:05BronsaPV at least
15:05kwladykaamalloy, do you see other solution like https://github.com/kwladyka/chess-challenge/blob/full-solution/src/chess_challenge/algorithm.clj#L18 (first ...) ?
15:06kwladykathe error is because i am doing https://github.com/kwladyka/chess-challenge/blob/full-solution/src/chess_challenge/pieces.clj#L33
15:06kwladykaBronsa, good to know
15:10sdegutisHelp. I'm getting an error during the creation of a new entity including {:line-item/sort-pos 0, ...} in a transaction which I cannot understand at all: Unable to resolve entity: :question-template/sort-pos {:db/error :db/invalid-data} -- what could be causing this?
15:12amalloykwladyka: the threading in add-piece-to-board seems intentionally obtuse. it's much easier to read if you write it as (-> (conj board piece) vary-meta update :safe-squares (partial remove-capture-squares piece))
15:13sdegutisOops the error is slightly incorrect. But it's correct enough.
15:13sdegutisPlease help.
15:13amalloyit's super weird to not have the main object you're operating on first: threading the function that later gets passed to a vary-meta on what is later introduced as the focus object is hard to untangle
15:17kwladykaamalloy, thx
15:19kwladykaamalloy, if you have time i will be very grateful if you can give me code review
15:27sdegutis,(require 'clojure.pprint/pprint)
15:27clojurebot#error {\n :cause "Could not locate pprint__init.class or pprint.clj on classpath."\n :via\n [{:type java.io.FileNotFoundException\n :message "Could not locate pprint__init.class or pprint.clj on classpath."\n :at [clojure.lang.RT load "RT.java" 456]}]\n :trace\n [[clojure.lang.RT load "RT.java" 456]\n [clojure.lang.RT load "RT.java" 419]\n [clojure.core$load$fn__5436 invoke "core.clj" 5869]...
15:27sdegutisWhat did I type wrong?
15:27sdegutisOh.
15:29kwladyka,(require 'clojure.pprint)
15:29clojurebotnil
15:29kwladykasdegutis, ^
15:29kwladykasdegutis, you can require namespace not function
15:30patrkrishi folks. I have a server written in Clojure, where the endpoints return Clojure data structures, e.g., maps and lists, which are then encoded as Transit data, which the JavaScript-based client consumes. I usually yes keywords as map keys, but it seems a bit cumbersome to look up data in a Transit map, if you first have to create a keyword. what do people here do?
15:31patrkrisyes=use
15:32sdegutisRight.
15:41wes_elliswhat do you call it when you do this: (defn do-stuff ([n] (do-stuff n 1 :this))([n foo bar] (blah (+ foo bar) n)))
15:41justin_smithwes_ellis: multiple arities, or arity overloading
15:41wes_ellisnot mutlimethods
15:41justin_smithno, that is not a multimethod
15:42wes_ellisis arity overloading supported in clojurescript?
15:42justin_smithyes
15:46wes_ellisOh, that wasn't the problem. What's the js equivelant of .indexOf?
15:48justin_smith(.indexOf "hello" "l") => 2 in my figwheel repl
15:48wes_ellis(.indexOf [11 12 13 15 14] 13)
15:49wes_ellisnot defined.
15:49wes_ellis(.indexOf (to-array [:a :b]) :b)
15:50justin_smithwes_ellis: oddly, that works for numbers but not keywords
15:50wes_ellisweird
15:50justin_smithjs .indexOf must be hard wired to use object identity
15:52amalloyyeah indexOf seems pretty lame. just tried this in a js console: [[1]].indexOf([1]) // -1
15:53justin_smithjs is also bad at collections as values I think
16:01dagda1is there a way I can get every select every odd or even indexed element from a sequence?
16:01justin_smith,(map first (partition 2 (range)))
16:01clojurebot(0 2 4 6 8 ...)
16:02amalloy,(take-nth 2 (range))
16:02clojurebot(0 2 4 6 8 ...)
16:02justin_smithoh, wow, I forgot about take-nth
16:03justin_smith(inc amalloy)
16:03lazybot⇒ 293
16:03oddcully,(map first (partition 2 [:a :b :c])) ; wrong?
16:03clojurebot(:a)
16:03sdegutisEven better: ##(take 3 (partition 2 1 (range)))
16:03lazybot⇒ ((0 1) (1 2) (2 3))
16:03amalloyoddcully: right, if you're using justin_smith's answer you need partition-all
16:03amalloy~partition
16:03clojurebotpartition is probably not what you want; see partition-all.
16:06gfredericksshould rename partition to partition-most
16:06oddcullypartition-meh
16:08sdegutishelp
16:25sdegutisSeriously. Datomic is inexplicably giving me a new error that it didn't give me this morning. I've reverted the database and the codebase, and it's a brand new error that simply wasn't there.
16:53sdegutisWhat are some Postgres wrappers for Clojure?
16:57hyPiRionsdegutis: clojure java jdbc is good, as is yesql imo
16:57hyPiRionDepends on use case though
16:58sdegutisWe have a simple web-app web-store.
17:03timvisheris it possible to use IAM roles with leiningen rather than the pub/private key pair?
17:17cnb_
17:17cnb_
17:17cnb_
17:17cnb_
17:18cnb_
17:18cnb_
17:18cnb_
17:18demophoon...
17:18cnb_ /j #freebsd
17:18{blake}Somebody fell asleep on the keyboard.
17:19sdegutisHa!
17:19cnb_I'm sorry Ia book fell on my keyboard
17:19sdegutisI laughed out loud just now.
17:19sdegutisWish there was some way to communicate that more succinctly though.
17:20firevoltI'm struggling to learn clojure... seems like a ton to learn, and I haven't found any great resources that walk through doing some like (i.e.) creating a full stack web app replacing javascript with clojure/clojurescript
17:20sdegutisfirevolt: there's basically nothing to learn about it, that's the magic of s-expressions
17:20sdegutisfirevolt: you praactically already know most of CLojure
17:20sdegutisfirevolt: the only thing left for you to learn is that ->> is great for map/reduce/filter etc
17:20sdegutisfirevolt: now you're a Clojur exprt
17:20firevoltI understand them in theory, I just struggle to know what to use to do different operations that I would do in node for example
17:23kwladykafirevolt, watch clojure inside out, all this http://www.purelyfunctional.tv/ and do http://www.4clojure.com/problems
17:23kwladykafirevolt, it worked for me
17:23MatachinesCan I get the index of a number in lazy sequence (sorry for noob question) ?
17:24kwladykafirevolt, and of course do your custom project during this time
17:24firevolt@kwladyka thanks! those look like great resources
17:25justin_smithMatachines: ##(.indexOf (map inc (range)) 2)
17:25lazybot⇒ 1
17:25kwladykafirevolt, but be warn, for almost all you have to pay :)
17:25kwladykafirevolt, unfortunately they are not free, but this is the reason why their are good
17:26Matachinesjustin_smith thanks!
17:26firevoltkwladyka: is clojure insideout that good? $120 seems a little steep
17:26kwladykafirevolt, you can find that one in torrent if you would like
17:27kwladykafirevolt, but in my opinion it is really good video
17:27firevoltI looked haha with the anticipation of paying for it if I watched it all
17:27kwladykai learned a lot of about clojure from that video
17:27kwladykaespecially about idea
17:27kwladykahow memory works
17:27kwladykaetc.
17:27firevoltokay interesting
17:28kwladykaother are more about code
17:28kwladykabut clojure inside out is also about how Clojure works inside
17:28kwladykait is a little hard to understand on the beginning, but worth to watch to catch the idea
17:29oddcullyare you advertising pirating?
17:29kwladykaoddcully, no, i am saying the fact
17:30kwladykathe choice everybody have to make independently
17:31kwladykai prefer pay for some video then lost hours for looking some information
17:33oddcullyif you enjoyed the video, then maybe out of courtesy to the hard working author, let potential customers find out the facts of life on their own ;)
17:37kwladykaoddcully, just i can imagine all depends on country where you live. For me paying in dollars is really pain, but i believe for somebody in other country there is much more pain like month salary or something like that :)
17:39kwladykastill i saved a lot of time buying video courses and i recommend that for everybody instead of books :)
17:47kwladykai am going sleep, goodnight! :)
18:00Bronsadnolen: is there still a reason for cljs.reader to be a thing?
18:01amalloyMatachines: note that if you actually need the index of an item in a lazy seq there is usually a cleaner more funcgtional solution
18:02Matachinesah, well it was only for a project euler solution. but im still interested, what would it be?
18:02amalloyi mean a solution to your project euler problem that wouldn't involve indexes of a sequence
18:03amalloynot a better way to get the index
18:03justin_smithyeah, indexes of a lazy-seq is usually the wrong answer altogether (unless maybe index is 0)
18:04amalloyand not knowing which problem you were doing i can't know what the better solution would be
18:07Matachinesoh well id be interested in a better solution, here's the problem: https://projecteuler.net/problem=25
18:07MatachinesI was using a lazy sequence of fibonacci numbers
18:10MatachinesWas basically doing (fib sequence -> filter by amount of digits == 1000 -> get the first -> get the index in the sequence
18:11amalloyMatachines: use map-indexed before filtering, so that each fibonacci number is paired with its index
18:12amalloyfibs -> number them -> filter by digits -> nth 1000 -> look at index
18:12amalloyoh, not nth 1000. filter for 1000 digits
18:16firevolthow would I mimic this in clojure? https://gist.github.com/loganmac/3fa7d8d45a86eeacccce
18:22oddcullyfirevolt: isn't this even for JS overly complicated?
18:23firevoltYes it was just proposed to me. Haha I realize it may not even be idiomatic. That's what I replied with
18:23oddcullyfirevolt: this is logging each item of the array to console, right?
18:23firevoltBasically it's a slowed-down for loop, with you being able to sequentially call each step
18:38Matachinesamalloy sorry for the late reply but I got it working. Thanks!
18:48{blake}Unrolling a map: https://www.refheap.com/108148
18:48{blake}The merge {} is...stupid, right? =P
18:49Bronsa{blake}: what does that do?
18:49{blake}Bronsa: It takes data returned from Mongo and returns a map showing the unique fields and their data types.
18:50{blake}Which can then be used to create a series of relational tables.
18:51{blake}But I'm just dumbly taking the latest value type and putting that into key, where, e.g., I want to ignore when the value is a nil, or do some other conflict resolution if there's a string in one place and a number in another.
18:53{blake}I think I need to replace the "merge {}" with something smarter.
18:55{blake}I know sdegutis was working on a similar thing.
19:07justin_smithblkcat: maybe what you want is (into {} ...)
19:07justin_smitherrr
19:07justin_smith{blake}: ^
19:08{blake}justin_smith: I think I had that. My head's a little spinning from the recursion. =P That does work, tho'.
19:08{blake}And is less dumb.
19:09justin_smithalso, I suspect you might be able to replace the nested mapcats with one for
19:09justin_smithcan't prove that yet though
19:09{blake}Yeah, that smells.
19:18sdegutis{blake}: I cheated and came up with a half baked solution.
19:18sdegutisSorry!
19:18{blake}sdegutis: A nod's as good as a wink to a blind bat...
19:18sdegutisYou remind me of me.
19:28{blake}sdegutis: I remind me of a younger, handsomer, smarter and richer me.
19:51amalloyso i have a namespace my.ns that contains (deftype T []). i have a java file that requires the namespace, and then tries c.l.RT/classForName("T"), which throws a NoClassDefFoundError. but, if i add (defn c [] T) to the namespace, and then call that function from java. i get the class of T just fine, so i know the namespace is loading. my question is, what classloader weirdness is stopping me from getting it from RT?
19:51amalloyer, that should read classForName("my.ns.T") - it's qualified properly
19:53justin_smiththat seems very odd
19:56hiredmanamalloy: I have a jira issue that I suspect is this
19:56hiredmanlemme see if I can dig it up
19:57hiredman(techno music plays as the camera pans around while I try to jira)
19:58amalloyhiredman: http://dev.clojure.org/jira/browse/CLJ-1457 ?
19:59hiredmanyes
19:59puredangerThose don't read as the same thing to me?
20:00hiredmanwell, my guess it is a different symptom of the same popping of the classloader
20:00puredangerAlso what Clojure version?
20:01hiredmantry binding LOADER to a DynamicClassloader before the classForName call
20:02Bronsahiredman: that should have been fixed by CLJ-979
20:02hiredman(the fastest way to do that is likely to create a clojure function that does it that takes a runnable)
20:02hiredmanBronsa: oh
20:02puredangerAlso, how are you requiring the namespace?
20:04amalloypuredanger: Clojure.var("clojure.core", "require").invoke(nsSym), clojure 1.6.0
20:04puredanger1.6 is like, old ;)
20:05puredanger But seriously would be curious re 1.7
20:07dabdhow would you implement a stack such that it can be backed up by either a list or vector? https://gist.github.com/dabd/0d664d953d633eff8705#file-stack-clj
20:07dabdthe above implementation won't work with vectors
20:08dabdbecause conj will behave differently for lists and vectors
20:09amalloydabd: lists and vectors are both already stacks under conj/pop/peek
20:09amalloyclojure.lang.IPersistentStack
20:09hiredman(and seqs are not lists)
20:12synkteAre clojure.test always evaluated alphabetically?
20:12dabdbut if I wanted to implement them using defprotocol I would have to look at the type of coll before in the defrecord implementation?
20:12dabdbefore manipulating it*
20:13hiredmanthey are not run in any defined order
20:13amalloyit's unclear what you expect this protocol to do
20:14amalloyif you want only one implementation of the protocol, then there is no need for it to exist at all. if you want two, then you can have a ListBasedStack that is always given a list, and a VectorBasedStack that is always given a vector
20:14sdegutisSHHHH IM THINKING
20:17synkteThanks hiredman
20:21amalloypuredanger: it seems that upgrading to 1.7 fixed it, although i am having some unrelated issues that are making everything not compile anymore so i can't 100% confirm that it wasn't some weird coincidence that made things work once
20:22dabdamalloy: thanks
20:44dabdis anyone using generative testing (test.check) instead of traditional unit testing?
21:04Olajydsomeone please help me with a substring functon such that (subs “clojure” 1 4) => “loj” and (subs “clojure” -1 4) => “jur”
21:13gfredericksdabd: I've done that a good amount I think
22:19namraidentify 037552
22:21scottjhe knows and is changing his pw
22:34gfredericks~password is 037552
22:34clojurebotOk.