#clojure log - Aug 12 2015

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

1:09 justin_smith: emperorcezar: not much, and typically questions here will get a quicker response

1:10 emperorcezar: I think you can turn off structural editing to fix your cursive problem

1:10 (temporarily turn it off)

1:10 or paste the paren you need (though entering a paren manually doesn't work as expected, cut/copy/paste should not be effected)

3:58 luxbock: I'd like to have one namespace for my schema definitions that every other namespace requires

3:58 but 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

3:59 justin_smith: luxbock: 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

3:59 luxbock: but 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

4:00 justin_smith: not sure I follow

4:01 I'm basically trying to get around circular namespace dependencies, but I'm not sure if it's possible

4:01 justin_smith: luxbock: 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

4:01 luxbock: yes, and protocols are a great way to fix circular namespace dependencies

4:01 luxbock: justin_smith: ah I see, yeah that's an interesting approach

4:02 yeah I'll give that a try, thanks

4:04 I forgot that in this case I wasn't actually using a record but potemkin/def-map-type

4:05 perhaps I should just get rid of it

4:05 if I can remember why I was using it in the first place

4:18 Olajyd: Given a string: ”12/34/900" I want to write a function that uses a Delimiter of "/" would return "900”.? any ideas

4:19 Kauko-: (fn [str] "900") :^D

4:20 perplexa: Olajyd: https://clojuredocs.org/clojure.string/split

4:20 hyPiRion: yeah, just do last on a split

4:20 perplexa: yeah last or nth

4:22 Kauko-: (defn foo [mystring] (last (clojure.string/split mystring #"/")))

4:24 Olajyd: thanks Kauko

4:28 perplexa: ¬_¬

4:51 TEttinger: Olajyd: re-seq is also handy for this. ##(last (re-seq #"[^/]+" "12/34/900"))

4:51 lazybot: ⇒ "900"

4:59 oddcully: or if you ever craved more java interop: ,(let [s "12/34/900" ofs (.lastIndexOf s "/")] (subs s (inc ofs)))

5:29 pydave6377: What do I need in .gitignore for a Leiningen 'app' project?

5:29 Pupeno: I have an empty route table with compojure and it’s still able to server static files from public. Any ideas why?

5:29 pydave6377: Ignore that - I just saw it generates one for me!

8:58 CookedGryphon: I'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?

8:58 what's actually going to test this

9:00 justin_smith: CookedGryphon: compile-file on some file

9:02 CookedGryphon: I get an ioexception no such file or directory when doing that

9:03 I wonder if the *compile-path* has been lost at this point...

9:28 justin_smith: (doc compile-file)

9:28 clojurebot: It's greek to me.

9:29 justin_smith: CookedGryphon: oh, my bad, you can just use compile, and provide a namespace symbol as the argument

9:29 CookedGryphon: http://clojure.org/compilation

9:37 CookedGryphon: Yeah, that's not working for me in the context of the clojure tests...

9:37 not sure why

9:43 aleoh

9:44 oh* turns out my test was working, and failing, and now I fixed it

9:56 wes_ellis: Does anyone use JavaFX for GUIs?

10:53 dumptruckman: anyone else using nightcode notice that it does not change the font color of most function names?

10:53 it only seems to do it for a select few from the core

11:08 Olajyd: can I implement a substring function that will do this (subs “clojure” -1 4) to give something like “jur”

11:13 vijaykiran: Olajyd: yes, you can :)

11:21 Olajyd: how do i go about implementing a substring function that will do this (subs “clojure” -1 4) to give something like “jur”?

11:22 pbx: Olajyd, what have you tried?

11:32 justin_smith: Olajyd: it should be easy if you know how to use let, count, and subs

11:35 gfredericks`: ,(defrecord Heyo [x])

11:35 clojurebot: sandbox.Heyo

11:35 gfredericks`: ,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.MapEntry x) [(str (key x)) (val x)] x)) x))

11:35 clojurebot: #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:35 gfredericks`: (require 'clojure.walk)

