#clojure logs

2015-08-05

00:01lsdfajklsdtest
00:01lsdfajklsdrhaywood: yt?
00:01justin_smithran 0 tests with 0 assertions, 0 fails, 0 errors
00:02lsdfajklsdrhaywood: (+ 1 1)
02:54tdammershi... is this the right place for questions about clojurescript and figwheel?
02:56Empperiok place, but #clojurescript is better
02:57tdammersaight
08:35tgoossensHow do I typehint a 2d array?
08:37justin_smith, (into-array [(into-array [5])])
08:37clojurebot#object["[[Ljava.lang.Long;" 0x5d642c1f "[[Ljava.lang.Long;@5d642c1f"]
08:37justin_smith"[[Ljava.lang.Long;", though the java.lang.Long part is variable of course
08:38justin_smith"[[Lfoo'\;"
08:38justin_smithyou can use the string where normally you would provide a class or keyword
08:42tgoossensjustin_smith, again my hero of the day thanks!
08:53snowell(inc justin_smith)
08:53lazybot⇒ 284
08:54hellofunkwhat is easiest way to build binary number of arbitrary length with all bits turned on?
08:54hellofunki.e. if i need length it builds 2r11111
08:54hellofunklength 5
08:56chouser,(Long/toBinaryString (- (bit-shift-left 1 5) 1))
08:57clojurebot"11111"
09:00justin_smith,(read-string (apply str "2r" (repeat 5 1))) ; less elegant
09:00clojurebot31
09:00justin_smitherr
09:01hellofunkjustin_smith: that is the correct result
09:01hellofunkjust not printing as binary
09:01hellofunkwhich is fine
09:01justin_smithhellofunk: ahh, right
09:01justin_smiththe bit-shift is probably two orders of magnitude faster :)
09:01hellofunki suspect there is still a clever elegant option to using xor
09:02hellofunkI was thinking that 2r100000... xor with 0 will always be 2r011111....
09:02hellofunkwait
09:02hellofunki mean bit-not, not xor
09:03hellofunki should not think out loud
09:04blackbird_I have a line like (def tmc (client/text-connection (env :cache-endpoint))) When doing like `lein ring uberwar`, this fails because the env variable doesn't exist there and it attempts to create a connection to nil. Is there a general patterin for dealing with this type of thing?
09:05hellofunki think i'll go with the chouser offering
09:05chouserDon't be too hasty. There may be benefits to the string-manipulation version that we haven't thought of yet. ;-)
09:06justin_smithblackbird_: the easy way is (def tmc (delay (clien/text-connection ...))) and then use @tmc where you would use tmc
09:06justin_smithblackbird_: the super proper way is to use stuartsierra/component for resources that are stateful
09:06chouser,(nth (iterate #(+ 1 (* 10 %)) 1) 5)
09:06clojurebot111111
09:07chouseroh, whoops, that's base 10
09:07chouser(Long/toBinaryString (nth (iterate #(+ 1 (* 2 %)) 1) 5))
09:07chouser,(Long/toBinaryString (nth (iterate #(+ 1 (* 2 %)) 1) 5))
09:07clojurebot"111111"
09:08blackbird_justin_smith: ahh cool. component way seems like overkill for one def, thanks for the tip
09:09chouser,(Long/toBinaryString (eval (read-string (nth (iterate #(str "(+ 1 (* 2 " % "))") 1) 5))))
09:09clojurebot"111111"
09:09opqdonut,(Long/toBinaryString (dec (bit-shift-left 1 6)))
09:09clojurebot"111111"
09:10opqdonutoh that was mentioned already ages ago
09:10justin_smiththe bit-shift/dec combo is the best though
09:10chouseropqdonut: dec, of course!
09:10chousernicely done
09:10opqdonutwell it's actually the same number of characters as - 1 :)
09:11chouserhm, true. I prefer dec.
09:15opqdonutme too
09:16opqdonutI even use it on floats, but feel a bit dirty afterwards
09:17justin_smith,(dec (/ 131 7))
09:17clojurebot124/7
09:20justin_smith,(inc (/ 17 7)) ; how I rock it
09:20clojurebot24/7
09:34tgoossensHow (using leiningen) can I compile java and clojure code AND have a java class use a class generated by clojure gen-class.
09:34tgoossensThis is a problem since java is compiled first and then clojure
09:34tgoossensbut in this particular case, clojure should be compiled before this one class
09:34tgoossenscan I express such things in leiningen?
09:35gfrederickstgoossens: do you know for sure that you have to structure it that way? there are other ways of calling clojure code from java code
09:35gfredericksthat don't require that order of compilation
09:35hyPiRiontgoossens: https://github.com/hyPiRion/multicompile-example
09:36hyPiRionessentially just do prep-task modifications
09:39chouseror move the gen-class code to another "project" and bring it in as a lein dep
09:42TimMcor use make
09:47tgoossensI added it as a Junit test (which in the end made more sense)
09:54TimMcfascinating
09:54TimMcWas it in fact a test?
10:01wes_hello. I've got a question if you've got time.
10:02justin_smithwes_: on IRC you don't need to ask, you can just ask
10:02namrawes_: just ask ^^
10:02namra^^
10:04wes__I want to apply a function to a seq with an init value and use the result of the function as the init value for the following iterations.
10:04justin_smithwes_: that's reduce
10:05justin_smith,(reduce + 2 [3 4 5])
10:05clojurebot14
10:05gfredericks,(reduce str 2 [3 4 5])
10:05clojurebot"2345"
10:05gfredericks,(reduce - 2 [3 4 5])
10:05clojurebot-10
10:05gfredericks,(reduce / 2 [3 4 5])
10:05clojurebot1/30
10:05justin_smith,(reduce conj [] [7 8 9])
10:05clojurebot[7 8 9]
10:05gfredericks,(reduce vector 2 [3 4 5])
10:05clojurebot[[[2 3] 4] 5]
10:06justin_smith,(reduce conj () [7 8 9])
10:06clojurebot(9 8 7)
10:06gfredericks,(reduce hash-set 2 [3 4 5])
10:06clojurebot#{#{4 #{3 2}} 5}
10:06justin_smithyeah, reduce is the greatest
10:06gfredericks(reduce reduce ? [? ? ?]) ;; ← make this work
10:06wes__(defn move-up [map vec-of-maps index] ...) -> new vec-of-maps with item moved to index
10:07wes__(reduce move-up vec-of-maps seq-of-maps) <---- this turns some of my maps into vectors of [k v]
10:07gfredericks,(reduce reduce conj [[1 2 3] [4 5 6] [7 8 9]])
10:07clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :at [clojure.core$conj__4104 invokeStatic "core.clj" 82]}]\n :trace\n [[clojure.core$conj__4104 invokeStatic "core.clj" 82]\n [clojure.core$conj__4104 invoke "core.clj" -1]\n [c...
10:07gfredericksdangit
10:08gfredericks,(reduce reduce + [[1 2 3] [4 5 6] [7 8 9]])
10:08clojurebot#error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [clojure.core$reduce invokeStatic "core.clj" 6516]}]\n :trace\n [[clojure.core$reduce invokeStatic "core.clj" 6516]\n [clojure.core$reduce invoke "core.clj" -1]\n [clojure.lang.PersistentVector reduce "Persist...
10:08justin_smithwes__: it would do that if seq-of-maps was actually a map
10:08gfrederickswelp I give up
10:08justin_smithwes__: also, how are you giving a three-arg function to reduce?
10:09wes__woops. move-up takes two args [item coll] and uses (.indexOf coll item) to call insert-at....
10:11justin_smithso you have a vector of maps, and a seq of maps, and your reduce is to take each item in the seq of maps and find its position in the vector and then...
10:12tgoossensin leiningen with ':aot' how do I set two values?
10:13justin_smithtgoossens: so you have two totally unrelated namespaces that should be aot compiled? aot is transitive, so aot compiling an ns also aot compiles all its deps
10:13wes__move-up takes a single map and a vector of maps, finds the index of the item in the vector and produces a new vector of maps in which the item resides at (dec index)
10:13hyPiRiontgoossens: what do you mean by two values? :aot [myns.first myns.second] will compile both namespaces, regardless of their dependency to one or another
10:13tgoossenshyPiRion,
10:14justin_smithwes__: OK, that should totally work
10:14tgoossenshyPiRion, That is what i mean
10:14hyPiRionah, nice
10:14tgoossensthanks :)
10:14wes__so, (reduce move-up seq-of-items vec-of-maps) ??
10:14lazybotwes__: Uh, no. Why would you even ask?
10:15justin_smithwes__: the vec should come before the seq
10:15justin_smithsince you can't update a seq by index
10:16wes__ok, i'll give it a go.
10:16justin_smithand more generally, reduce takes its accumulator before the sequence it walks
10:20Olajyd_Please how can I compare date-values in clojure to determine which is greater?
10:20justin_smithOlajyd_: compare
10:20justin_smith,(java.util.Date. 0)
10:20clojurebot#inst "1970-01-01T00:00:00.000-00:00"
10:20justin_smith,(java.util.Date.)
10:20clojurebot#inst "2015-08-05T14:21:01.504-00:00"
10:21justin_smith,(compare (java.util.Date.) (java.util.Date. 0))
10:21clojurebot1
10:21pbxnice demo justin_smith
10:21justin_smithheh, thanks
10:23gfredericks$google gfredericks compare
10:23lazybot[gfredericks (Gary Fredericks) · GitHub] https://github.com/gfredericks
10:23gfrederickswell https://github.com/gfredericks/compare
10:24gfredericksif you don't like writing your own -1/0/1 logic
10:24justin_smithgfredericks: handy!
10:24oddcullyand if you don't need it for sorting, there is also .before/.after
10:24gfredericksjustin_smith: !!!
10:25wes__So, I tried this and it gives a vector of vector of vector of maps
10:26sdegutisGiven (defn foo [x y z] ...) and (defn bar [x y] (foo x y z)), how can I redefine bar so to remove the parameter redundancy?
10:27sdegutisHi.
10:29sdegutisI thought it would have something to do with partial, but nope.
10:29wes__(move-up 'b ['a 'b 'c]) => [b a c]
10:29justin_smithwes__: (defn move-up [v i] (let [pos (.indexOf v i)] (if (pos? pos) (-> v (assoc pos (v (dec pos))) (assoc (dec pos) i)) v)))
10:29justin_smithwes__: needed the if for cases where i is not in the vec, or i is already at position 0
10:30sdegutisClearer definitions are probably (defn foo [x y z] ...) and (defn bar [x y] (foo x y "some z")),
10:30justin_smith,(defn move-up [v i] (let [pos (.indexOf v i)] (if (pos? pos) (-> v (assoc pos (v (dec pos))) (assoc (dec pos) i)) v)))
10:30clojurebot#'sandbox/move-up
10:30justin_smith,(move-up 'b '[a b c])
10:30clojurebot#error {\n :cause "No matching method found: indexOf for class clojure.lang.Symbol"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: indexOf for class clojure.lang.Symbol"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]\n [clojure.lang.Reflector invo...
10:30justin_smith,(move-up '[a b c] 'b)
10:30clojurebot[b a c]
10:30justin_smithoops I flibbed your args
10:30justin_smithbut it works otherwise :)
10:30perplexa:D
10:32justin_smithshorter: (defn move-up [v i] (let [pos (.indexOf v i)] (if (pos? pos) (assoc v pos (v (dec pos)) (dec pos) i) v)))
10:33justin_smithwes__: I recommend that arg order, because the idiom in clojure is that the associative item comes first
10:33justin_smithwes__: and even more important, the rules of reduce says the accumulator (the vector) must be the first arg
10:34perplexa,(move-up '[a b c] 'c)
10:34clojurebot#error {\n :cause "Unable to resolve symbol: move-up in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: move-up 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: move-up i...
10:34justin_smith,(defn move-up [v i] (let [pos (.indexOf v i)] (if (pos? pos) (assoc v pos (v (dec pos)) (dec pos) i) v)))
10:34clojurebot#'sandbox/move-up
10:34perplexa,(move-up '[a b c] 'c)
10:34clojurebot[a c b]
10:34justin_smithnow try - clojurebot is forgetful :)
10:34perplexahehe
10:34perplexaalzheimerbot ;p
10:35wes__oh, so to write a function that is reducable, I've got to have the accumulator as the first argument?
10:35justin_smithyes, always
10:35Olajyd@justin_smith: How can i comapre date values in clojure?
10:35wes__Thanks. That's a great help.
10:35sdegutisWait!
10:35sdegutisIs this even possible!?
10:35justin_smithOlajyd: didn't I just show that above?
10:36justin_smithOlajyd: the compare function will return -1, 0, or 1 depending on how two dates compare
10:36sdegutisI actually have this: (defn change [db entity attr value] ...) and (defn change-text [db entity value] (change db entity :text value))
10:36sdegutisCan I simplify the definition of change-text at all?
10:37sdegutisI tried using partial but I must be doing it wrong because that helps naught.
10:37sdegutis*not
10:37justin_smithsdegutis: maybe flatland/useful has some kind of flipped partial
10:37justin_smithsdegutis: partial works from the wrong direction for your code
10:38sdegutisAhh right, I have to fill in the innards when I don't have them yet.
10:38Olajyd@justin_smith.. I’m sorry can’t find the compare function, is it the `move-up` function you wrote?
10:38justin_smithOlajyd: it's called "compare"
10:38oddcully,(doc compare)
10:38clojurebot"([x y]); Comparator. Returns a negative number, zero, or a positive number when x is logically 'less than', 'equal to', or 'greater than' y. Same as Java x.compareTo(y) except it also works for nil, and compares numbers and collections in a type-independent manner. x must implement Comparable"
10:38justin_smithOlajyd: I literally showed how to use compare right after you asked the first time
10:39justin_smith,(compare (java.util.Date.) (java.util.Date. 0))
10:39clojurebot1
10:39justin_smiththat result means the first one was greater
10:39Olajyd@justin_smith I’m sorry i got disconnected when I asked the first time :)
10:39justin_smithoh, OK
10:40justin_smithI have joins/parts/disconnects turned off on this channel, it's too noisy otherwise
10:40oddcullyOlajyd: there is also a log: http://clojure-log.n01se.net/
10:41Olajyd@oddcully Thanks for helping me out on saturday :)
10:42oddcullyyw, but i forgot ;)
10:43Olajyd@oddcully : I have a vector of dates in the format (yyyy/MM/dd) and I want to be able to get the maximum date using `reduce`
10:43justin_smithOlajyd: you could also use max-key
10:43gilliardOlajyd: that date format will sort lexicographically, if they're strings.
10:44justin_smith, (apply max-key #(.getTime %) [(java.util.Date. 0) (java.util.Date. 1) (java.util.Date. 2)])
10:44Olajydreally @gilliard
10:44clojurebot#inst "1970-01-01T00:00:00.002-00:00"
10:44justin_smithOlajyd: the above will always return the largest date in a sequence
10:45oddcullydates in the "formst X" are just strings right?
10:45justin_smithoh, I thought you meant you had real dates (as in java.util.Date.)
10:45gilliard,(max ["2015/5/2" "2015/11/10" "2010/20/9"])
10:45clojurebot["2015/5/2" "2015/11/10" "2010/20/9"]
10:45gilliard,(apply max ["2015/5/2" "2015/11/10" "2010/20/9"])
10:45clojurebot#error {\n :cause "java.lang.String cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers gt "Numbers.java" 229]}]\n :trace\n [[clojure.lang.Numbers gt "Numbers.java" 229]\n [clojure.lang.Numbers max "Numbers.java" 4027]\n [clojure.core$max invokeStatic "core.clj" 1091]\n ...
10:45justin_smithgilliard: first of sort
10:45oddcullyshouldn't this be just be the last of a string sort?
10:45gilliardjustin_smith: you got it ;)
10:45justin_smithoddcully: oh right, or first of a reversed sort
10:46justin_smithor a reduce using compare (compare works on strings)
10:46oddcullyat least of MM/dd is actually used (leading zeros)
10:48justin_smith,(reduce #(case (compare % %2) 1 % -1 %2 0 %1) ["1970/02/11" "1914/03/01" "0000/00/00"])
10:48clojurebot#error {\n :cause "No matching clause: 6"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching clause: 6"\n :at [sandbox$eval102$fn__103 invoke "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval102$fn__103 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.PersistentVector reduce "PersistentVector.java" 323]\n [clojure.core$reduce invokeStatic "core.clj" 6517]\n [clojure.core$re...
10:48justin_smitherr
10:48justin_smithcompare can return 6, OK
10:49oddcully`Returns a negative number, zero, or a positive number...`
10:49gilliardye just 0, more than 0, or less than 0
10:49justin_smith,(reduce #(if (pos? (compare % %2)) %1 %2) ["1970/02/11" "1914/03/01" "0000/00/00"])
10:49clojurebot"1970/02/11"
10:49Olajydthanks @justin_smith :)
10:52justin_smithOlajyd: the funny part is that my initial answer still works even though I was wrong about your data type, because compare is just that general
10:52Olajyd@justin_smith the solution works for me
10:52Olajyd:)
10:52oddcullyrandom fun wikipedia fact: on 1914-03-01 china joined the Universal Postal Union
10:54justin_smithhaha
10:58wes__justin_smith Using your move-up works (move-up [f1 f2 f3] f2) => [f2 f1 f3] but (reduce [f1 f2 f3] '(f2 f3)) => [f1 f2 f3] where I expect [f2 f3 f1]
10:59justin_smithwes__: hmm
10:59justin_smithwes__: it works?
11:00justin_smith, (defn move-up [v i] (let [pos (.indexOf v i)] (if (pos? pos) (assoc v pos (v (dec pos)) (dec pos) i) v)))
11:00clojurebot#'sandbox/move-up
11:00justin_smith, (reduce move-up '[f1 f2 f3] '(f2 f3))
11:00clojurebot[f2 f3 f1]
11:04wes__justin_smith yeah, it works thanks. I just learned that '(f2 f3) is not the same as (list f2 f3)
11:05justin_smithoh, yeah :)
11:06justin_smith[f2 f3] works too - reduce can accept vectors, anything that seq works on
11:41wes__So, I got move-down working as well, but I discovered that the order of the items in the reduce function is important. How do I sort a seq by their index in a vector?
11:44wes__(sort #(.indexOf '[f1 f2 f3 f4 f5] %) '(f3 f5 f1))
11:45justin_smith,(sort-by #(.indexOf '[f1 f2 f3 f4 f5] %) '(f3 f5 f1))
11:46clojurebot(f1 f3 f5)
11:46jonathanjhrm, how would i write a function that wraps another function and logs its arguments to a file? i tried: (defn log-to [path f] (with-open [fd (writer path)] (fn [s] (spit fd s) (f s))))
11:46jonathanjbut i guess (with-open) closes as soon as log-to returns
11:46justin_smithjonathanj: yeah, only use with-open if you want to close the file in that block
11:47justin_smithjonathanj: otherwise you can use .write, and make your own arrangements to close the file...
11:47wes__Missed it by `that` much. thanks
11:47justin_smithwes__: yes, you were quite close
11:47jonathanjokay, well as a crappy interim measure i can just open the file and write to it everytime the inner function is invoked, how do i open a file for appending?
11:47justin_smithwes__: do you ever look at http://conj.io ?
11:48justin_smithjonathanj: it's an optional arg to writer
11:48justin_smith,(doc clojure.java.io/writer)
11:48clojurebot"([x & opts]); Attempts to coerce its argument into an open java.io.Writer. Default implementations always return a java.io.BufferedWriter. Default implementations are provided for Writer, BufferedWriter, OutputStream, File, URI, URL, Socket, and String. If the argument is a String, it tries to resolve it first as a URI, then as a local file name. URIs with a 'file' protocol are converted to local...
11:48wes__justin_smith no. Thanks for showing it to me.
11:49jonathanji'm reading the docs for writer but there is apparently no mention of what the arguments are?
11:49justin_smithwes__: I asked because with the way conj.io is layed out, you likely would have found sort-by :)
11:49jonathanjthe optional arguments, i mean
11:49justin_smithjonathanj: hmm, I know they are around somewhere
11:49jonathanjlooks like it's just :append
11:49jonathanj(looking at an example on conj.io)
11:50justin_smithjonathanj: source reveals it https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj#L69
11:50jonathanj:append true, at least
11:50justin_smithjonathanj: useful site :)
11:51jonathanjwhat are the differences between conj.io and clojuredocs?
11:51justin_smithjonathanj: different maintainers, conj.io is more ambitious
11:51jonathanjhow so?
11:52justin_smithit wants to document libs outside of clojure itself eventually
11:52jonathanjah, nice
11:52justin_smithjonathanj: arrdem and andyf could probably tell you about the differences in more detail (they maintain the two sites)
12:00jonathanji remember some clojure library that implemented a grammar-based parser based on BNF (or something that was really close to it), but i can't remember the name of the library
12:01jonathanjoh instaparse
12:01justin_smithinstaparse?
12:01blkcatinstaparse?
12:01clojurebotinstaparse is lovely
12:01clojurebotinstaparse is lovely
12:01justin_smithhahaha
12:01blkcati use instaparse and can confirm that it rocks
12:01justin_smith^ the beginning of a musical about parsing
12:01justin_smith(to the tune of "monorail" of course)
12:26jonathanjso if i have an instaparse rule like `word = letter+ <letter> = #'[a-zA-Z]'` i end up with :word ["h" "e" "l" "l" "o"]
12:27jonathanjit looks like the preferred way to turn that into a string is `(transform {:word str} ...)`?
12:27jonathanji can't indicate this in the grammar some how?
12:28sdegutisI just used clojure.data/diff
12:28sdegutisand clojure.set/map-invert, I bet you didn't even know it existed!
12:30jonathanjthe problem i guess is that (transform {:word str} ...) turns [:word ["h" "i"]] into "hi", i'd prefer not to destroy the tag
12:32alex_engelbergjonathanj: I'm missing context (just joined channel) but I may be able to help with your instaparse problem
12:32jonathanjalex_engelberg: hello!
12:32jonathanjalex_engelberg: firstly, instaparse is a wonderful piece of software, thank you very much
12:33alex_engelbergthank you! and thank YOU for using it! :)
12:33sdegutisMy task this week is to write a parser via a purely immutable state machine.
12:34alex_engelbergI'm an IRC noob, is there a way to look at previous messages before I joined?
12:34alex_engelbergOr is the solution to just always stay logged in? :)
12:34sdegutisalex_engelberg: neither
12:34arohneralex_engelberg: yes, stay logged in. There are also bot loggers
12:34sdegutishttp://logs.lazybot.org/irc.freenode.net/%23clojure
12:34sdegutisalex_engelberg: just use that link. only works for here.
12:34jonathanjalex_engelberg: i'd like not to destroy the tag being transformed
12:34arohnerhttp://clojure-log.n01se.net/
12:34oddcullyalex_engelberg: http://clojure-log.n01se.net/
12:34sdegutisarohner: I prefer lazybot's
12:34alex_engelbergThanks
12:34oddcullyalex_engelberg: and instaparse is fscking awesome!
12:35jonathanjalex_engelberg: (insta/transform {:word str} [:word "h" "i"]) ends up losing the structure
12:35sdegutisoddcully: instaparse has nothing to do with checking or interactively repairing filesystem consistency
12:35alex_engelbergjonathanj: you want [:word "hi"]?
12:35jonathanji realise i can probably do something like {:word (put-the-tag-back :word str)} but i'd like to avoid repeating myself if it's possible
12:36jonathanjalex_engelberg: yes
12:36alex_engelbergYou could cleverly write your grammar with extra layers that are transformed in different ways
12:36alex_engelbergword = word2
12:36alex_engelbergword2 = #'[a-z]+'
12:36alex_engelbergAnd just transform word2
12:36jonathanjso produce something like [:word [:letters "h" "i"]] and transform letters with str?
12:37alex_engelbergyes.
12:38alex_engelbergI don't know enough about instaparse innards to know how much slower that would make the parser. The "put-the-tag-back" transformer would be the best place to do that work, efficiency-wise. I'd say it's probably a negligible difference though.
12:39jonathanji guess that could work
12:39jonathanjthanks
12:40alex_engelbergjonathanj: no problem
12:40alex_engelbergI'm seeing a potential bug with clojure.tools.reader and cljs.tools.reader.
12:41alex_engelberg(clojure.tools.reader/read-string "018") => null pointer exception
12:42alex_engelbergNote that this is an invalid octal number, and throws a more user friendly number format exception in clojure.lang.LispReader.
12:42alex_engelbergOn cljs (and I'm not sure this is a bug or a feature), (cljs.tools.reader/read-string "018") => 18
12:42alex_engelbergIn other words, invalid octal numbers are simply parsed as decimal.
12:45alex_engelbergFor comparison, (clojure.tools.reader/read-string "017") => 15, and same with cljs
13:25puredangeryou could use that as a really weird platform detector
13:26Bronsaalex_engelberg: definitely a bug
13:29justin_smithpuredanger: heh, for when cljc is just too easy
13:34Bronsaalex_engelberg: fixed in tools.reader master
13:57jonathanji know that ztellman's libraries aren't terribly popular here but can anyone suggest why i might want to use core.async over manifold streams?
13:58justin_smithjonathanj: what makes you think his libs are unpopular?
13:58justin_smithjonathanj: core.async is inherently "push", manifold can do push or pull
13:58justin_smith(that's one reason)
13:58jonathanjjustin_smith: i just don't see a lot of conversation around them here
13:59jonathanjand the mailing lists are very low volume
13:59jonathanjwell, the aleph list anyway, i don't even think there are lists for his other libraries
13:59justin_smithjonathanj: ztellman did a great talk at the last conj comparing manifold, core.async, and prismatic/graph that explains them all on a continuum of design
13:59amalloyjonathanj: higher volume than most other clojure libraries, which have no ML at all
14:00jonathanjjustin_smith: oh that sounds pretty great, i don't suppose you have a link or title of the talk for me?
14:00justin_smithjonathanj: if you really want to understand how manifold relates to core.async, I'd check out that talk - it's on youtube
14:00amalloyjustin_smith: i don't quite understand what you mean by core.async being push-only
14:00justin_smith$google ztellman manifold clojure conj
14:00lazybot[Clojure/conj 2014 Notes - Forays into simplicity] http://eigenhombre.com/clojure/2014/11/27/conj-notes/
14:00amalloylike you can only push things into channels, and you can only pull things out, right?
14:01jonathanjjustin_smith: i'm guessing that's not the one?
14:01justin_smithjonathanj: it's on youtube, one moment
14:01jonathanjhttps://www.youtube.com/watch?v=1bNOO3xxMc0 ?
14:02justin_smithnope, that's from clojure/west
14:02justin_smithjonathanj: this one https://www.youtube.com/watch?v=3oQTSP4FngY
14:02jonathanjjustin_smith: thank you
14:04justin_smithamalloy: I wish I could remember the concrete details (I should have made a blog post about this), I was making an app where a lazy-seq was abstracting over input from a core.async channel, and it was "buffering" an item at a time
14:05amalloyas opposed to waiting until you seq to <! an item?
14:05justin_smithamalloy: I actually talked to ztellman about why this happened, and the explanation ended up being that lazy-seqs were a "pull" abstraction, and core.async is a "push" abstraction
14:06amalloyyes, that i agree with
14:06justin_smithand manifold is more flexible (I ended up going another route entirely in our app though)
14:06justin_smithnow I want to make a minimal example (another thing on my "get around to it" list)
14:08jonathanjin the first 2 minutes of both of those talks, ztellman says "we don't just write software to raise the ambient temperature of the room"... haha
14:44eriktjacobsenAny critiques / improvements on a pattern that will take a list of maps, search for partial duplicates and remove them? So perhaps matching dupes on 2-3 keys, with option to customize which item is picked as the final de-duped one?
14:44eriktjacobsenThis is what I came up with: (defn remove-dupes [key-fn sort-fn compare-fn items]
14:44eriktjacobsen (->> (group-by key-fn items)
14:44eriktjacobsen (map (fn [[_ entries]]
14:44eriktjacobsen (first (sort-by sort-fn compare-fn entries))))
14:44eriktjacobsen (remove nil?)
14:44eriktjacobsen flatten))
14:44oddcullyfirst concern: not using refheap, pastebin, ...
14:45eriktjacobsenhttp://pastebin.com/EDpr1pHy
14:45eriktjacobsenWill remember
14:45oddcullycool
14:46justin_smitheriktjacobsen: you may want to use group-by, if you have a function that will return the same result for all maps that should be considered dups (maybe select-keys ?)
14:47justin_smith,(group-by #(select-keys % [:a :b]) [{:a 0 :b 1 :c 2} {:a 1 :b 1 :c 2} {:a 0 :b 1 :c 42}])
14:47eriktjacobsengroup-by is the first call actually, I’m often passing in something like “#(clojure.string/join "-" ((juxt :partner :year :month) %))”
14:47clojurebot{{:a 0, :b 1} [{:a 0, :b 1, :c 2} {:a 0, :b 1, :c 42}], {:a 1, :b 1} [{:a 1, :b 1, :c 2}]}
14:48eriktjacobsenOh I don’t have to string that / join do I… interesting right
14:48amalloyfirst of sort is not right in many scenarios; are you sure you can't use max-key?
14:48justin_smithright, you can use anything as a key in clojure
14:48sdegutisI'm back.
14:49justin_smitheriktjacobsen: also, use mapcat identity instead of remove nil / flatten
14:49justin_smithit replaces both, and is better behaved
14:49eriktjacobsenamalloy: I was intending to sometimes pass in something as simple as pulling an integer key and using < or > as compare, but also wanted to pass in ability to use a string or regex type compare to sort them…. so max-key would seem to force that
14:51eriktjacobsenI’ll look into that (actually the remove nil / flatten I think is un-needed since this one does first, which will always return a record) this was actually from separate version that instead of outputting list of de-duped, it instead gave list of stuff to REMOVE (so I did a (when (> (count %) 1) (rest items))
14:51eriktjacobsenWill do that though since I need both version
14:52hellofunkare bitwise operations supported on 64bit integers in clojure
14:53eriktjacobsenjustin_smith: I dont think I knew that… could you explain how mapcat identity removes nils ? isn’t (identity nil) = nil? I would expect a single nil in the output
14:54hiredmaneriktjacobsen: it is, he meant apply concat
14:55hiredmanor just turn the map in to a mapcat if the function returns nil or a collection
14:56eriktjacobsenhiredman it does actually work though… it flattens and removes the nils. I just dont understand why. http://pastebin.com/ArDbeyyW
15:00eriktjacobsenoh duh concat doesn’t concat nils…. totally forgot. that seems like odd behavior though. interesting though
15:02eriktjacobsenThanks amalloy justin_smith. Learn something new everyday
15:05TEttingerhellofunk: yes. I think the default is to use long (64-bit signed) integers
15:05kwladykaREPL can affect memory usage in some way?
15:05kwladykainstead of running directly from jar file?
15:05TEttinger,(bit-or (bit-shift-left 0xFFFFFFFF 15) 0xFFFFFFFF)
15:05clojurebot140737488355327
15:06kwladykawhat i see yes, but i am not sure
15:06TEttingerkwladyka: yeah, the REPL has to store previous evaluated arguments as *1, *2, *3 etc.
15:07kwladykais a way to test app usage memory without compile it to jar?
15:08TEttingerI think it also needs to compile code differently, but I'm not sure how. jar (or uberjar for executables, or whatever war/uberwar stuff EE webdev needs) should probably be the default when testing performance if you're deploying that way
15:11TEttinger(I think it's likely that running a jar with the right memory settings, -Xms64m to start small and garbage collect quickly if not using all of the allocated memory, -Xmx512m or whatever the max you might need and can support is, mess with GC options, make sure you're using --server if you need speed, --client may help with memory at the expense of speed...)
15:11TEttingeror is it -server
15:12TEttingeranyway, running a jar with the right memory settings is very different from running a jar with very wrong memory settings
15:12TEttinger-Xms16G
15:12TEttinger"why is my jarva using so much rams?"
15:13kwladykaTEttinger, i use profiler to check memory usage so i see not only how many is allocated, but how many is really used
15:13kwladykabut as i see REPL affect results as i see
15:13kwladykabut i am not sure, i am researching it now :)
15:15kwladykait can be noob question, but.. if i will do lein compile can i run app without doing lein uberjar?
15:15TEttingerI'm guessing uberjar is pretty slow for your project?
15:16TEttinger$google leiningen faster
15:16lazybot[Faster · technomancy/leiningen Wiki · GitHub] https://github.com/technomancy/leiningen/wiki/Faster
15:17TEttingerclojurebot: slow |no| more! https://github.com/technomancy/leiningen/wiki/Faster
15:17clojurebotYou don't have to tell me twice.
15:17TEttinger~slow
15:17clojurebotslow no more! https://github.com/technomancy/leiningen/wiki/Faster
15:17sdegutisI'm back again.
15:18TEttingeryour nick is an anagram for degu sits. degus are kinda cute little creatures.
15:19Bronsasdegutis: you don't have to announce it everytime
15:19sdegutisBronsa: Phew, thanks.
15:20TEttingerBronsa: I'm here currently
15:20oddcully~logs
15:20clojurebotlogs is http://clojure-log.n01se.net/
15:21oddcullyah i knew it
15:21TEttingersdegutis: they're a pretty good thing to have in your name. https://en.wikipedia.org/wiki/Degu#/media/File:Octodon_degus_-Artis_Zoo,_Netherlands-8b.jpg
15:21amalloysdegutis just needs like one more letter to have a lot of fun anagrams
15:21amalloyduet siege
15:22sdegutisOh man. Do I need to go back to /nick sed-utils?
15:22TEttingerDegus are extremely intelligent and have a good ability to solve problems. well there you go!
15:32sdegutisIs there a way to check if every item in a collection is equal besides (apply = coll) ?
15:33amalloysure, there are lots of worse ways
15:33gfrederickswhat don't you like about (apply = coll)?
15:33kwladykasomething is wrong with my profile file? https://www.refheap.com/58124c0debd9118eb4c6e7ab3 Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method.
15:33amalloygfredericks: i'll tell you what *i* don't like about (apply = coll)
15:33amalloybut i bet you already know: it doesn't work on empty colls
15:34gfredericksI didn't know that would be it
15:34amalloy(i regard this as a bug in = but nobody really cares)
15:34gfredericksbut I think I might understand why it does
15:34opqdonutyeah (=) should be true
15:34opqdonutI agree
15:34gfredericks,(<)
15:34clojurebot#error {\n :cause "Wrong number of args (0) passed to: core/<"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: core/<"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 399]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 i...
15:34opqdonut(<) is less well defined than (=)
15:34gfrederickswhy is that?
15:35opqdonutor that's my knee-jerk reaction anyway, let me think
15:35amalloygfredericks: last time this came up somebody claimed it is a little bit awkward if you extend this to the < family of functions, because then < and (complement >=) are no longer the same
15:35amalloybut on reflection this is totally bunk, because they're already not the same on anything but 2 arguments
15:36opqdonutindeed
15:36opqdonutok, I guess (=) and (<) are actually pretty symmetric. if you have the n-ary versions you should also have the 0-ary version
15:36gfredericksI've always thought of these arities as being related to recursive definitions of the functions
15:37gfredericks+ and * can get all the way to 0 args because they are monoids
15:37gfredericks(in contrast with / and -)
15:37sdegutisWhat's the opposite of some
15:38gfredericksand and or are also monoids I think?
15:38amalloygfredericks: yes, they are
15:38gfredericksso you can't get 0 args for = and < just by the monoid reasoning, it'd have to be something else
15:38amalloygfredericks: the problem is that some and every? do extend down to empty collections, and (apply = coll) "should" be the same as (every? #(= % (first coll)) coll)
15:38hiredmanwell
15:39gfredericksin haskell that'd throw an exception
15:39amalloygfredericks: i don't think so
15:39gfredericksfor an empty list
15:39amalloyno, because every undefined [] = true
15:39amalloyTrue
15:39gfrederickswell arguably that has more to do with how the code is structured
15:40gfredericksif you wrote it (let [x (first coll)] (every? #(= % x) coll))
15:40amalloygfredericks: still would work fine in haskell, because lazy
15:40gfredericksI feel like this is a meaningful point somehow
15:40amalloyyou can't make that throw, because you can't possibly use the value if the list is empty
15:40sdegutisIs there a shorter way of (not (some f xs)) ?
15:40gfredericksamalloy: sure but the language being lazy is a side detail here
15:41gfrederickssdegutis: not-any?
15:41sdegutisAhhh.
15:41sdegutisSilly lack of consistent naming.
15:41amalloyi don't think so. if you're claiming that my proposed equivalent would throw an exception in haskell, it seems like the way haskell behaves is pretty relevant
15:41sdegutisEarlier I looked for any? and couldn't find it. Turns out it was some.
15:41kwladykaseriously what am i doing wrong with lein uberjar, why am i gettign this error? All looks like is should in poject.clj https://www.refheap.com/58124c0debd9118eb4c6e7ab3
15:41opqdonutsdegutis: because it returns non-booleans too
15:41Bronsasdegutis: any? would imply a boolean return.
15:41gfredericksamalloy: I'm appealing to one part of the behavior of haskell and not the other part :P
15:42opqdonutbut yeah it trips people up
15:42sdegutisAhhh right, Clojure makes types multi-task.
15:43amalloygfredericks: so your argument seems to be that in two consistently-defined languages, my suggested identity would hold, but in a theoretical bad language that's a mix of both, a restructured version of my identity would throw an exception
15:43amalloy(eg, in java you would be right)
15:43gfredericksso let's think about it recursively
15:44gfredericksif you add another element to an = expression, the expression is true if that element equals the "first" element in the expression and if the rest of them are equal
15:44gfredericksi.e. (= a b1 b2 ...) is (and (= a b1) (= b1 b2 ...))
15:44gfredericksand the base case is that (= bn) is true
15:44sdegutisThanks gfredericks.
15:45gfredericksmy point is that the natural base case in this formulation is 1 arg
15:45gfredericksand this works for all the ordering predicates
15:45sdegutisWhat's a striking way to test if coll contains :a or :b (or both)?
15:46gfredericksso adding a 0-arg version feels like an unrelated "alternate base case" or something
15:46gfrederickssdegutis: (some #{:a :b} coll)
15:46sdegutisAmazing.
15:46sdegutisThanks gfredericks. You won twice in a row.
15:46kwladykaoh i have to use :gen-class ...
15:48amalloygfredericks: doesn't apply to not=, right?
15:48gfredericks,(doc not=)
15:48clojurebot"([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"
15:49gfredericks(not= a b1 b2 ...) is (or (not= a b1) (not= b1 b2 ...))
15:49gfredericks,(not= 42)
15:49clojurebotfalse
15:49gfredericksand the base case is (not= bn) is false
15:49gfredericksI just did that off the top of my head, hadn't thought about not=
15:49gfredericksso not sure if it makes sense
15:50gfredericksamalloy: I think a better approach to what I was trying to say w/ haskell would be "You can't formulate it that way mathematically"
15:51gfrederickse.g., with set theory
15:58hiredmanisn't equivalence in math a binary operation?
15:58hiredmanerr
15:58hiredmanrelation
15:58gfredericksyeah
15:59gfredericksthat doesn't stop you from making it variadic though
15:59gfredericksthe question is does it make sense to have the (=) base case when you do
15:59hiredmandoes it make sense to have a base case (= b) ?
15:59gfredericksI think it makes as much sense as (+)
16:00gfredericksand I think (=) makes less sense
16:00gfredericksthat's the side I'm arguing for anyhow
16:00gfredericksnot gonna get in a fight about it
16:00hiredmanand if (= b) makes sense even if = is a binary relation, then why doesn't (=) make as much sense?
16:01gfrederickswell that's what I was trying to argue; in particular I think (+) => 0 is a "natural" base case for + and that (= b) => true is a "natural" base case for =
16:01gfredericksbecause they both have nice recursive definitions that use those base cases
16:01gfredericksI don't know of a recursive definition for = that uses (=) true as a base case
16:04justin_smithgfredericks: I guess there is (apply = c), which should return true if c is nil / empty
16:05justin_smithintuitively at least
16:05amalloyjustin_smith: that was the base case of this discussion
16:05justin_smithamalloy: d'oh! shows me for replying before I catch up on the scrollback
16:06amalloyit seeems like gfredericks is arguing that the usual description of (apply = xs) as "are all the things in xs equal to each other" is incorrect
16:06amalloybecause if you take that description it is obvious that (=) is true
16:07hiredmangfredericks: that is an interesting point
16:07sdegutisThanks for all your help.
16:07gfredericksamalloy: I might argue that that english phrasing is a bit ambiguous about what the empty case means
16:07gfredericksdunno maybe not
16:07gfredericksenglish hard
16:08kwladykaused PS old gen <- if i have something like that in my app with 209 MB in profiler... what is it mean? Am i doing something wrong?
16:08kwladykait is about memory
16:09amalloyi just realized i don't have to put up with this sass. i can just +b gfredericks
16:09gfrederickso_O
16:09amalloyit will be as foretold in the prophecies by andyf. amalloy will rule with an iron fist
16:10hiredmanthere exists an equivalence class E for all item x in list l where x is a member of E
16:12gfrederickshiredman: quoting from some formalization of something?
16:12hiredmanno, trying to piece one together
16:13hiredmanthat seems to be a statement of equality which would allow for (=), but I forget all that stuff about which binders → existence of whatever
16:13kwladykaech i totally don't know how to get conclusions from profiler :/
16:19justin_smithkwladyka: you could see if the allocated size gets bigger if you run the code twice, you could profile subprograms to try and narrow down what is allocating
16:19hiredmanthe tricky thing is, I don't think any language has first class equivalence classes, but you can define one given at least one member of the equivalence class and some kind of equality operator
16:20hiredman(which of course is circular, we are trying to define equality)
16:20hiredmanso you end up with recursion that bottoms out with a single element
16:22kwladykajustin_smith, https://www.dropbox.com/sh/fekagh9kp77f057/AAC0dCeunm2MDt0qWRw8f4lda?dl=0 look at clojure-jar char vs scala char
16:23kwladykajustin_smith, in both i did 10 sec sleep before
16:23kwladykajustin_smith, both do the same...
16:23kwladykajustin_smith, i totally stack with that, i dont know how to get conclusion what is wrong
16:24kwladykajust no idea what to do now to solve that :/
16:26justin_smithugh, what a terrible gallery
16:26kwladykasorry, i dont know better to fast upload
16:27oddcullyhaha
16:27justin_smithkwladyka: it's OK, you didn't implement that gallery view, but it's terrible
16:27kwladykajustin_smith, :)
16:28justin_smiththe biggest difference there is that with clojure you have the whole compiler and all its libs in heap, with scala you do not
16:28kwladykawhy the same algorithm in scala is so fast and consume so less memory, it makes me sick
16:28justin_smithbut that isn't going to cause your speed problem
16:29kwladykajustin_smith, but clojure-jar.png is for uberjar file
16:29justin_smithuberjar has the entirety of clojure in it
16:29justin_smiththere is no standalone option with clojure, unlike scala
16:29justin_smiththe feature simply doesn't exist
16:29Bronsa(inc puredanger) ;; thanks for CLJ-1093
16:29lazybot⇒ 62
16:30puredangerdid you catch the outcome?
16:30justin_smithbut the extra ram used by clojure itself is not the cause of your speed difference, beyond the few seconds it takes clojure to bootstrap itself
16:30kwladykajustin_smith, do you know what used PS old gen can mean? maybe if you will see the code?
16:30justin_smithkwladyka: I've looked at your code already, it's complicated and I have my own hard debugging to do
16:30justin_smithsorry
16:30kwladykajustin_smith, because of about 10 sec sleep before counting it shouldnt affect the time
16:31kwladykajustin_smith, but didnt see any technical anti-performance code? :)
16:32Bronsapuredanger: yes. not exactly what I was hoping for but I'm fine with it, it's consistent with the doc and CLJ-1460
16:32puredangerBronsa: he also addressed your other question on the (defn ^{:tag foo} a [])
16:32Bronsayup saw that too
16:32kwladykajustin_smith, any hints what more can i do t solve that? i dont have more ideas....
16:33justin_smithkwladyka: I've looked at your code multiple times already, I suggested the things I thought might be issues, but I really can't fix this performance issue for you
16:33kwladykais it possible it is because of Clojure, not my bug? Just Clojure do this longer or something like that?
16:34TimMcgfredericks: Regarding (=), I like the invariant that remving an element from the input never turns the output from true to false.
16:34kwladykajustin_smith, each time code was improved, i did big step, but now i stack totally what can i do more, i rewrited algorithm to work like this one in scala, but even now performance is much worst
16:35justin_smithkwladyka: if you switch some of your data from vanilla hash-maps to defrecords (which are in most ways identical in behavior to hash-maps, so it won't be a big change to your code) the profiler might give you easier to use data
16:35TimMcgfredericks: Or put more generally, "= returns true iff no two inputs are unequal" -- and if there are no two inputs, it is vaciously true.
16:35TimMc*vacuously
16:35kwladykajustin_smith, anyway thank you so much for trying help me with that problem.
16:35puredangerBronsa: meaning it now has behavior prior to direct linking
16:36kwladykajustin_smith, defrecords performance is better?
16:37justin_smithkwladyka: it shows up as a different datatype in your profiler
16:37justin_smiththus you can see where all that ram is going
16:37kwladykajustin_smith, oh
16:37justin_smithlike which kind of object is being created to such excess (if that is in fact the issue). Also try CPU profiling, see which methods are doing the most work.
16:39kwladykait is hard to say what is the problem, but for sure it consume too much memory vs scala solution
16:39hiredmanhttps://gist.github.com/hiredman/2aa99f1c24634e0fd9de
16:39Bronsapuredanger: I think there's still a difference but it's probably not meaningful
16:40kwladykai mean if it is CPU problem, shouldnt be....
16:40kwladykaCPU didnt cross 80% during all counting
16:40justin_smithkwladyka: I already told you why the ram usage is different, clojure loads the full compiler into your app at runtime, scala does not
16:41sdegutisFor anyone here looking to practice Clojure or sharpen their Clojure skills, this is an excellent Java file for porting to pure Clojure using every Clojure technique in the book to shorten it by a huge degree: https://raw.githubusercontent.com/slagyr/latlngtz/master/src/latlngtz/TimezoneMapper.java
16:41hiredmanso if any language had first class equivilance classes, it would be natural to define equality using them in a way where (=) would work, but having first class ecs seems very impractical, so what is left is the recursive definition of = which relies on (= b) working
16:41hiredmanoops, deleted the wrong line (emacs repeats my inputs)
16:42kwladykajustin_smith, yes but anyway it consume too much memory, i am afraid it is connected with Used PS old gen, it can be some track, but i dont understand what it is :)
16:42kwladykawhat can cause that
16:43kwladykabut maybe it is not my code but Clojure...
16:43hiredmanand since you need a base case for (= b) adding another for (=) seems inelegant
16:43Bronsapuredanger: actually I'm not sure rettag is very useful right now? it seem to only accept stuff like (defn ^long x [] ..) which don't make sense at runtime since long is evaluated to #<clojure.core$long..>
16:44BronsaI'll try to look into it if I have some time tomorrow and let you know
16:45gfrederickshiredman: "Do all these elements belong to one class?" ← doesn't make sense for no elements
16:46hiredmangfredericks: https://en.wikipedia.org/wiki/Universal_quantification#The_empty_set
16:46justin_smithkwladyka: if I start clojure.jar, with no other libs loaded (not even lein or nrepl) I see a vsz/rss of 7056368 86412
16:46justin_smiththat's a baseline, it won't go smaller
16:47gfrederickshiredman: I'm talking about (->> coll frequencies count (= 1))
16:47gfredericksor group-by if you like
16:48kwladykajustin_smith, i am thinking more about maybe Clojure remember some outputs for some magic reasons
16:48kwladykacash that for future for me :)
16:49xificurChiccup, garden, sablono - all these are used to generate html/css on the fly? I thought the purpose is to have it defined in clojure, process the definitions and generate static files. Am I misinterpreting something here?
16:50hiredmansure, right, you can obviously write the code differently, and via church-turing and get something in some other logic that will do the same
16:50justin_smithxificurC: static is relative, you can make a compile time step that outputs your resources if there is no relevant run time input
16:51kwladykaxificurC, http://clojure.wladyka.eu/posts/2015-06-01-template-libraries.html you can read my opinion about template libraries
16:52gfrederickshiredman: maybe I'm just having trouble connecting (=) to equivalence classes; how do you phrase the question that (=) is asking in terms of equivalence classes?
16:53hiredmangfredericks: set theoretic notions of equality seem to be based on equivalence classes
16:54hiredman(seem to meaning I am not sure my understanding is correct, not casting doubt on the field)
16:54xificurCjustin_smith: I see, although since there's no utility functions/macros written for this I take it it's not very common to do that
16:55xificurCdoesn't computing the page hinder performance on the server?
16:55xificurCkwladyka: thanks, although it seems very biased
16:56hiredmanso I guess I don't see the argument from some formalism that handling (= b) is valid but (=) is not
16:56kwladykaxificurC, because it is my opinion base on my own experience :)
16:57amalloyjustin_smith: most of that vsize is mmapped files though, not taking up any real memory if other programs need it
16:58amalloywell, i don't know about "most". but a lot of
16:58hiredmanstructurally (= b) makes more sense, because it is a base case you need in this case, but why not handle a base case for (=) if it would make it easier for client code
17:00gfrederickshiredman: yeah I'm not saying clojure shouldn't change necessarily; though you might argue that all the theoretical hand-waving suggests that anybody calling (=) has a high probability of having done it by accident. but that's probably not true
17:00gfredericksshould (not=) be false?
17:01xificurCimpressive how 1 guy (weavejester) created so many well known web-related libraries, e.g. ring, compojure, hiccup
17:01kwladykaxificurC, yes but i guess he didnt do this alone
17:02kwladyka_guess_
17:02hiredmangfredericks: I dunno
17:02hiredmanI guess? is there a reason it shouldn't be the negation of =?
17:03gfrederickswell the argument for (=) seems to be "well *I* think it's obvious what it means" so I wondered if not= was the same way
17:03gfrederickswhere *I* isn't anybody in particular
17:03hellofunkTEttinger: i get an int out of range error if i try to go beyond 32 bits
17:04hiredmanequality is very problematic
17:04hiredmanI taught clojurebot a factoid about scala years ago, that was a quote from someone in #scala saying something like "we are so screwed on ="
17:04TEttingerhellofunk: code please
17:05hiredmanI must owe that guy a beer
17:05slesterhmm, splitting up my code is proving a bit difficult
17:05gfrederickshiredman: haha
17:05hellofunkactually the error is java.lang.IllegalArgumentException: Value out of range for int: 4294967295
17:05TEttingercooooode please
17:05TEttingerare you calling int on a large number?
17:06hiredman~scala
17:06clojurebotscala is val foo = bar ~-> 45 <~< "Fred" %% x
17:06TEttingeruse long if you need a 64-bit signed integer
17:06slesterDo a lot of people have just one giant file with all the functions in it? Seems bad, but I can't separate them into namespaces because basically all the functions call each other
17:06TEttinger,(int 4294967295)
17:06clojurebot#error {\n :cause "Value out of range for int: 4294967295"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for int: 4294967295"\n :at [clojure.lang.RT intCast "RT.java" 1198]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1198]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "...
17:06TEttinger,(long 4294967295)
17:06clojurebot4294967295
17:07hellofunkTEttinger: ah, i see the problem now. it's the API i'm using that is apparently limited to 32 bits under the hood. if i do it at the repl, no problem over 32 bits
17:08hellofunkthe stack trace reveals an intCast right before the out of range error
17:08TEttingerslester: that's a pretty general architecture problem. from my experience, games are particularly susceptible to architecture issues because of the need to have so many things affect the inherently mutable graphics code.
17:08hefestoHi. I am new at Clojure and irc... so I'm doing this the right way (if not, please say so). I am trying to use clj-antlr (https://github.com/aphyr/clj-antlr) on a project, but I keep getting java.io.FileNotFoundException: Could not locate clj_antlr__init.class or clj_antlr.clj on classpath: , compiling:(date.clj:1:1). On project.clj I add the [clj-antlr "0.2.2"] dependency and lein repl shows the previous error. ¿Does anyone see what I'm doing wro
17:08hefestong?
17:08TEttingerhey hefesto
17:09hefestoso *I hope* I'm doing this the right way
17:09slesterTEttinger: yeah... :( I'm not sure what I can do about it though.
17:09TEttingerwhat are you requiring the clj-antlr dep as in your date.clj file?
17:09hefestoyes
17:09hefesto(ns com.bm.bmi.date
17:09hefesto "Parse dates using DateExpr.g4 grammar and ANTLR"
17:09hefesto (require ['clj-antlr.core :as 'antlr]))
17:09xificurCpaste your date.clj into a pastebin
17:10hefesto(ns com.bm.bmi.date
17:10hefesto "Parse dates using DateExpr.g4 grammar and ANTLR"
17:10hefesto (require ['clj-antlr.core :as 'antlr]))
17:10hefesto(defn foo
17:10hefesto "I don't do a whole lot."
17:10hefesto [x]
17:10hefesto (println x "Hello, World!"))
17:10xificurChefesto: you're new to IRC, don't do that :)
17:10TEttingerhefesto:
17:10TEttinger~pastebin
17:10clojurebotpastebin how about refheap? https://www.refheap.com/
17:10hefestook.
17:10hefestosorry
17:10xificurCif you have more than 1 line of code use a site to paste your code
17:11hefestookay, sorry.
17:11TEttingeryour require is incorrect for an ns
17:11TEttingerwithin the ns form, (:require [clj-antlr.core :as antlr])
17:12TEttingeryou still need to have the parens match, I just did that one section of the 3rd line in the date
17:12hefestoI see
17:12TEttinger(require ['clj-antlr.core :as 'antlr]) ; this is correct if you're running it at the REPL, or in any part of a file that isn't the ns macro
17:13xificurCor (require '[clj-antlr.core :as antlr])
17:13TEttingerthere's an in-depth guide here, hefesto http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
17:14TEttinger(inc xificurC)
17:14lazybot⇒ 1
17:14hefestothank you very much!!!
17:14TEttingerno prob, is it working?
17:14xificurCseems like (bad joke ahead) I'm the One
17:15TEttingermaybe in the next life
17:15hefestorepl started to work
17:15hefestowhich i've been trying to do for a while
17:15hefestoso it's a huge success for just now.
17:16hefesto:)
17:16TEttingerwoo
17:16TEttingeryou're using lein repl , right?
17:16hefestoemacs cider right now
17:18TEttingerI'm always kinda disappointed how the official docs don't really say "use lein, please, it's the best way right now" when talking about project management. I don't use emacs, but I think the clojure tools for it all use lein internally for projects and deps?
17:18TEttingerthere's boot, which is really meant for larger projects it seems from their site
17:24Bronsapuredanger: yeah I looked into it and it doesn't seem like rettag makes sense the way it is implemented now. it will only accept (defn ^long x ..) or (defn ^double x ..) but those are invalid tags
17:26hefesto<TEttinger> : I dont know what emacs use internally. I've tried it out with the lein repl and the error disappeared too :)
17:27TEttingerwoo
17:29puredangerBronsa: thx
17:31michaniskin__TEttinger: cider should work fine with boot btw
17:32TEttingernice
17:32michaniskin__but for beginners lein is probably a better alternative because there is a lot of stuff on stackoverflow to copy/paste from
17:32michaniskin__which is pretty important if you're just learning the language
17:32TEttingerI just think boot makes sense as a thing to transition to if a project becomes unmanageable with lein. is boot able to produce uberjars?
17:32michaniskin__sure
17:33michaniskin__it can do all the things you need
17:33TEttinger(is it faster at compiling at lein? pretty please?)
17:33michaniskin__haha no, boot is more about correctness and sanity
17:33TEttingerpfft
17:33TEttingeryou know what I just wrote?
17:33michaniskin__so aggressive caching isn't done unless we have a solid way to invalidate cache
17:34TEttinger [DllImport("xbrz.dll", EntryPoint = "scale")] internal static extern int scale(int factor, UIntPtr src, UIntPtr trg, int srcWidth, int srcHeight, int colFmt, IntPtr nil = default(IntPtr), int yFirst = 0, int yLast = int.MaxValue);
17:35michaniskin__however, i think boot is a lot better for incremental compiles because of how it's organized, so that's what you generally use instead of persistent caches
17:35justin_smith~.
17:35clojurebotCool story bro.
17:35TEttingerjustin_smith: ?
17:36justin_smithTEttinger: that's the magic key sequence that closes ssh when it hangs
17:36TEttinger~~
17:36clojurebotTitim gan éirí ort.
17:36justin_smithTEttinger: my ssh connection to my irc session hangs when I connect from work
17:36TEttingerclojurebot: ~ is how you get factoids from me
17:36clojurebotYou don't have to tell me twice.
17:37TEttinger~~
17:37clojurebot~ is how you get factoids from me
17:37justin_smithin this instance I had pushed page-up, and hit ~. because the page up was not scrolling. Turns out the ~. only works immediately after newlines
17:37TEttingeraw
18:21sdegutisGiven [:a :b :c :d :e], what's a spectacular way to generate [[:a []], [:b [:a]], [:c [:a :b]], [:d [:a :b :c]], [:e [:a :b :c :d]]] ?
18:26{blake}sdegutis: Beat the CPU till it catches fire. Have the answers on a slip of flash paper in your pocket.
18:27michaniskin__,(reduce #(conj %1 (conj [%2 (vec (flatten (reverse (last %1))))])) [] [:a :b :c])
18:27clojurebot[[:a []] [:b [:a]] [:c [:a :b]]]
18:27sdegutisHmm we may have a tie.
18:28sdegutisBoth very good answers so far. But none quite spectacular... yet!
18:28{blake}I'd probably use a for.
18:28justin_smith,(first (reduce (fn [[acc prev] e] [(conj acc (vector e prev)) (conj prev e)]) [[][]] [:a :b :c :d]))
18:28clojurebot[[:a []] [:b [:a]] [:c [:a :b]] [:d [:a :b :c]]]
18:29justin_smithsdegutis: ^
18:29sdegutisI like the [[][]] in justin_smith's solution.
18:29sdegutisBut still not spectacular.
18:29{blake}Nice.
18:30{blake}Write a macro that, when you start typing [:a :b...] it responds with "I see where you're going with this." and gives the result.
18:31justin_smith,(first (reduce (fn [[acc prev] e] [(conj acc [e prev]) (conj prev e)]) [[][]] [:a :b :c :d]))
18:31clojurebot[[:a []] [:b [:a]] [:c [:a :b]] [:d [:a :b :c]]]
18:34sdegutis{blake}: Haskell basically has that.
18:34{blake}heh
18:34{blake}(inc Haskell)
18:34lazybot⇒ 2
18:36DerGuteMoritzhere's one without reduce: (let [x [:a :b :c :d :e]] (mapv vector x (map (comp vec drop-last) (range (count x) 0 -1) (repeat x))))
18:36sdegutistake 10 $ ['a','b' ..] // => "abcdefghij" (inc Haskell)
18:36sdegutisDerGuteMoritz: ugh, that's the one I was working on
18:37sdegutiscept I got distracted by magNITED states of merica
18:37sdegutisthat rant was priceless
18:37{blake}Eh. I like justin_smith's better.
18:38sdegutisI'm still trying to understand DerGuteMoritz -- that in itself is major points!
18:38sdegutisAnyway thanks for always doing the hard parts of my day job for me you guys.
18:38sdegutisEspecially you justin_smith.
18:38DerGuteMoritzheh yeah it's not exactly what I would use in production code
18:38sdegutisDerGuteMoritz: you'd be surprised how much FP is in production code
18:39michaniskin__,((fn [x] (zipmap x (mapv #(vec (take-while (partial not= %) x)) x))) [:a :b :c :d])
18:39clojurebot{:a [], :b [:a], :c [:a :b], :d [:a :b :c]}
18:39DerGuteMoritzjust wanted to do one without reduce for a change
18:39justin_smithDerGuteMoritz: on a vector, never use drop-last, use pop instead
18:39michaniskin__derp
18:39justin_smithDerGuteMoritz: oh wait, that isn't a vector coming in, neverm ind
18:39sdegutisI need to loop over each item in a coll while testing against all previous elements in the same coll each time.
18:39sdegutisThis is the most spectacular way to do it.
18:40{blake}michaniskin__: Oh, also nice.
18:40DerGuteMoritzjustin_smith: also, pop doesn't take an argument of how many elements to pop - but we could use subvec instead perhaps
18:41DerGuteMoritz(when first mapping to vectors, right)
18:41sdegutisStill struggling to figure out how in the world DerGuteMoritz's solution works.
18:42DerGuteMoritzsdegutis: try this as a first step: (map drop-last (range (count x) 0 -1) (repeat x))
18:43justin_smithsdegutis: after you recall map is varargs, it's easy
18:43DerGuteMoritzthe rest is just decoration ;-)
18:43sdegutisjustin_smith: That's the fact I was planning to take advantage of actually.
18:43sdegutisIn my try, all I got so far was ##(map vector (reverse coll) coll)
18:43lazybotjava.lang.RuntimeException: Unable to resolve symbol: coll in this context
18:44sdegutisI mean ##(let [coll [:a :b :c :d :e]] (map vector (reverse coll) coll))
18:44lazybot⇒ ([:e :a] [:d :b] [:c :c] [:b :d] [:a :e])
18:44sdegutisI was gonna work from there.
18:44sdegutisAnd that's when I found this: https://www.youtube.com/watch?v=1L3eeC2lJZs
18:44michaniskin__iterate is the spectacularest
18:45sdegutisWhich really slowed my progress down on the solution.
18:49DerGuteMoritzmichaniskin__: hm nice idea
18:50ebloodi have an uberjar that’s configured to start a main function that starts a backend process (started with java -jar dt-utils.jar).. i want to hop into a repl to use a function to test something, so using “java -cp dt-utils.jar clojure.main” I can get a repl, but none of the namespaces are initialized. what else do i need to do?
18:50justin_smitheblood: require your core namespace
18:50justin_smitheblood: remember that require from the repl is different from in ns forms
18:51michaniskin__,((comp (partial apply map vector) (juxt identity (comp reverse (partial take-while first) (partial iterate pop) pop))) [:a :b :c :d])
18:51clojurebot([:a [:a]] [:b [:a :b]] [:c [:a :b :c]])
18:51michaniskin__hehe
18:51DerGuteMoritz(let [x [:a :b :c :d :e]] (map vector x (cons [] (reverse (take (count x) (iterate pop x))))))
18:52justin_smith(inc michaniskin__)
18:52lazybot⇒ 1
18:52justin_smiththat's a nice one
18:52justin_smith(inc michaniskin)
18:52lazybot⇒ 2
18:52michaniskin__i want my family coat of arms to have COMP JUXT PARTIAL APPLY in the crest
18:52DerGuteMoritz,(let [x [:a :b :c :d :e]] (map vector x (cons [] (reverse (take (count x) (iterate pop x))))))
18:52clojurebot([:a []] [:b [:a]] [:c [:a :b]] [:d [:a :b :c]] [:e [:a :b :c :d]])
18:52sdegutisMy plan was to first turn [:a :b :c :d :e] into [[] [:a] [:a :b] [:a :b :c] ...]
18:53sdegutisThen I was just going to (partial mapv vector coll) that sucker.
18:53DerGuteMoritzok that was fun, but now good night :-)
18:53sdegutisDangit. I think DerGuteMoritz just did it again.
18:57sdegutisAha! I knew it had something to do with repeatedly or repeat or iterate!
18:57sdegutisAnd yet, I feel oddly dissatisfied for not coming up with it myself.
18:57sdegutisI'm sorry #clojure. I'm sorry I asked you to do my day job for me. I just.. I had no idea that you would also get the /satisfaction/ from doing it.
18:58sdegutisWell, at the very least, I got to clean it up and make it beautiful:
18:58sdegutis,(let [coll [:a :b :c :d :e]] (->> coll (iterate pop) (take (count coll)) (reverse) (cons []) (mapv vector coll)))
18:58clojurebot[[:a []] [:b [:a]] [:c [:a :b]] [:d [:a :b :c]] [:e [:a :b :c :d]]]
18:59michaniskin__excellent
19:03ebloodjustin_smith: thanks.. that worked
19:28slesterI'm struggling a bit with laying out my code; it seems bad to have to (declare) a bunch of functions at the beginning :(
19:28gfredericksTimMc: I missed your comments earlier
19:28gfredericksI do appreciate the "no two elements are unequal" formulation
19:29gfredericksbut regarding your other one about removing elements, you have the flipside of "adding an element can always turn true to false", which wouldn't be true for (=)
19:29slesterMy code if someone is generous enough to given comments: https://github.com/slester/amiss/blob/master/src/amiss/core.clj -- always appreciated! I'll keep doing some searching to see what the Internet says
19:30justin_smithslester: I think the logic of your domain means that inherently each operation needs to conditionally invoke others
19:31justin_smithslester: you could use a big letfn or something, but it is cleaner to just declare them and let them mutually conditionally call one another
19:35{blake}Is there a "mapmerge" equivalent of "mapcat"?
19:36justin_smith{blake}: isn't that just (partial reduce merge) ?
19:36justin_smithoh no, you are doing some function to each element before merging
19:36sdegutis{blake}: How about (->> coll (map f) (apply merge))
19:36justin_smithso it's (apply merge (map f coll))
19:37sdegutisjustin_smith: Oh reduce, clever.
19:37sdegutisI like how (partial) is implicit in Haskell and (comp) is just .
19:37{blake}justin_smith, sdegutis: Right. I was just looking at mapcat and it's (apply concat (apply map f colls))) so I figured there might be one for merge.
19:37sdegutis,(source mapcat)
19:37clojurebotSource not found\n
19:38sdegutisAre you drunk clojurebot?
19:38sdegutis##(source mapcat)
19:38lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
19:38sdegutisOh.
19:38sdegutis,(clojure.repl/source mapcat)
19:38clojurebotSource not found\n
19:38sdegutis##(clojure.repl/source mapcat)
19:38lazybot⇒ Source not found nil
19:38sdegutisFINE, bots.
19:39iamjarvois there a way for lein repl to load all the files in /src? ive been having to (load-file "file_path")
19:39justin_smithiamjarvo: you can specify :main in your project.clj
19:40justin_smithiamjarvo: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L196
19:41amalloy~def mapcat
19:42iamjarvojustin_smith but thats one namespace, i guess the main namespace should require all the dependencies
19:45iamjarvoi was sort of hoping to load the repl and require a namespace or use a namespace as needed
20:31hefestoHow do you concatenate two strings?
20:32hefestosomething like: (+ "string 1" "string 2")
20:32hefestoclojure.string doesnt seem to have a function that does it.
20:33gfredericks,(str "string 1" "string 2")
20:33clojurebot"string 1string 2"
20:34hefestothank you!
20:34hefesto:)
21:10TimMcgfredericks: Interesting point about adding elements!
21:13gfredericksdo any lisps evaluate (=)?
21:20justin_smithguile> (=) => #t
21:20justin_smithfirst one I tried
21:21justin_smithcommon lisps don't like it
21:33gfredericksI don't imagine the question even applies to any other popular languages
21:34justin_smithlush demands exactly two arguments
21:34TimMc=.apply([])
21:41kclawlwhat makes clojure more functional than python?
21:42gfredericksimmutable data structures?
21:42kclawlanything else?
21:42justin_smithkclawl: the core functions and data structures make side effects rare
21:43justin_smithkclawl: in python you can code functionally if you have a lot of self discipline and keep track of the gotchas (hidden or unexpected mutation) - in clojure it's the default, the easy way to code
21:46kclawlyeah I see
22:18TimMcYou can opt out of it, of course, but it has to be somewhat explicit.
22:20gfredericksit's not just a language attribute it's a community/ecosystem thing too
22:27sg2002kclawl: The semantics itself is more functional too. Python expressions are imperative.
22:36kclawlsg2002 hmm, what makes python expressions imperative?
22:43gfredericksdo all python expressions return something?
22:47sg2002kclawl: Lisp expressions are functional because they always return a value. Python expressions generally don't return a value. if a==b{ x} else{ y} in an imperative language like python means "DO x when a==b or DO y". In a lisp similar statement means "return value from doing x when a==b or value from doing y".
22:52kclawlah ok.. python is if expression too, but it is kind of ugly and backwards
22:52kclawl10 if True else 20
22:59sg2002kclawl: Python expressions are not backwards or ugly, but from the point of functional programming those expressions are a layer of accidential complexity.
23:01kclawl10 if True else 20 is backward and ugly
23:01kclawlfirst a then value, then boolean check, then else
23:29amalloygfredericks: i think expressions that don't return something get called statements