11:36 ,(require 'clojure.walk)

11:36 clojurebot: nil

11:36 gfredericks`: ,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.MapEntry x) [(str (key x)) (val x)] x)) x))

11:36 clojurebot: #'sandbox/stringify-keys

11:36 gfredericks`: ,(stringify-keys (map->Heyo {:x 42}))

11:36 clojurebot: #sandbox.Heyo{:x 42}

11:36 gfredericks`: ,(defn stringify-keys [x] (clojure.walk/prewalk (fn [x] (if (instance? clojure.lang.IMapEntry x) [(str (key x)) (val x)] x)) x))

11:36 clojurebot: #'sandbox/stringify-keys

11:36 gfredericks`: ,(stringify-keys (map->Heyo {:x 42}))

11:36 clojurebot: #sandbox.Heyo{:x 42, ":x" 42}

11:36 gfredericks`: ^ am I misunderstanding how prewalk works or does that look like a bug?

11:37 maybe a better example is when it's not a basis key

11:37 ,(defrecord NoKeys [])

11:37 clojurebot: sandbox.NoKeys

11:37 gfredericks`: ,(stringify-keys (map->NoKeys {:x 42}))

11:37 clojurebot: #sandbox.NoKeys{:x 42, ":x" 42}

11:37 gfredericks`: ,(stringify-keys (map->NoKeys {93 42}))

11:37 clojurebot: #sandbox.NoKeys{93 42, "93" 42}

11:37 gfredericks`: ^ seems to not be related to basis keys or keywords in general

11:40 justin_smith: gfredericks`: odd!

11:40 ,(stringify-keys {:a 0})

11:40 clojurebot: {":a" 0}

11:40 justin_smith: ,(stringify-keys (map->NoKeys {:a 0}))

11:40 clojurebot: #sandbox.NoKeys{:a 0, ":a" 0}

11:40 justin_smith: something is fishy in recordtown

11:41 gfredericks`: back in my day it would just crash if you gave it a record I think

11:41 I wonder if it uses (into rec (something with rec))

11:42 sdegutis: What's your favorite Clojure function and why?

11:42 justin_smith: (source clojure.walk/walk)

11:42 gfredericks`: the source to that function makes it clear - the base case for the reduce is the record itself

11:42 which 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:43 gfredericks`: I'm guessing that was a hack for trying to not remove the basis keys

11:43 justin_smith: yeah, but a bit over-eager clearly

11:43 gfredericks`: ,(-> (NoKeys) class .getBasis)

11:43 clojurebot: #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:43 gfredericks`: ,(NoKeys/getBasis)

11:43 clojurebot: []

11:44 justin_smith: ,(Heyo/getBasis)

11:44 clojurebot: [x]

11:44 justin_smith: so this could be used to do it the proper way?

11:44 gfredericks`: not sure if you can do it without reflection?

11:45 the question muddles my head

11:45 justin_smith: eg. make the base case (select-keys form (.getBasis (type form)))

11:45 ,(.getBasis Heyo)

11:45 clojurebot: #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:45 justin_smith: hrmph

11:45 devn: I have a go-loop inside of a stuartsierra component. How do properly shutdown a component containing a go-loop?

11:45 gfredericks`: devn: have a shutdown channel?

11:45 justin_smith: devn: use alts with a special shutdown channel

11:46 devn: that's what I do at least, I think that's the standard thing

11:46 devn: other less traditional options include a promise where the loop checks if that promise has been delivered

11:46 devn: yeah, 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:47 justin_smith: keep a handle to the magic kill-channel

11:48 gfredericks: the 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:49 justin_smith: gfredericks: eh, (when-not (realized? p) (recur)) is simple enough, but alts with a poison channel is definitely more idiomatic

11:50 gfredericks: justin_smith: yeah but you have to do that separate from whatever other "blocking" thing the go loop does

11:50 justin_smith: oh, true, that is a problem

11:50 gfredericks: so 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:50 justin_smith: (dec justin_smith)

11:50 lazybot: You can't adjust your own karma.

11:50 gfredericks: ,(println "(dec justin_smith)")

11:50 clojurebot: (dec justin_smith)\n

11:51 justin_smith: ,(print "(dec justin_smith)")

11:51 clojurebot: (dec justin_smith)

11:51 lazybot: ⇒ 283

11:51 justin_smith: hax

11:51 gfredericks: ,(print "(inc clojurebot)")

11:51 clojurebot: (inc clojurebot)

11:51 lazybot: You can't adjust your own karma.

11:52 blkcat: hah :D

11:56 justin_smith: ,'(inc gfredericks)

11:56 clojurebot: (inc gfredericks)

11:56 lazybot: ⇒ 144

11:56 justin_smith: because of course i had to golf it

12:04 ebzzry: is anybody having problems with clojars, too?

12:04 tcrawley: ebzzry: what sort of problems?

12:04 justin_smith: error-id:"216e53a5-e0c9-4df0-ba04-62e7405a5cec"

12:04 ebzzry: error-id:"dd398dc2-e870-4582-ad43-ebd91e75ec48"

12:04 justin_smith: tcrawley: getting oops from the front page of clojars.org

12:04 tcrawley: one sec

12:05 ebzzry: http://i.imgur.com/4ascJLd.png

12:05 justin_smith: ebzzry: yeah, except for the uuid, identical to what I get

12:05 tcrawley: looks like a corrupt DB. yay! I'll see what I can do

12:06 ebzzry: tcrawley, thanks!

12:06 justin_smith: (inc tcrawley)

12:06 lazybot: ⇒ 3

12:07 tcrawley: the root cause looks like a full filesystem

12:07 looking to see what's eating all the space now

12:07 ebzzry: aw :)

12:08 oddcully: all that jars - the immutable past ;)

12:09 wes_ellis: is there a more idiomatic version of (take n (drop x coll)) ?

12:10 justin_smith: wes_ellis: depending on what else you are doing, there is (->> coll (drop x) (take n))

12:10 wes_ellis: thanks

12:10 justin_smith: (where context decides which version is clearer)

12:10 but there isn't a simpler function for that

12:11 gfredericks: unless it's a vector

12:11 and then there is subvec

12:11 justin_smith: oh yeah, excellent point

12:13 tcrawley: ebzzry: justin_smith: you should be back in business

12:13 ebzzry: tcrawley, thanks

12:13 tcrawley: ebzzry: thanks for reporting it!

12:13 ebzzry: tcrawley, np

12:15 pepijndevos: Is there a name for a knapsack where all items have the same size, but their values depend on other items in the knapsack?

12:17 A shipping-container problem if you will. But a container of torches is more valuable when there is a container of batteries onboard.

12:17 So you can't just sort by value and (take n)

12:18 gfredericks: sounds too specific of a problem to have an abstract name

12:18 justin_smith: I don't know what that is, but it sounds np to me

12:18 pepijndevos: reminds me of a few things in graph theory (eg. min-cut)

12:19 gfredericks: does torch mean flashlight?

12:19 justin_smith: yeah, it's britishese

12:19 pepijndevos: haha

12:19 oddcully: i'd say yes, because of the battery context

12:19 gfredericks: I think south african for traffic light is "robot"

12:19 which I bet makes scifi a lot weirder now that I think about it

12:20 justin_smith: gfredericks: the movie chappy must be very confusing

12:20 TEttinger: like lorry and nappy and other funny british terms

12:21 and of course america has funny terms like "doritos locos tacos from taco bell"

12:21 justin_smith: TEttinger: boot, pants, footy

12:22 TEttinger: pants are a british term?

12:22 pepijndevos: I'm neither British nor American, so I get to pick the nice words from both.

12:22 TEttinger: do americans just wear shorts?

12:22 justin_smith: TEttinger: it's a different term in british

12:23 TEttinger: in british, showing up to work wearing pants and a shirt is much sillier than it is in 'murica

12:23 TEttinger: also showing up in a boot is bad

12:24 gfredericks: I 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:24 justin_smith: pepijndevos: 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:24 pepijndevos: But 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:25 justin_smith: pepijndevos: you'd have a local optima problem

12:25 pepijndevos: yea...

12:25 justin_smith: simulated annealing is more likely to get you a truly optimum result

12:26 pepijndevos: justin_smith that looks promising.

12:29 xemdetia: hillclimb with random restart if you are lazy

12:29 justin_smith: xemdetia: that's just annealing with a bad thermostat :)

12:32 xemdetia: justin_smith, sounds like my refridgerator

12:32 pepijndevos: justin_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:41 kwladyka: is any common way to show in doc it is map entry not map? {[col row] :piece-type}

12:56 justin_smith: pepijndevos: 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:57 TEttinger: justin_smith: is this at all related to gradient map pathfinding?

12:58 also 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:58 justin_smith: TEttinger: I don't know actually, is this a neural net related thing, or a gaming thing?

12:58 TEttinger: both

12:59 justin_smith: aha, no wonder I was confused

12:59 TEttinger: dijkstra can be used to pathfind on any graph, and a lot of search engine stuff is graph based

13:00 justin_smith: TEttinger: I found a SO post with no answers addressing that interesting question http://stackoverflow.com/questions/24070685/simulated-annealing-and-path-finding

13:00 but the comments are interesting

13:00 TEttinger: http://www.roguebasin.com/index.php?title=Dijkstra

13:00 a friend made this visualization

13:01 TSP?

13:02 justin_smith: TEttinger: I think that full SA is avoided with those kinds of maps because the range of choices is more linear

13:02 TEttinger: and SA really starts to become valuable when your search space is actually too large to enumerate

13:02 kwladyka: justin_smith, can i please you about code review (code is very short)?

13:02 justin_smith: kwladyka: got a paste?

13:03 kwladyka: justin_smith, do you preffer bitbucker or github?

13:03 *bitbucket

13:03 justin_smith: github is nice

13:03 kwladyka: i will prepare repo

13:03 ok, give me a sec.

13:03 TEttinger: yeah 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:03 justin_smith: TEttinger: oh yeah, then your space of options is starting to look like something you would use SA with

13:04 TEttinger: especially when you have multiple variables you are trying to optimize in parallel (experience points, hit points, gold, etc.)

13:04 TEttinger: I 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:04 there's some issues with it currently

13:09 justin_smith: TEttinger: 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:12 wes_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:13 justin_smith: ,(apply concat (repeat 3 [[1 2 3] [1 3 2]]))

13:13 clojurebot: ([1 2 3] [1 3 2] [1 2 3] [1 3 2] [1 2 3] ...)

13:13 justin_smith: wes_ellis: is that what you want?

13:14 wes_ellis: yeah

13:14 justin_smith: ,(take 6 (cycle [[1 2 3] [1 3 2]])) ; another option

13:15 clojurebot: ([1 2 3] [1 3 2] [1 2 3] [1 3 2] [1 2 3] ...)

13:16 wes_ellis: Actually I have a seq made of 35 seqs that I just want to repeat infinitely

13:16 justin_smith: wes_ellis: then you could just use cycle directly!

13:16 simplist answer, I bet

13:17 wes_ellis: awesome

13:17 TEttinger: ,(let [sos (repeatedly 35 #(map (partial + (rand-int 1000)) (range 10)))] (cycle sos))

13:17 clojurebot: ((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:18 TEttinger: better example uh

13:18 ,(let [sos (repeatedly 4 #(map (partial + (rand-int 1000)) (range 4)))] (cycle sos))

13:18 clojurebot: ((202 203 204 205) (326 327 328 329) (289 290 291 292) (735 736 737 738) (202 203 204 205) ...)

13:44 skalar_: can anyone comment on the first edition vs second edition of "The Joy of Clojure"

13:49 kungi: skalar_: second one has more pages :-)

13:51 skalar_: 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:52 kungi: skalar_: if this is your intention then it does not matter if you read the first or second edition.

13:52 skalar_: kungi: do you recommend the book in general? or is there something better for this purpose?

13:53 kungi: skalar_: yes I recommend it! It is just great! Something better ... I don't know

13:54 skalar_: 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:54 kungi: skalar_: in my opinion the second edition expands on the first on in every way.

13:55 skalar_: kungi: that sounds great. but it's not necessary to cover the 1st ed first right?

13:55 kungi: skalar_: no

13:55 skalar_: kungi: perfect. thanks for your help!

13:56 justin_smith: ,(+ 1 1)

13:56 clojurebot: #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:56 justin_smith: haha, quite different from the error that provokes locally

13:57 amalloy: justin_smith: really? i'd expect them to be the same

13:57 and that's the error i get locally

13:57 justin_smith: amalloy: somehow locally my reader decides that (+ is two different inputs...

13:58 amalloy: cider?

13:58 clojurebot: cider is Try #clojure-emacs for more help with Cider

13:58 justin_smith: oh weird now I can't reproduce it

13:58 it's like some artifact of copy/pasting the parens, then typing in the code

13:59 so I can probably blame it on readline or my terminal, neverm ind

14:01 amalloy: blaming things on a terminal is rarely too far wrong

14:23 Atarian: Anyone know why cider was obsoleted from Melpa?

14:25 kwladyka: Please 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:25 justin_smith, ^

14:26 justin_smith: kwladyka: why (first {safe-square piece}) instead of [safe-square piece] ?

14:27 kwladyka: justin_smith, i am using this form in board notation like {[1 2] :queen [1 4] :king}

14:27 justin_smith, so i wanted use map entry for notation

14:28 justin_smith: kwladyka: OK, I'm just saying ##(= (first {[1 2] :queen}) [[1 2] :queen])

14:28 lazybot: ⇒ true

14:28 kwladyka: justin_smith, oh... thx

14:34 fikusz: does 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:38 justin_smith: fikusz: 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:38 fikusz: since lein doesn't do globally installed deps, you need a defined project to know which deps should be available beyond the defaults

14:45 kwladyka: justin_smith, what do you think about code, tests, etc.?

14:59 justin_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:00 so it is not the same

15:00 or i dont understand something :)

15:04 amalloy: kwladyka: map entries are vectors, but not all vectors are map entries

15:05 Bronsa: they will be in 1.8

15:05 PV at least

15:05 kwladyka: amalloy, do you see other solution like https://github.com/kwladyka/chess-challenge/blob/full-solution/src/chess_challenge/algorithm.clj#L18 (first ...) ?

15:06 the error is because i am doing https://github.com/kwladyka/chess-challenge/blob/full-solution/src/chess_challenge/pieces.clj#L33

15:06 Bronsa, good to know

15:10 sdegutis: Help. 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:12 amalloy: kwladyka: 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:13 sdegutis: Oops the error is slightly incorrect. But it's correct enough.

15:13 Please help.

15:13 amalloy: it'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:17 kwladyka: amalloy, thx

15:19 amalloy, if you have time i will be very grateful if you can give me code review

15:27 sdegutis: ,(require 'clojure.pprint/pprint)

15:27 clojurebot: #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:27 sdegutis: What did I type wrong?

15:27 Oh.

15:27 * sdegutis slaps face

15:29 kwladyka: ,(require 'clojure.pprint)

15:29 clojurebot: nil

15:29 kwladyka: sdegutis, ^

15:29 sdegutis, you can require namespace not function

15:30 patrkris: hi 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:31 yes=use

15:32 sdegutis: Right.

15:41 wes_ellis: what 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:41 justin_smith: wes_ellis: multiple arities, or arity overloading

15:41 wes_ellis: not mutlimethods

15:41 justin_smith: no, that is not a multimethod

15:42 wes_ellis: is arity overloading supported in clojurescript?

15:42 justin_smith: yes

15:46 wes_ellis: Oh, that wasn't the problem. What's the js equivelant of .indexOf?

15:48 justin_smith: (.indexOf "hello" "l") => 2 in my figwheel repl

15:48 wes_ellis: (.indexOf [11 12 13 15 14] 13)

15:49 not defined.

15:49 (.indexOf (to-array [:a :b]) :b)

15:50 justin_smith: wes_ellis: oddly, that works for numbers but not keywords

15:50 wes_ellis: weird

15:50 justin_smith: js .indexOf must be hard wired to use object identity

15:52 amalloy: yeah indexOf seems pretty lame. just tried this in a js console: [[1]].indexOf([1]) // -1

15:53 justin_smith: js is also bad at collections as values I think

16:01 dagda1: is there a way I can get every select every odd or even indexed element from a sequence?

16:01 justin_smith: ,(map first (partition 2 (range)))

16:01 clojurebot: (0 2 4 6 8 ...)

16:02 amalloy: ,(take-nth 2 (range))

16:02 clojurebot: (0 2 4 6 8 ...)

16:02 justin_smith: oh, wow, I forgot about take-nth

16:03 (inc amalloy)

16:03 lazybot: ⇒ 293

16:03 oddcully: ,(map first (partition 2 [:a :b :c])) ; wrong?

16:03 clojurebot: (:a)

16:03 sdegutis: Even better: ##(take 3 (partition 2 1 (range)))

16:03 lazybot: ⇒ ((0 1) (1 2) (2 3))

16:03 amalloy: oddcully: right, if you're using justin_smith's answer you need partition-all

16:03 ~partition

16:03 clojurebot: partition is probably not what you want; see partition-all.

16:06 gfredericks: should rename partition to partition-most

16:06 oddcully: partition-meh

16:08 sdegutis: help

16:25 Seriously. 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:53 What are some Postgres wrappers for Clojure?

16:57 hyPiRion: sdegutis: clojure java jdbc is good, as is yesql imo

16:57 Depends on use case though

16:58 sdegutis: We have a simple web-app web-store.

17:03 timvisher: is it possible to use IAM roles with leiningen rather than the pub/private key pair?

17:17 cnb_:







17:18 demophoon: ...

17:18 cnb_: /j #freebsd

17:18 {blake}: Somebody fell asleep on the keyboard.

17:19 sdegutis: Ha!

17:19 cnb_: I'm sorry Ia book fell on my keyboard

17:19 sdegutis: I laughed out loud just now.

17:19 Wish there was some way to communicate that more succinctly though.

17:20 firevolt: I'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:20 sdegutis: firevolt: there's basically nothing to learn about it, that's the magic of s-expressions

17:20 firevolt: you praactically already know most of CLojure

17:20 firevolt: the only thing left for you to learn is that ->> is great for map/reduce/filter etc

17:20 firevolt: now you're a Clojur exprt

17:20 firevolt: I 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:23 kwladyka: firevolt, watch clojure inside out, all this http://www.purelyfunctional.tv/ and do http://www.4clojure.com/problems

17:23 firevolt, it worked for me

17:23 Matachines: Can I get the index of a number in lazy sequence (sorry for noob question) ?

17:24 kwladyka: firevolt, and of course do your custom project during this time

17:24 firevolt: @kwladyka thanks! those look like great resources

17:25 justin_smith: Matachines: ##(.indexOf (map inc (range)) 2)

17:25 lazybot: ⇒ 1

17:25 kwladyka: firevolt, but be warn, for almost all you have to pay :)

17:25 firevolt, unfortunately they are not free, but this is the reason why their are good

17:26 Matachines: justin_smith thanks!

17:26 firevolt: kwladyka: is clojure insideout that good? $120 seems a little steep

17:26 kwladyka: firevolt, you can find that one in torrent if you would like

17:27 firevolt, but in my opinion it is really good video

17:27 firevolt: I looked haha with the anticipation of paying for it if I watched it all

17:27 kwladyka: i learned a lot of about clojure from that video

17:27 especially about idea

17:27 how memory works

17:27 etc.

17:27 firevolt: okay interesting

17:28 kwladyka: other are more about code

17:28 but clojure inside out is also about how Clojure works inside

17:28 it is a little hard to understand on the beginning, but worth to watch to catch the idea

17:29 oddcully: are you advertising pirating?

17:29 kwladyka: oddcully, no, i am saying the fact

17:30 the choice everybody have to make independently

17:31 i prefer pay for some video then lost hours for looking some information

17:33 oddcully: if 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:37 kwladyka: oddcully, 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:39 still i saved a lot of time buying video courses and i recommend that for everybody instead of books :)

17:47 i am going sleep, goodnight! :)

18:00 Bronsa: dnolen: is there still a reason for cljs.reader to be a thing?

18:01 amalloy: Matachines: note that if you actually need the index of an item in a lazy seq there is usually a cleaner more funcgtional solution

18:02 Matachines: ah, well it was only for a project euler solution. but im still interested, what would it be?

18:02 amalloy: i mean a solution to your project euler problem that wouldn't involve indexes of a sequence

18:03 not a better way to get the index

18:03 justin_smith: yeah, indexes of a lazy-seq is usually the wrong answer altogether (unless maybe index is 0)

18:04 amalloy: and not knowing which problem you were doing i can't know what the better solution would be

18:07 Matachines: oh well id be interested in a better solution, here's the problem: https://projecteuler.net/problem=25

18:07 I was using a lazy sequence of fibonacci numbers

18:10 Was basically doing (fib sequence -> filter by amount of digits == 1000 -> get the first -> get the index in the sequence

18:11 amalloy: Matachines: use map-indexed before filtering, so that each fibonacci number is paired with its index

18:12 fibs -> number them -> filter by digits -> nth 1000 -> look at index

18:12 oh, not nth 1000. filter for 1000 digits

18:16 firevolt: how would I mimic this in clojure? https://gist.github.com/loganmac/3fa7d8d45a86eeacccce

18:22 oddcully: firevolt: isn't this even for JS overly complicated?

18:23 firevolt: Yes it was just proposed to me. Haha I realize it may not even be idiomatic. That's what I replied with

18:23 oddcully: firevolt: this is logging each item of the array to console, right?

18:23 firevolt: Basically it's a slowed-down for loop, with you being able to sequentially call each step

18:38 Matachines: amalloy sorry for the late reply but I got it working. Thanks!

18:48 {blake}: Unrolling a map: https://www.refheap.com/108148

18:48 The merge {} is...stupid, right? =P

18:49 Bronsa: {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 Which can then be used to create a series of relational tables.

18:51 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 I think I need to replace the "merge {}" with something smarter.

18:55 I know sdegutis was working on a similar thing.

19:07 justin_smith: blkcat: maybe what you want is (into {} ...)

19:07 errr

19:07 {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 And is less dumb.

19:09 justin_smith: also, I suspect you might be able to replace the nested mapcats with one for

19:09 can't prove that yet though

19:09 {blake}: Yeah, that smells.

19:18 sdegutis: {blake}: I cheated and came up with a half baked solution.

19:18 Sorry!

19:18 {blake}: sdegutis: A nod's as good as a wink to a blind bat...

19:18 sdegutis: You remind me of me.

19:28 {blake}: sdegutis: I remind me of a younger, handsomer, smarter and richer me.

19:51 amalloy: so 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:51 er, that should read classForName("my.ns.T") - it's qualified properly

19:53 justin_smith: that seems very odd

19:56 hiredman: amalloy: I have a jira issue that I suspect is this

19:56 lemme see if I can dig it up

19:57 (techno music plays as the camera pans around while I try to jira)

19:58 amalloy: hiredman: http://dev.clojure.org/jira/browse/CLJ-1457 ?

19:59 hiredman: yes

19:59 puredanger: Those don't read as the same thing to me?

20:00 hiredman: well, my guess it is a different symptom of the same popping of the classloader

20:00 puredanger: Also what Clojure version?

20:01 hiredman: try binding LOADER to a DynamicClassloader before the classForName call

20:02 Bronsa: hiredman: that should have been fixed by CLJ-979

20:02 hiredman: (the fastest way to do that is likely to create a clojure function that does it that takes a runnable)

20:02 Bronsa: oh

20:02 puredanger: Also, how are you requiring the namespace?

20:04 amalloy: puredanger: Clojure.var("clojure.core", "require").invoke(nsSym), clojure 1.6.0

20:04 puredanger: 1.6 is like, old ;)

20:05 But seriously would be curious re 1.7

20:07 dabd: how 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:07 the above implementation won't work with vectors

20:08 because conj will behave differently for lists and vectors

20:09 amalloy: dabd: lists and vectors are both already stacks under conj/pop/peek

20:09 clojure.lang.IPersistentStack

20:09 hiredman: (and seqs are not lists)

20:12 synkte: Are clojure.test always evaluated alphabetically?

20:12 dabd: but if I wanted to implement them using defprotocol I would have to look at the type of coll before in the defrecord implementation?

20:12 before manipulating it*

20:13 hiredman: they are not run in any defined order

20:13 amalloy: it's unclear what you expect this protocol to do

20:14 if 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:14 sdegutis: SHHHH IM THINKING

20:17 synkte: Thanks hiredman

20:21 amalloy: puredanger: 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:22 dabd: amalloy: thanks

20:44 is anyone using generative testing (test.check) instead of traditional unit testing?

21:04 Olajyd: someone please help me with a substring functon such that (subs “clojure” 1 4) => “loj” and (subs “clojure” -1 4) => “jur”

21:13 gfredericks: dabd: I've done that a good amount I think

22:19 namra: identify 037552

22:21 scottj: he knows and is changing his pw

22:34 gfredericks: ~password is 037552

22:34 clojurebot: Ok.

Logging service provided by n01se.net