#clojure logs

2014-04-18

00:16base698Anyone know how to get this to work: (-> [old-position move] (partial apply interleave)) setting (def f (partial apply interleave)) works.
00:17Frozenlock,(macroexpand-1 '(-> [old-position move] (partial apply interleave)))
00:18clojurebot(partial [old-position move] apply interleave)
00:18base698well that's helpful
00:18Frozenlockbase698: I suppose that's not what you wanted :-p
00:18base698nope
00:19Frozenlock(macroexpand-1 '(->> [old-position move] (apply interleave)))
00:19Frozenlock,(macroexpand-1 '(->> [old-position move] (apply interleave)))
00:19clojurebot(apply interleave [old-position move])
00:20base698hmm.
00:22base698success!
00:28base698Frozenlock: thanks. first time I've used ->> in the wild.
00:29Frozenlockbase698: No problem.
00:29FrozenlockHowever I'm not sure this increase readability. I suppose there's some other stuff going in the ->> macro?
00:29base698yeah, it's super long
00:30base698not sure if that pasted
00:31base698there was a map and partition and some other stuff
01:24serjeemSort of specific question, but: I'm trying to play with libgdx in a repl. I've got everything running just fine, but when I try to exit the window, it crashes the repl, complaining that the "subprocess failed".
01:25serjeemIs there a way to keep the repl running even when the subprocess dies?
02:07hiredmanserjeem: likely libgdx is kill the clojure/jvm process when the window closes, there should be an option in libgdx to disable that
02:08hiredmanserjeem: lein runs two jvms, one is actually running lein, the second is your projects, if that message is from lein it is because the project jvm (where your code is being run) is dying
02:42danielszmulewiczAre forward declarations broken with the latest clojurescript? Doesn't seem to work here.
03:16martintrojer,(= false)
03:16clojurebottrue
03:16martintrojergreat
03:17Frozenlock(= nil false)
03:17Frozenlock,(= nil false)
03:17clojurebotfalse
03:17martintrojer,(every? (constantly false) [])
03:17clojurebottrue
03:17martintrojerperfect
03:25dbasch,(= = - = =)
03:25clojurebotfalse
03:25martintrojer,(every? (constantly false) [false])
03:25clojurebotfalse
03:26dbasch,(every? (constantly false) [true])
03:26clojurebotfalse
03:27martintrojer,(every? (constantly false) [])
03:27clojurebottrue
03:27dbasch,(every? every? [])
03:27clojurebottrue
03:28mpenet,(and)
03:28clojurebottrue
03:37FrozenlockIs it an emacs function that 'prettify' the requires into equal length vectors?
03:45owl-v-how do i use mutable list?
03:46dbaschowl-v-: what do you mean mutable list? what do you want to do?
03:47owl-v-update list and use it as stack
03:47dbaschowl-v-: but why do you need to mutate it, as opposed to appending to an immutable one?
03:50owl-v-is there reason to use immutable list?
03:50dbaschowl-v-: normally you need a reason to use mutable structures
03:50dbaschthe default is immutability
03:51dbasch,(pop [1 2 3 4 5])
03:51clojurebot[1 2 3 4]
03:52owl-v-im using a list as an argument and iterate through and create new list then use this new list as argument of new function
03:52yediwhat are the best clojure codebases to read for learning some of the better clojure development strategies
03:53owl-v-,(pop [1 2 3 4 5])
03:53clojurebot[1 2 3 4]
03:53owl-v-,(push 6 [1 2 3 4 5])
03:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: push in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:53owl-v-,(push [1 2 3 4 5] 6 )
03:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: push in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:53dbasch‘(conj (pop [1 2 3 4 5]) 6)
03:53dbasch,(conj (pop [1 2 3 4 5]) 6)
03:53clojurebot[1 2 3 4 6]
03:54Jaood,(peek [3 5 7 9])
03:54clojurebot9
03:54owl-v-,(conj [list 1 2 3 4 5] 6 )
03:54clojurebot[#<clojure.lang.PersistentList$1@67c93d> 1 2 3 4 ...]
03:54owl-v-,(conj [1 2 3 4 5] 6 )
03:54clojurebot[1 2 3 4 5 ...]
03:54owl-v-what's that '...'?
03:55dbaschellipsis
03:55owl-v-,(conj [1 2 3 ] 4 )
03:55clojurebot[1 2 3 4]
03:55dbaschclojurebot truncates results
03:55owl-v-and fifo?
03:57owl-v-,(reverse (conj [1] 2))
03:57clojurebot(2 1)
03:57owl-v-why do i get list when reverse?
03:57Jaood(first (conj [] 9))
03:57Jaood,(first (conj [] 9))
03:57clojurebot9
03:58owl-v-,(reverse [1 2 3])
03:58clojurebot(3 2 1)
03:58Jaood,(first (into [] [1 2 3]))
03:58clojurebot1
03:58owl-v-,(first (conj [1 2] 3))
03:58clojurebot1
03:58owl-v-,(ast (conj [1 2] 3))
03:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ast in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:58owl-v-,(last (conj [1 2] 3))
03:58clojurebot3
03:59dbasch,(type [])
03:59clojurebotclojure.lang.PersistentVector
03:59dbasch,(type (reverse []))
03:59clojurebotclojure.lang.PersistentList$EmptyList
03:59owl-v-list out of vector?
03:59owl-v-,(conj (1 2))
03:59clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
03:59dbasch,(into [] (reverse [1 2 3])
04:00clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
04:00owl-v-,(conj (1 2) 3)
04:00clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
04:00owl-v-,(cons (1 2) 3)
04:00clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
04:00owl-v-,(cons [1 2] 3)
04:00clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
04:00owl-v-,(conj (reverse (conj [1 2] 3)) 4)
04:00clojurebot(4 3 2 1)
04:00dbasch,(into [] (reverse [1 2 3]))
04:00clojurebot[3 2 1]
04:01owl-v-reverse of vector should return reversed vector :(
04:02dbaschno
04:02dbasch“reverse: Returns a seq of the items in coll in reverse order. Not lazy.”
04:03dbasch,(rest [1 2 3 4])
04:03clojurebot(2 3 4)
04:03dottedmagowl-v-: You're mixing it up with Haskell :)
04:08owl-v-not logical... god da@# it!
04:11dbaschowl-v-: a vector is not a seq. reverse returns a seq
04:12dbaschit’s good to know why and when to use a vector, and it’s not just because typing square brackets is convenient :)
04:20owl-v-so, i'm using two vectors in this function. and i have errors on line 12 and 4: https://www.refheap.com/77370
04:20owl-v-v and vv
04:27dbaschyou’re calling your function with a vector of vectors, so you’re trying to decrement a vector
04:28owl-v-decrement a vector?
04:28owl-v-when v is [[]] , item is []
04:29owl-v-(first item) is first element of item which is just a number 99 in the first case.
04:29dbaschprint n and m before line 12 and you’ll see
04:29owl-v-so n == 99
04:30owl-v-omg!!!!!!
04:32owl-v-why item is not iterated element of v?
04:32owl-v-when looped?
04:34owl-v-because it is not for loop?
04:34dbaschv is a vector of vectors
04:34dbasch[[99 99]]
04:34dbaschthe first element of that is [99 99]
04:34owl-v-yes. that's what i want
04:34dbaschit’s also the last element, of course
04:34sm0kecan core.typed be used to enforce function argument/return types?
04:34owl-v-but item==[[99 99 ]]
04:35sm0keso for e.g. what if i declare `inc` as [Num -> String], would core.typed throw exception?
04:35dbaschyes, item starts as v
04:36owl-v-i guess (loop [item v] ...) this simply initialize value item=v which is not what i want.
04:55ambrosebssm0ke: not currently
04:56owl-v-,(let [v []] (let [n 3] (conj v 3) )
04:56clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
04:56owl-v-,(let [v []] (let [n 3] (conj v 3) ))
04:56clojurebot[3]
04:56ambrosebssm0ke: working on generating casts from types
04:56ambrosebssm0ke: but there's always going to be a core of "trusted" annotations.
04:56owl-v-,(let [v []] (let [n 3] ((conj v 2) (conj v 3)) ))
04:56clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Key must be integer>
04:57owl-v-illegal?
04:58TEttinger,(let [v []] (let [n 3] (do (conj v 2) (conj v 3)) ))
04:58clojurebot[3]
04:59owl-v--.-
05:00owl-v-what happened to (conj v 2)?
05:02owl-v-,(let [v []] (let [n 3] (do (conj v 2) (conj v 3)) ))
05:02clojurebot[3]
05:02owl-v-,(let [v []] (let [n 3] (do (conj v 2) (do (conj v 3))) ))
05:02clojurebot[3]
05:04ucb,(doc conj)
05:04clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
05:04ucbowl-v-: conj returns a new collection
05:05akazlouinteresting found that get/assoc/assoc-in work nice with nil map passed, is it by design?
05:06katratxoakazlou: "nil keys and values are ok" http://clojure.org/data_structures#Data%20Structures-Maps%20%28IPersistentMap%29
05:08owl-v-ucb; how do i update one at a time?
05:08ucbowl-v-: you don't? What are you trying to do?
05:12owl-v-add two vectors to a vector
05:12owl-v-[] -> [[1 2]] -> [[1 2] [1 3]]
05:14Frozenlock,(conj [] [1 2] [1 3])
05:14clojurebot[[1 2] [1 3]]
05:14akazloukatraxo: thank you for the link, but what I meants, that (assoc nil {:lang "Clojure"}) or (get nil :lang) is ok, so map passing into assoc/get/assoc-in can be nil, and no NullPointerException,
05:14akazloufor example in my sample ring app:
05:14akazlou (-> (response-util/file-response file {:root "public"})
05:14akazlou (response-util/content-type content-type))
05:14akazlouif file doesn't exist file-response returns nil, but then content-type return {:headers {"Content-Type" content-type}} which is not right ring response
05:14akazloujust found it interesting
05:22kraswhat's wrong with this function?
05:22kras(defn flt [lis acc]
05:22kras (if (not (seq? (first lis)))
05:22kras (do (conj acc (first lis)) (recur (rest lis) acc))
05:22kras (recur (first lis) acc)))
05:23krasit just hangs when I eval (flt '(1 2 (3 4)) ())
05:24ivankras: conj doesn't mutate acc
05:25ivanit returns a new value that you threw away
05:26krasoops !!!
05:27kraslets say I throw away the result
05:28krasit still doesn't explain why it should hang?
05:28owl-v-Frozenlock: thanks
05:28krasmight be missing something else here
05:28clgvowl-v-: please do read some introductory material on clojure, you'll be learning much faster.
05:28krashere's the easier to read code https://www.refheap.com/77372
05:29clgvkras: good move. always post more than one-line code in a gist:)
05:29krasclgv: yeah realized it after seeing the code I posted
05:30ivan,(seq? (first '(1 2)))
05:30clojurebotfalse
05:31clgvkras: you know that you always have to pass on the "modified" object. your (conj acc (first lis)) does not have any effect on future recursive invocations. and you are missing a base case where the recursion stops
05:31clgvkras: what exectly do you want to do?
05:33krasclgv: thanks for the hint
05:33krasI think I undertsood the problem
05:33krasI am basically trying to flatten a given nested list
05:33kraslet me try for some more time
05:33beamso,(doc flatten)
05:33clojurebot"([x]); Takes any nested combination of sequential things (lists, vectors, etc.) and returns their contents as a single, flat sequence. (flatten nil) returns an empty sequence."
05:34clgvbeamso: I think it is a learning exercise ;)
05:34beamsooh
05:34krasyep
05:36owl-v-why is it harder to think in clojure/lisp than think in python?
05:36owl-v-or c or c++
05:36llasramLack of experience
05:36owl-v--.-
05:36clgvowl-v-: you are probably struggling with imperative programming vs functional programming
05:36beamsofor me it's a) lazy evaluation and b) functions that return something vs functions that return nothing
05:37clgvowl-v-: that's why I suggested to you several times already to read introductory material on clojure - this will speed up your learning process
05:37beamsoe.g. doall vs dorun
05:38clgvowl-v-: get one of the books and do the reading + experimenting cycle ^^
05:39owl-v-simple breath first tree search is not fun in clojure :(
05:39llasramAnd why do you say that?
05:40clgvowl-v-: why is that? you can directly translate the recursive function from c/c++/java to clojure. but naturally you might suffer a stackoverflow as you would in c/c++/java ;)
05:44krasthis is what I came up with: https://www.refheap.com/77374
05:45krasofcourse since I am throwing away the conj result it returns an empty seq now
05:45clgvkras: still the same error with the "conj" I told you before
05:45clgvkras: do you know "cond"?
05:45kraslike a case statement?
05:46clgvkras: it is a compact form to write those nested "if" statements (nested in the else case)
05:47krasokay, let me check that
05:49owl-v-,(for [i (1 2)] (print i))
05:49clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:49owl-v-,(for [i (1 2)] (println i))
05:49clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:50clgv,(for [i '(1 2)] (println i))
05:50clojurebot(1\n2\nnil nil)
05:50owl-v-,(for [i (1 2)] (prn i))
05:50clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:50owl-v-?
05:50clgvread please^^
05:50krasowl-v-: please read the docs
05:50beamso(1 2) is calling the function 1 with an argument of 2. '(1 2) is the list of 1 and 2.
05:50clgv,(1 2)
05:50clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
05:50clgv^^
05:50owl-v-docs didn't help me at all
05:51kras(1 2) clojure expects 1 to be callable
05:51krasor special form
05:51owl-v-,(for [i [1 2]] (prn i))
05:51clojurebot(1\n2\nnil nil)
05:51owl-v-,(for [i [1 2]] (println i))
05:51clojurebot(1\n2\nnil nil)
05:51krasif you want clojure to stop doing that then you have to quote it
05:51kras,(doc quote)
05:51clojurebotHuh?
05:51clgv$doc quote
05:52clgv&1
05:52lazybot⇒ 1
05:52clgv&(doc quote)
05:52lazybot⇒ "Special: quote; Yields the unevaluated form."
05:52owl-v-java runtime error :(
05:53clgvowl-v-: you'll have many more of those disappointing experiences if you dont try to learn clojure in a structured way, i.e. reading something that explains you the big picture and the mandatory basics
05:54krasowl-v-: clojure is a lisp, if that helps :-)
05:55beamsoi recommend http://www.clojurebook.com/ . for me it was better than the pragprog books on clojure.
05:56krasone think which still confuses me a hell lot is recur
05:56krasused to recursion with function names
05:56clgvkras: just imagine it is the function name of your current function^^
05:56krasany good article which explains why we need a special form recur instead of just using traditional recursion
05:56clgvkras: provided you have no loop surrounding it ;)
05:57clgvkras: because the JVM is not able to do Tail Call Optimization
05:57daityaowl-v-: section 1.1 of chapter 1 will help you get started thinking in lisp http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start
05:58owl-v-,(let [v []] (for [item [1 2 3]] (conj v item)))
05:58clojurebot([1] [2] [3])
05:59clgvkras: you tell the Clojure compiler to use tail call optimization by using recur. through the use of recur the compiler can also determine whether it really occurs in a tail call position
05:59owl-v-...list
06:00owl-v-,(let [v []] (for [item [1 2 3]] (conj v item)) v)
06:00clojurebot[]
06:00clgvowl-v-: well you are wrong in interpreting that code as imparative code :P
06:00krasso if I implement a traditional recursion it will be translated to pure JVM recursion which doesn't support Tail resursion optimization?
06:01clgvkras: right. that does only matter if your recursion works on large data structures. so sometimes a traditional recursion is totally suitable if you know that the number of recursive calls is bounded by a small number
06:02krasok makes sense now
06:02owl-v-,(let [v []] (do (for [item [1 2 3]] (conj v item) v))
06:02clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:02krasclgv: thank you
06:03FrozenlockI've always found the lack of tail recursion optimization in Clojure... unfortunate.
06:03owl-v-,(let [v []] (do (for [item [1 2 3]] (conj v item)) v))
06:03clojurebot[]
06:03clgvFrozenlock: huh? you get tco by using recur explicitely.
06:03clgvFrozenlock: you'd want it implicitly if applicable?
06:04FrozenlockYes
06:04FrozenlockWouldn't you?
06:04clgvwasnt there some discussion regarding that design choice?
06:04owl-v-,(let [v []] (do (for [item [1 2 3]] (conj v item)) (println v) ))
06:04clojurebot[]\n
06:04clgvwell coming from C++/Java I never had TCO in the first place ;)
06:05llasramThis may be the Stockholm syndrome talking, but given that general-case TCO isn't possible on the JVM, I'd rather have an explicit construct for it than have it just not TCO when it couldn't
06:05clgvllasram: yeah I also like the check telling me that I misplaced the recur^^
06:05owl-v-,(let [v []] (for [item [1 2 3]] (conj v item) (print v) ))
06:05clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (3) passed to: core/for, compiling:(NO_SOURCE_PATH:0:0)>
06:06clgvowl-v-: could you please use your own local repl?
06:06llasramOr just /query clojurebot
06:06krasor you can use http://tryclj.com/
06:06krasplease stop using this as a REPL
06:06owl-v-cool! thanks
06:06llasramMany options!
06:08llasramowl-v-: But FYI, that last bit of code you tried can't do what you want w/ immutable vectors
06:08llasramNot to mention `for` as generating a lazy sequence
06:11owl-v-:( but it works when (conj [] 1 2 3)
06:11owl-v-or (conj v 1) (conj v 2) (conj v 3)
06:12owl-v-i mean (conj (conj ( conj v 1) 2) 3)
06:12llasramowl-v-: Yes, but those are operating on the return value of conj in each case
06:13llasramYou're doing the same thing as ##(for [i (range 1 4)] (conj [] i))
06:13lazybot⇒ ([1] [2] [3])
06:13llasramBecause `v` doesn't change -- it stays bound to `[]`
06:13owl-v-T.T
06:13owl-v-my python way of thinking...
06:14owl-v-i miss mutable list...
06:15llasramAnd my experience is that once I learned to use immutable data structures, I miss *those* in every language lacking them :-)
06:15llasramYou have complete access to mutable datastructures in Clojure
06:16clgvllasram: cant wait for the version of the above code using java.util.ArrayList ^^
06:16llasram,(let [v (java.util.ArrayList.)] (doseq [i (range 3)] (.add v i)) v)
06:16clojurebot[0 1 2]
06:16anna_why clojure error reporting sucks ?
06:16anna_:(}
06:16clgvllasram: damn, you should have used `for` ;) :P
06:17llasramclgv: Let's not be crazy now :-p
06:17llasramOne problem at a time
06:18clgvanna_: mostly due to the JVM since the only possibility for runtime errors are exceptions. but certainly there could be improvements trying to translate those exceptions into better user friendly error messages
06:18daityaowl-v-: if you want tutorial-style learning, many options to learn from: http://www.purelyfunctional.tv/ ... http://www.braveclojure.com/ ... http://aphyr.com/tags/Clojure-from-the-ground-up
06:19clgvthe one from aphyr looks nice
06:19daityaand the best way is to try stuff in your local repl... it puts things in context (as opposed to clojurebot)
06:19llasramclgv: I don't think that's true... (re: errors) My reasons:
06:19llasramanna_: Because (a) rhickey isn't interested; (b) with some familiarity, most of the error messages do tell you what went wrong; and (c) because it's honestly difficult given the language design
06:20clgvllasram: well my answer would be in (c) I guess^^
06:21owl-v-i was doing http://projecteuler.net
06:21daityallasram: i doubt if (a) is even within the answer space
06:21clgvowl-v-: better switch to 4clojure.com and start with the basic ones
06:21llasramdaitya: Really? I think it's definitely a reason the Clojure error messages aren't better :-)
06:22llasramrhickey is completely fine with Clojure core macros (like defn) just throwing whatever exception bad input causes them to generate
06:22clgvllasram: provided those execptions carry enough information the error messages could be improved in the repl frontends
06:22llasramI'm skeptical
06:22clgvllasram: probably the compiler should throw ExceptionInfo objects with enough information
06:23llasramMaybe, but arbitrary code getting arbitrarily incorrect data -- there's only so much you can do
06:23llasramYou'd really need every macro to carefully check what it expects vs what it recieves
06:25clgvright
06:25clgvbut do you do that in your own code 100% of the time?
06:26llasramOf course not. And I'm not even saying that I think clojure.core should
06:26llasramI'm just saying I think it's what you need to do to get significantly better error messages, and that that kind of philosophical direction would need to come from the top
06:28daityallasram: :) ... I feel there must be a good reason out there somewhere... it's completely counterintuitive that a carefully-designed language would deliberately not provide clean, useful feedback to its user
06:29llasramWell, I mean, it *does*, if you've got a certain mental model and level of familiarity. That's (b), and it's kind of a chicken-egg + self-selection thing
06:29clgvdaitya: requiring a certain amount of effort would be one reason if the developers are not convinced the effort is worth it
06:30llasramIf you stick around Clojure, you learn enough of the implementation to interpret the error messages. Once you've learned enough of the implementation, the error messages frequently tell you *exactly* what went wrong
06:30llasram,(1)
06:30clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
06:30durmguys, help me please!
06:30durmI want to do fs walk and store file to another place
06:30llasramClojure expected an IFn (a function object) and found a Long
06:30durmi have a function
06:31durm(defn walk [dirpath pattern]
06:31durm (doall (filter #(re-matches pattern (.getName %))
06:31durm (file-seq (file dirpath)))))
06:31llasramAn error like "non-function used in call position" would be newbie friendly, but tell you *less* about exactly what went wrong
06:31durmwhich can walk over fs
06:31durmand return file handlers
06:32llasramdurm: In the future, please use a paste service like refheap.com for code longer than 1-liners
06:32durmoh sorry
06:32durmok
06:32durmand in another expression i want to store the file
06:33daityallasram: i'm fairly new to clojure, and that has been my experience... these days i get surprised that--more often than not--i barely glance at the error and know where I made a mistake... it took some effort, but now i have a certain level of comfort
06:33durmlike (map #(println (__create media %)) (walk import-dir #".*"))
06:33durmbut it doesnt work
06:33durmI think because of lazyness
06:34owl-v-why this is true? (= (list :a :b :c) (vec '(:a :b :c)))
06:34FrozenlockI remember coming to clojure without knowing any java at all. I wanted to throw my computer at the ground everytime I saw one of those horrible error messages.
06:34daityaowl-v-: hint... sequence abstraction
06:34durmhow can I do it?
06:35llasramdurm: Um, well `dorun` will force a lazy sequence and discard the results, if you just want to force it for side-effects
06:35owl-v-but this is java runtime error: (= (list a b c) (vector a b c))
06:35llasramdurm: You might also consider using `doseq` instead of `map` if you just want to run some code for side-effects
06:36daityaowl-v-: what is the difference between 'a' and ':a'?
06:36llasramdaitya: Oooh, the Socratic method. Fancy
06:36owl-v-just an element?
06:36owl-v-just elements?
06:36durmllasram: thanks, I will try it
06:37owl-v-http://www.4clojure.com/problem/6
06:38daityaowl-v-: do you have a running repl?
06:38owl-v-yes
06:38owl-v-with :a works but with 'a' does not
06:38daityacorrect, but why?
06:39daityallasram: oh don't tease ... any resemblance is purely coincidental
06:40daityaowl-v-: try this... first feed (def a "foo") to your repl, then feed 'a' to it
06:41daityawithout the quotes
06:43Guest27066lol funny name daitya
06:43owl-v-daitya: "foo"
06:44daityaowl-v-: aha! now type in :a
06:44daityaGuest27066: http://vedabase.net/d/daitya ... a subtle pun on my real name
06:44akazlou:require vs :use in ns definition, which one is usually used?
06:44owl-v-daitya; :a
06:44jonasenakazlou: :require
06:44Frozenlockakazlou: :require
06:45clgvdaitya: lol. you started a tutorial "clojure on hands and knees" just now ;)
06:45Frozenlock:use is evil
06:45akazlouor preference/difference between them?
06:45akazlouwhy :use is evil?
06:45Guest27066:use is daitya
06:45Guest27066:D
06:46clgvakazlou: in (ns) only use ":require". in repl (use ...) is often pretty handy
06:46daityaowl-v-: before you bound a to something--that is, "foo"--it didn't exist
06:46jonasenI wouldn't say that :use is evil. It's just that :require can do everything (and more) that :use can do. So :use is not really needed
06:46daityaGuest27066: :D
06:46clgvakazlou: usually you use something like (:require [clojure.string :as str]) and then (str/join ", " (range 10))
06:46Frozenlockakazlou: Personally I hate it because it brings everything into the namespace. Want to know from which library a function is coming just by looking at the code? Good luck...
06:47jonasenFrozenlock: you can (:use ... :only ..)
06:47FrozenlockSure, but do you really? :-p
06:47krasfinally ended up with this: https://www.refheap.com/77391
06:47jonasenFrozenlock: no
06:48owl-v-daitya; a still shows "foo" but :a shows :a
06:48clgvjonasen: but why when (:require ... :refer ...) is equivallent?
06:48jonasenbut I do use (:require [foo.bar :refer ..])
06:48akazlouok, so with use you can't assign name to the import, but :as require will allow you to do it, or nice
06:48daityaowl-v-: and that is the correct behaviour
06:48jonasenclgv: exactly! :require can do al that :use can.. so :use is not needed
06:48daityaowl-v-: http://clojure.org/data_structures#toc8
06:49akazlouthanks
06:49daitya:a is a keyword... it evaluates to itself
06:50daityawhereas a is a symbol that means nothing till you bind it to something
06:50clgv,'a
06:50clojurebota
06:50clgv,(class 'a)
06:50clojurebotclojure.lang.Symbol
06:51daitya,(class :a)
06:51clojurebotclojure.lang.Keyword
06:51clgv,(class (read-string "a"))
06:51clojurebotclojure.lang.Symbol
06:51daityamore correctly, a will not mean anything to _you_ unless you bind it to something
06:53daitya,a
06:53clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)>
06:54owl-v-(def :a "boo") -> "java.lang.RuntimeException: First argument to def must be a Symbol" because :a is not a symbol
06:55clgv,(def a 42)
06:55clojurebot#'sandbox/a
06:55clgv,a
06:55clojurebot42
06:56daityaowl-v-: yes, because :a already is--crudely speaking--permanently bound to a value... itself
06:57owl-v-but when do we use :keyword? in dictionary?
06:58daityayes, that's the most common use case; keywords are used as keys in a map
06:58daitya,{:a :a}
06:58clojurebot{:a :a}
06:58daityabut this is a perfectly valid map ^
06:59clgv,({:a :a} {:a :a} {:a :a})
06:59clojurebot{:a :a}
07:00daityaclgv: ooh... why did that happen? let me go find out
07:00daitya(serious ^)
07:00clgvdaitya: :D
07:00clgv,({:a :a} {:b :b} {:c :c})
07:00clojurebot{:c :c}
07:03owl-v-returns last dic?
07:04owl-v-i think that's correct behavior :)
07:04owl-v-i tried on http://tryclj.com/
07:05jonasen,({:a 1 :b 2} :a :not-found)
07:05clojurebot1
07:05jonasen,({:a 1 :b 2} :c :not-found)
07:05clojurebot:not-found
07:06daityaclgv: D'oh ... default value >_<
07:06clgvdaitya: yeah you could just write a "get" in front to have it pretty obvious ;)
07:07daityaclgv: well, careless of me, because i knew about the optional default
07:08daityathanks for the knock on the head :)
07:09owl-v-what does ( ) do on ({:a 1} :a :whatever) ?
07:10daityatry it in your repl
07:10clgv,((#{{}} {}) {} {})
07:10clojurebot{}
07:11Guest27066how stupid is the idea to have a line-reader in clojure which collapses all the ending paranthesis? so intead of something like )]})]}))))) we can just write somthing like ...)
07:11Guest27066:P
07:12clgv,((#{{}} {}) (#{{}} {}) (#{{}} {}))
07:12clojurebot{}
07:13Guest27066ignoring that it will just blow off all the existing tools and ides for clojure, its a nice idea
07:13daityaowl-v-: seriously, you will do well to read this: http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html#%_sec_1.1
07:14clgvGuest27066: I guess it wont work in general, since there scenarios when you need to look ahead to be able to determine what closing paranthesis you need and especially which are closed later
07:15Guest27066hmm i am not sure if its entirly correct
07:15Guest27066every ...) will look ahead for the first unmatched (
07:15Guest27066thats it
07:16clgvno. you need to know all closing ones that are ahead..
07:16Guest27066yes
07:16clgvand I guess for that you'd need to read until the end of the document
07:16Guest27066beginnging you mean?
07:16clgvno
07:17clgvyou need to know which paranthesis to insert instead of ...) you know the possible ones from the opening counter parts but some of them might be closed later on so you have to exclude those
07:18clgvand you cant tell if there is still a closing one before you readched the end of the file
07:18clgv-d
07:21owl-v-does (set (list)) make array-map?
07:21clgvno, it creates a set
07:22clgv,(class (set (list)))
07:22clojurebotclojure.lang.PersistentHashSet
07:22clgv,(class #{})
07:22clojurebotclojure.lang.PersistentHashSet
07:26Guest27066is there something like take-while but still extract the last failing element
07:27clgvGuest27066: you probably need something that would be called "take-until" then... refering to the looping constructs...
07:27Guest27066,(take-while #(< % 10) (range 20))
07:27clojurebot(0 1 2 3 4 ...)
07:28Guest27066,(take-while #(< % 5) (range 20))
07:28clojurebot(0 1 2 3 4)
07:28clgvGuest27066: with numbers it's easy to patch but you probably have something different
07:28Guest27066i can use 6 here, but thats not the point
07:28Guest27066clgv: right
07:28clgv,(source take-while)
07:28clojurebotSource not found\n
07:28clgv$source take-while
07:29lazybottake-while is http://is.gd/6y8gU0
07:29Guest27066i can always write a reduce and reduced
07:29clgvGuest27066: write take-until base on take-while. you just have to move the "when"
07:29Guest27066but thats 1.5+
07:34clgvGuest27066: https://www.refheap.com/77393
07:35Guest27066nice
07:35Guest27066(inc clgv)
07:36lazybot⇒ 16
07:37Guest27066hurmm
07:37Guest27066hey! take until?
07:37Guest27066oh ok
07:37clgvcorresponding to the difference between while loop and repeat-until loop
07:39clgvoh humm concerning that the sematic is wrong. the predicate needs to be inverse for that naming^^
07:40Guest27066may be it should be named take-unless
07:41Guest27066take-unless-and-until
07:41Guest27066weird
07:42owl-v-why ({:a 10, :b 20, :c 30} :b) == (:b {:a 10, :b 20, :c 30}) ?
07:42clgvGuest27066: ok there are two variants in the gist now ;)
07:42clgv(take-until #{6} (range)) ; => (0 1 2 3 4 5 6)
07:43clgv(take-while+1 #(< % 6) (range)) ; => (0 1 2 3 4 5 6)
07:44clgvowl-v-: because keywords act as functions
07:44clgvowl-v-: you'd know that if you read anything about clojure at all.. :/
07:44Guest27066i will go with take-until
07:44Guest27066makes sense
07:46daityaclgv: +1 / owl-v- please do read the learning material available, otherwise you'll hit really unnecessary roadblocks, like you are doing now... for example, http://www.braveclojure.com/ and aphyr.com/tags/Clojure-from-the-ground-up
07:47owl-v-i read "Maps store key-value pairs. Both maps and keywords can be used as lookup functions." and couldn't understand
07:49martinklepschanyone having used Schema here?
07:50martinklepschIs there a way to require a key to be i.e. a string?
07:50agarman@martinklepsch: yeah, both ole Scheme and Racket
07:50martinklepschagarman, actually talking about prismatic/schema here :P
07:54martinklepsch[(s/one s/Str "s") s/Str] — does it forme
08:06Guest27066anyone using fireplace facing problem of reloading record definitions?
08:06Guest27066re-definitions*
08:06Guest27066i guess it must be a clojure problem in general
08:14martinklepschhey
08:24gfredericksGuest27066: yeah that can be tricky; I think every time you reload you get a new class on the jvm; old instances have the old method definitions
08:24gfrederickseven weirder if you reload protocols that the records implement
08:25Guest27066yep, i end up killing the repl and restarting
08:26martinklepsch(zf/xml1-> xml-zipper :a :b zf/text) — how could I write this so that I can supply :a :b as list?
08:26gfredericksGuest27066: I can usually stay on top of things by making sure to reload protocols, then records, then restart stuff (e.g. w/ stuartsierra/component)
08:27martinklepschseems like something where you'd use apply but I'm not sure how since there is another mandatory thing at the end
08:27Guest27066hurm i find it very constraining
08:34gfredericksmartinklepsch: you could work something out with reduce for sure
08:34gfredericksGuest27066: what are you using records for?
08:35Guest27066gfredericks: just some abstraction which user can hold on to
08:35gfredericksGuest27066: when I use records I tend to minimize the amount of code inside the methods so it doesn't change as often
08:35Guest27066yep i noticed that
08:35Guest27066but i feels like a cheat
08:36Guest27066it*
08:36agarman, (#(apply + 1 (concat % [5])) [2 3 4])
08:36clojurebot15
08:36Guest27066reloading function which records use works seamlessly nonethless
08:37Guest27066hurm may be i can follow that more strictly
08:37gfredericksGuest27066: yeah; I've found that even when changing the implementations, I don't need to restart if I'm thorough about what gets reloaded
08:38gfredericksand it's usually obvious if I've screwed it up somehow
08:38Guest27066yeah changes are easy to track and reload
08:38Guest27066just canhe function and reload is what i usually do
08:39Guest27066change*
08:39martinklepschgfredericks, any more pointers? kinda lost I guess...
08:41gfredericksmartinklepsch: I'm not familiar with the xml stuff in particular, but I'd imagine (zf/xml1-> xml-zipper (as-> <> (reduce #(zf/xml1-> %1 %2) <> [:a :b])) zf/text)
08:41gfredericksthere might be a more succinct version based on what zf/xml1-> does exactly
08:44ryanbraganzanewbie question - how do I print a big number without the trailing N? e.g. user=> (println 1234123946812893467981236478921697384671823649612934678126389461278364912763461265216385123478213749712893478912378947)
08:44ryanbraganza1234123946812893467981236478921697384671823649612934678126389461278364912763461265216385123478213749712893478912378947N
08:44martinklepschhttps://github.com/clojure/data.zip/blob/b165e0c9d4ccd83280ac0462a36718b216b0ed20/src/main/clojure/clojure/data/zip/xml.clj#L56
08:45llasramryanbraganza: You `str` it first
08:45martinklepschgfredericks ^ — will look into your suggestion, thx!
08:46ryanbraganzallasram: thanks!
08:52martinklepschgfredericks, turns out I can just (zf/text (xml1-> .... ))
09:38akazlouhi, guys, having difficulties understanding the behavior of apply fn:
09:38akazlou(apply conj [1 2 3] 4) ;=> doesn't compile
09:38akazlou(apply conj [1 2 3] [4]) ;=> [1 2 3 4]
09:38akazloualthough:
09:38akazlou(conj [1 2 3] [4]) ;=> [1 2 3 [4]]
09:38akazlouwhat is happening in the background when apply is called?
09:40beamso,(conj [1 2 3] 4)
09:40clojurebot[1 2 3 4]
09:40beamso,(apply conj [1 2 3] 4)
09:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
09:41agarman,(apply conj [1 2 3] [4 5 6])
09:41clojurebot[1 2 3 4 5 ...]
09:41agarman,(doc apply)
09:41clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
09:41BobSchack,(apply conj [3] 3 1 3 4 4 [1 2 3])
09:41clojurebot[3 3 1 3 4 ...]
09:42BobSchackakazlou for apply it appears the last argument is expected to be a collection of arguements
09:42agarmanditto what BobSchack said
09:45BobSchackso you have (apply <your function> <arg1> <arg2> [<arg3> .. <argN>]) which is (<your function> <arg1> <arg2> <arg3> ... <argN>)
09:46akazlouwhat are the use cases when you need to use apply, instead of <your function> directly?
09:46teslanickApply lets you hand a constructed list of arguments to a function, where you may not know what those arguments are ahead of time.
09:47BobSchackIt's the same use case as *args in python
09:48agarman,(apply + (range 3 11 7/9))
09:48clojurebot682/9
09:48agarman,(doc +)
09:48clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'"
09:49teslanickOne where you might not know the arguments or the number of arguments ahead of time:
09:49teslanick,(apply + (take (rand-int 20) (repeatedly #(rand-int 10))))
09:49clojurebot6
09:49agarmanfor a fn like +, that's expecting a individual args, apply allows you to pass a sequence of args instead
09:50teslanickSum a set of random integers between 0 and 10, between 0 and 20 members in size.
09:51agarmanapply & reduce are similar
09:51akazlouok, need to think about it, thank you guys
09:52akazloureduce is a little bit different as I may say: reduce is (f (f (f (args)))
09:52akazlouwhen in apply f is called only once
09:53akazloubut, yes, they are similar
10:00akazlouin addition to apply question above:
10:00akazlou,(source apply)
10:00clojurebotSource not found\n
10:01akazlou(source apply)
10:01akazlou(defn apply
10:01akazlou "Applies fn f to the argument list formed by prepending intervening arguments to args."
10:01akazlou {:added "1.0"
10:01akazlou :static true}
10:01akazlou ([^clojure.lang.IFn f args]
10:01akazlou (. f (applyTo (seq args))))
10:01akazlou ([^clojure.lang.IFn f x args]
10:01akazlou (. f (applyTo (list* x args))))
10:01akazlou ([^clojure.lang.IFn f x y args]
10:01akazlou (. f (applyTo (list* x y args))))
10:01akazlou ([^clojure.lang.IFn f x y z args]
10:01akazlou (. f (applyTo (list* x y z args))))
10:01akazlou ([^clojure.lang.IFn f a b c d & args]
10:02akazlouso (apply conj [1 2 3] [4]) ;=> (apply conj (list* [1 2 3] 4))
10:02akazlou,(list* [1 2 3] 4)
10:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
10:02akazlou,(list* [1 2 3] [4])
10:02clojurebot([1 2 3] 4)
10:02akazlouand this result is then applied to conj
10:02akazlouwhich conj expects
10:04akazlouthrough conj.applyTo, (every fn is an instance of clojure.lang.IFn?)
10:04dnolen_akazlou: please don't paste into the channel, use a paste service
10:05akazlousorry
10:06teslanickakazlou: Yes. Every function (and many "not functions") are IFns
10:06teslanick(e.g. keywords are IFns too)
10:06agarmanand maps
10:06agarmanand sets
10:07teslanickI always forget about that. I find (:foo {:foo "bar"}) easier to think about than the inverse.
10:07teslanick({:foo "bar"} :foo)
10:08teslanick,({:foo "bar"} :foo)
10:08clojurebot"bar"
10:09teslanickBut applyTo takes a list of arguments:
10:09teslanick,(. conj (applyTo '([1 2 3] 4)))
10:09clojurebot[1 2 3 4]
10:12akazlouyes, this is what list* produces I guess
10:13teslanick,(doc list*)
10:13clojurebot"([args] [a args] [a b args] [a b c args] [a b c d & ...]); Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."
10:25btcNeverSleepsouch, my Emacs / erc session crashed... If anyone did answer about my "lein test" hanging on an assert failing, it would be great if you could paste the answer again ^ ^
10:45gfredericksteslanick: I think keywords-as-fns is useful for record-like maps while maps-as-fns is useful for homogeneous hash-map-like maps
10:45akazlouon clojure.test/is is there any convention which value in = comes first expected or actual:
10:45akazloui.e. (is (= <expected> <actual>)) or (is (= <actual> <expected>)), I see the value having <expected> first
10:46stuartsierra(is (= <expected> <actual>)) is the norm but not enforced
10:46teslanickgfredericks: That's actually a really good point that I hadn't thought about. I rarely use maps as hash-map-like maps (to my own detriment; it's hard to shake my JS-provided worldview)
10:47gfredericksteslanick: I think it's the same use cases for using a hashmap *at all* in a statically typed language
10:47gfredericksin my experience it's usually in algorithmic contexts rather than data/logic contexts
10:48akazlouthanks stuartsierra
10:50akazlouand if keywords and maps are both function, and in simple cases can be used interchangeably to get the value from the map, again which way is more common: (:keyword {<map>}) or ({<map>} :keyword)?
10:52teslanickAs gfredericks pointed out, if you're using your map as a record of keyword->value, it's ocmmon to do (:keyword {map of kw->value})
10:53teslanickBut not all map keys need to be keywords. You could do { 'foo "at foo" }
10:54teslanickIn which case, you would use the other form:
10:54teslanick,({ 'foo "AT FOO" } 'foo)
10:54clojurebot"AT FOO"
10:54gfredericksif you're writing code that you want to work with arbitrary maps and keys, the safest route is clojure.core/get
11:10akazlouyes, clojure.core/get is even necessary when you do (->) and keys are not keywords
11:10akazlou,(-> {:headers {"Content-Type" "text/html"}} :headers (get "Content-Type"))
11:10clojurebot"text/html"
11:13bbloomakazlou: that's a good spot for a get-in
11:13bbloom(get-in {:headers {"Content-Type" "text/html"}} [:headers "Content-Type"])
11:13bbloom,(get-in {:headers {"Content-Type" "text/html"}} [:headers "Content-Type"])
11:13clojurebot"text/html"
11:17akazloucool :)
11:19akazloustill trying to remember that you can any symbol in clojure fn name, like ? instead of is-, and even < and > :), which seems pretty common for Clojure
11:20seangrove,(def : get)
11:20clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :>
11:20seangroveSadly, lots of symbols you can't use (or at least start with), otherwise writing perl in clojure would be a lot easier
11:20martinklepschanyone a clever suggestion for something easily accessible like a map with multiple keys for the same value?
11:21martinklepsch{15 [:subdoc-abstract :paragraph]
11:21martinklepsch 16 [:subdoc-abstract :paragraph]
11:21martinklepsch 40 [:abstract]
11:21martinklepsch 41 [:abstract]}
11:22seangrovemartinklepsch: Probably a fn to construct that
11:23seangrove(mk-hash-map [15 15] [:subdoc-abstract] [40 41] [:abstract] [[:nested :vector] 99] [:example])
11:24martinklepschseangrove, yeah, probably just making a function that copies into the empty spots is simplest
11:27mikerodare there any good clj libs for working with Jar streams (input is my concern currently)? they are just annoying.
11:28mikerodclojure.java.io doesn't quote do it all for me; maybe I just don't know how to use it good enough :P
11:30stuartsierramikerod: https://github.com/clojure/java.classpath may help a little
11:41felherHey folks. Say I have an impure function that returns something I need, like `create-random-card-deck`, whats the easiest way to get a sequence of n times invoking that function? (doall (map (fn [f] (f)) (repeat n create-random-card-deck))) doesn't strike me as being overly convenient.
11:41llasram&(doc repeatedly)
11:41lazybot⇒ "([f] [n f]); Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied) lazy sequence of calls to it"
11:41mikerodstuartsierra: thanks! I'll take a look. after reading this project description, I think it is useful for other things I've been looking at to. win-win
11:41felherllasram: perfect! Thanks!
11:49TimMcseangrove: "sadly", yes...
11:56martinklepsch(fun :that :takes :a :lot :of :arguments) how could I rewrite that so that it takes a list which supplies some of those arguments? like (fun % :more :arguments)
12:01seangrovemartinklepsch: apply?
12:01seangrove(doc apply)
12:02clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
12:03seangrove(map (partial apply +) [[1 1] [2 2] [3 3]])
12:03seangrove,(map (partial apply +) [[1 1] [2 2] [3 3]])
12:03clojurebot(2 4 6)
12:07rasmusto,(apply vector 1 2 3 [4 5])
12:07clojurebot[1 2 3 4 5]
12:08hfaafbrequire_once("../../lib/WebServiceCore.class.php");
12:08hfaafbmy bad!
12:09hfaafbhow embarassing
12:09hfaafb<_<
12:09rasmusto~php
12:09clojurebotphp is http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
12:09nullptr`hfaafb: yeah, here we say (require-once "../../lib/WebServiceCore.class.php") -- sheesh
12:09hfaafb:)
12:09rasmusto:)
12:13jcromartie,((memfn .toUpperCase) "test")
12:13clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: .toUpperCase for class java.lang.String>
12:13jcromartieWHY?
12:14nullptr`,((memfn toUpperCase) "test")
12:14clojurebot"TEST"
12:14jcromartieoh...
12:14jcromartiethanks
12:16martinklepschseangrove, rasmusto, that works if I only want to append fn-arguments but not if I want to insert them in the middle
12:19felherWhy does the following code stack overflow? (println (reduce #(map + %1 %2) (repeat 2000 [1])))
12:19felherI guess there some lazy-magic going on there, since doing #(doall (map + %1 %2)) seems to fix the problem.
12:21justin_smithfelher: for me that does not so, and returns quickly
12:21justin_smith,(println (reduce #(map + %1 %2) (repeat 2000 [1])))
12:21clojurebot(#<StackOverflowError java.lang.StackOverflowError>
12:21TEttingerheh
12:21justin_smithodd
12:21felher:)
12:22stuartsierrafelher: Lazy sequences nest. If you wrap too many of them, it overflows the stack when you try to consume it.
12:23stuartsierraThis shows up often if you use `concat` to build up a long sequence in a loop.
12:23TEttinger,(reduce #(mapv + %1 %2) (repeat 2000 [1])) ; I wonder...
12:23clojurebot[2000]
12:24TEttingermapv does avoid the laziness from repeat, interesting
12:24felherstuartsierra: oh, okay, thanks :)
12:25justin_smithTEttinger: I think the problem was the map laziness - it is reduce that eliminates the repeat laziness
12:25TEttingerah
12:26justin_smithTEttinger: the reduce ends up building a long chain of map upon map, none forced until the print stage
12:26TEttingerah! that makes sense
12:28tuddif you create a defrecord `RecordType` and define an instance with (def RecordType some-record) can you later pass that some-record into another fn and reference some-record.property
12:28tuddseems like a straightforward thing to do in OOP-land..
12:28base698is there a better repl so you can use emacs bindings to go back in history, jumper words etc?
12:29jcromartiebase698: cider
12:29justin_smithtudd: that makes very little sense
12:29jcromartiebase698: you can use it to connect to an nREPL in your leiningen projects
12:29jcromartieor anywhere, like on a production server :)
12:30jcromartiebase698: that's an Emacs mode, BTW
12:30TEttinger(def RecordType some-record) can't be the right syntax
12:30justin_smithclojure version (def instance (RecordType. arg0 arg1 arg2 ... argN)) (:property instance)
12:30justin_smithor even (.property instance)
12:33tuddhttp://pastebin.com/htSdGhwY
12:33justin_smith,(do (defrecord RecordType [property]) (def instance (RecordType. 42)) (-> instance .property))
12:33clojurebot42
12:35justin_smithtudd: in that example, you can use (.ticker order) instead of order.ticker
12:35justin_smithor (:ticker order)
12:35justin_smithor (-> order .ticker)
12:35justin_smithbut order.ticker is an error
12:36justin_smithand the right way to do it: {:params order :handler handler ...}
12:36tuddjustin_smith: yep. error. but not in the repl
12:36justin_smithI am extremely skeptical that it would not be an error in the repl
12:36justin_smithjust pass order as the params, clojure will use it as a map, it will just work
12:37tuddLT is cool with returning order.broker
12:37justin_smithalso in this case you could just use a map instead of defining an Order record
12:37justin_smiththen LT is broken
12:37justin_smithbecause that is not clojure code
12:38lorefyrHi everyone
12:38tuddI didn't think so. But coming over from JS land, that does work, normally ;)
12:39justin_smithright, clojure is not js though
12:39tuddcljs
12:40justin_smithcljs is not js either
12:41justin_smithThe google results for searching "clojure publish rss" are filled with useless results (pages that have the word "rss" somewhere, because that page has a feed) - any good libs out there for publishing rss with clojure?
12:41seangrovejustin_smith: (js/console.log "x") is valid cljs
12:42justin_smithseangrove: oh, weird
12:42seangrove(js/Math.floor ...)
12:42seangroveetc.
12:42tuddhttps://github.com/yogthos/clj-rss
12:42justin_smithnever mind my above question, I found yogthos/clj-rss
12:42justin_smithhah, thanks :)
12:42stuartsierraSometimes the ClojureScript compiler will let through things like `foo.bar`. I wouldn't rely on that, though.
12:43justin_smithstuartsierra: so that isn't an intentional feature?
12:43seangrovejustin_smith: With cljs, it's always hard to tell :)
12:43tuddAs it spits errors when called from within another fn, I won't
12:44justin_smithseangrove: the js murkiness sneaks in, I guess :(
12:45seangrovejustin_smith: A bit. A lot of it is just unspecified behavior that'll be nailed down as practices are established
12:45tuddfoo.bar is NOT idiomatic clojure(script), and even though you want it to ultimately become js, not gonna let you!
12:46justin_smithyeah, I never even thought to try foo.bar in cljs
12:47tudddon't bother. LT gets red-in-the-face mad at ya
12:47mr-foobarcljsc nodehello.cljs '{:optimizations : :target :nodejs}' > nodehello.js
12:47justin_smithwhich dead horse?
12:47mr-foobaris giving me "goog.addDependency("base.js", ['goog'], []); ..." in the compiled file
12:47seangrovefoo.bar
12:48justin_smithit was new to me, sorry
12:48seangrovejustin_smith: Oh, not at all ;)
12:48seangroveAnyway, just added a css reset: * { position: absolute; top: 0px; left: 0px;}, let's see how this goes
12:50tuddjustin_smith: thx again! collapsing LOC nicely after your suggestion
12:50tuddplus that, it now works! thing
12:50justin_smithtudd: cool
12:50justin_smithso you are just passing :params order now?
12:51tuddyep
12:51justin_smitha similar trick is (select-keys order [:keys :we :use :here])
12:51justin_smithor (assoc order :this "also" :and "this")
13:07gozalatbaldridge: Do you have time for a question regarding core.async/net ?
13:07tbaldridgesure
13:10gozalatbaldridge: so I was looking at the source
13:10gozalatbaldridge: and notice pattern similar to one I used
13:10gozalafor buliding node.tcp module using core.async
13:11gozalatbaldridge: https://github.com/Gozala/node.core/blob/master/src/node/tcp.cljs
13:11gozalatbaldridge: only thing I noticed though
13:11gozalaor rather did not quite got
13:11tbaldridgegozala: what do you mean by core.async/net btw? that doesn't quite exist?
13:12gozalatbaldridge: I was looking at
13:12gozalahttps://github.com/clojure/core.async/blob/net-channels/src/main/clojure/clojure/core/async/net.clj
13:12gozalatbaldridge: I’m aware it’s does not exists yet :)
13:13tbaldridgeso I'll caution you as that has mostly been considered a bad idea and discontinued :-P
13:13gozalatbaldridge: Anyway what I was trying to understand was what’s a good way to deal with errors
13:13gozalatbaldridge: I see
13:14gozalatbaldridge: are there any ideas right now that are considered good ?
13:14gozalain terms of networking or any IO really ?
13:15tbaldridgegozala: errors are one thing, that we can discuss. Trying to create channel like semantics over a unreliable connection (like TCP or any net connection) creates a ton of problems.
13:16gozalatbaldridge: are those problems listed somewhere ? I would like to look at them
13:16gozalatbaldridge: I would also like to discuss errors
13:17gozalatbaldridge: so now I define connection in terms of a ISocket
13:17gozalathat is record of input, output, and error channels
13:18gozalaso data read from the connection is put onto input
13:18gozaladata put onto output channel is written into underlying connection
13:19gozalaif there is an error it’s put onto error channel
13:19gozalatbaldridge: ^
13:20gozaladoes that sounds reasonable so far ?
13:21gozalaor did I ignored tons of problems already ?
13:24gozalatbaldridge: So my question regarding errors was mainly regarding how one would distinguish between write and read errors
13:24gozalaor how had error would carry info regarding where did it happened
13:26gozalatbaldridge: I other words I am no longer sure that dedicated error channel for buth input / output errors was such a good idea
13:26justin_smithgozala: tcp connections introduce complications in error handling - like with a socket being held open, you don't get an error when you send the message that fails, you get an error later because tcp is retrying (you probably already know this I guess)
13:27gozalajustin_smith: so that is more or less why I’m bringing it up
13:28gozalajustin_smith: also I would kind of run into same issue if I would implement something like buffered FileWriter
13:28tbaldridgegozala: sorry, had to run for a sec, back now
13:29gozalawhere it’s not obvious how to associate error with chunk that was put
13:29tbaldridgegozala: justin_smith brings up some good points, and that's all part of the fun of working with tcp.
13:29justin_smithgozala: it forces everything to be async and nonlinear
13:30tbaldridgegozala: that's why I took a different approach with Hermod (kindof the successor to core.async/net): https://github.com/halgari/com.tbaldridge.hermod
13:30justin_smithso you should make your model so that it maps cleanly to tcp's weird time semantics
13:30tbaldridgegozala: if you push error handling off on to the app code things get a bit simpler for both the library and the app (imo).
13:31gozalatbaldridge: looking at that lib now
13:32justin_smithtbaldridge: gozala: yeah, that looks like the kind of approach I was suggesting actually
13:32tbaldridgeyeah it's a lot like the actor model, except processes aren't tied to mailboxes.
13:33gozalajustin_smith: tbaldridge I’m afraid it’s not clear to me yet what the approach looks like yet
13:34gozalatbaldridge: are there any examples anywhere outlining error handling ?
13:36gozalatbaldridge: or is idea is that if message send timed out that is an error ?
13:36seangrovebbloom: In your layout system, is slot meant to be absolutely positioned against the entire screen, and content relative to its parent?
13:38bbloomseangrove: i forget how i implemented it, but generally i prefer local coordinates wherever possible
13:38tbaldridgegozala: sending a message is always non-blocking, so sending always succeeds, but the message may not get to the other end
13:38bbloomgame dev habits die hard
13:38gozalatbaldridge: so if I read correctly
13:38tbaldridgegozala: so the only way to ensure delivery is to send a message with a "respond-do" address and wait until you hear back from the receiver. If you don't get a reply, try resending the message, or give up.
13:38tbaldridge"respond-to"
13:38gozalathere are things like ::errro put on channel
13:39gozalatbaldridge: ok I see
13:40gozalatbaldridge: I guess what I am looking is something more abstract
13:40gozalatbaldridge: Can I give that FileWriter example I mentioned eariler
13:40bbloomfor the record, i don't think CSP makes any sense in a distributed context
13:41tbaldridgeand that's the problem. it really doesn't
13:41tbaldridgechannels are transactional, blocking and guaranteed delivery, that's pretty much the exact opposite of network connections.
13:42justin_smithbbloom: I think it can make sense, but only with the added abstraction allowing you to describe tentative and retroactively failed communications - not as a direct mapping (which is the naive and common first approach)
13:42danielszmulewiczdnolen_: ping
13:42dnolen_danielszmulewicz: pong
13:42danielszmulewiczHi David, you helped me yesterday with bringing javascript objects to participate in pattern matching. I'm wondering now about Javascript arrays. According to the documentation, any Sequential type is eligible, but Javascript arrays are not sequential. Am I right that I could aim to reify array instances with the ISequential protocol? I can't find anything on that. Can you point me to the right direction?
13:42gozalatbaldridge: I think it’s not only about networking though
13:42seangrovetbaldridge: Is it used for distributed things in Go? I've not seen it at all, so not sure
13:43bbloomjustin_smith: when failure is the norm, not the exception, i'd prefer a different model
13:43tbaldridgeseangrove: sure, but go doesn't attempt to make a "distributed channel".
13:43gozalaif you do any IO and you have a buffered channel to feed data into it
13:43gozalatbaldridge: you hit more or less same problem
13:43bbloomtbaldridge: justin_smith: CSP is slightly different than just sockets + queues... you can make stuff like zmq work nicely in a distributed context
13:44seangrovebbloom: Presumably the global offsets should be passed in as well. I'm thinking of draggable snap-to-guideline/grid/other-thing outside of the component itself
13:44bbloombut it's much more complex than shared memory networking
13:44justin_smithfair enough :) I'm just saying with the right abstraction failure can be integrated into the CSP model I think - as long as you don't expect the network to be a transperent medium
13:44seangrovetbaldridge: Ok, makes sense
13:44bbloomseangrove: ok, get ready... i'm going to send you another MSDN link lol
13:44bbloomseangrove: http://msdn.microsoft.com/en-us/library/ms743737(v=vs.110).aspx
13:44gozalaon one of the writes to disk writer may fail and there is no clear way to communicate that to a producer
13:44gozalaor data provider
13:45tbaldridgebbloom: YAY! more XAML based stuff
13:45seangroveAdorners!
13:45seangroveffs
13:45tbaldridge(seriously, the only thing I hated about XAML was the XML part and the mutability, that stuff rocks)
13:45bbloomtbaldridge: no really, you're right. xaml is a good idea wrapped in a cloth of bad ideas
13:45bbloomtbaldridge: fundamentally, the good idea is basically EDN :-)
13:46bbloomgeneral purpose, extensible data construction syntax
13:46seangroveAh, but this does seem like a a good idea
13:46bbloomtbaldridge: oh jeeze, i'm sorry
13:46bbloomjavafx was oracle getting WPF envy and fucking it up
13:46tbaldridgejavafx2 isn't as bad
13:47tbaldridgeand don't knockit till you try it, edn syntax + clojure primitive and core.async makes it quite nice actually.
13:47bbloomheh ok, i can buy that
13:48bbloomat least compared to HTML and/or swing, for sure
13:48tbaldridgeyeah exactly
13:48tbaldridgeand now back to working with metadata and macros....to whomever wanted good line numbers inside a go macro....I hate you right now
13:48tbaldridgelol
13:48bbloomseangrove: anyway, fns to map between local & global coordinates are context-dependent (of course) so you should use local coordinates wherever possible to avoid having to do lots of inverse transformations
13:49bbloomseangrove: also, it's ok to put things at negative relative positions, you just need to deal with clipping policy
13:50danielszmulewiczdnolen_: Hi David, you helped me yesterday with bringing javascript objects to participate in pattern matching. I'm wondering now about Javascript arrays. According to the documentation, any Sequential type is eligible, but Javascript arrays are not sequential. Am I right that I could aim to reify array instances with the ISequential protocol? I can't find anything on that. Can you point me to the right direction?
13:52dnolen_danielszmulewicz: I think for now you need to do (matchv :clojure.core.match/objects [arr] ...)
13:53dnolen_danielszmulewicz: I recommend looking at the ClojureScript tests for examples - also feel free to update the wiki, I'm sure other people have similar questions.
13:53danielszmulewiczdnolen_: OK, I'll do that. Thanks.
13:54danielszmulewiczdnolen_: By the way, converting my array with js->clj doesn't hurt neither. Does this seem acceptable to you?
13:55seangrove"The arrange pass begins with a call to the Arrange method. During the arrange pass, the parent Panel element generates a rectangle that represents the bounds of the child. This value is passed to the ArrangeCore method for processing."
13:55seangrovebbloom: ^^ The rectangle representing the bounds of the child is the slot rectangle in your system, right?
13:55dnolen_danielszmulewicz: yes if expressivity outweights perf
13:55dnolen_outweighs
13:56bbloomseangrove: right b/c the child may be given a slot that's too big, so the child has margin & alignment settings to say how it gets positioned within that slot
13:56danielszmulewiczdnolen_: Yes, makes sense.
13:56seangrovebbloom: Alright, hope to have an Om render in an hour or so
13:58bbloomseangrove: just added you to a private repo of mine. plz don't commit to it ;-) it's got a layout.clj file that is more feature complete
13:59bbloomseangrove: if you eval the render forms in core.clj you can play with the layout engine
14:08Bronsabbloom: just noticed you have a typo in the github description for backtick
14:08Bronsas/marco/macro
14:09bbloomBronsa: fixed, thanks
14:13mikerodare there any libs out there that deal with attempting to fully-qualify all symbols in chunks of code and the context of their originating namespace? the goal being to store off the code as pure-data, that is sufficiently descriptive to be read back in and compiled at a later time.
14:14mikerod*chunks of code with the context of their originating namespace*
14:14technomancymikerod: sounds like the analyzer?
14:14amalloymikerod: tools.analyzer?
14:17mikerodtechnomancy: amalloy this is what I thought
14:18mikerodI'm not sure that it actually "qualifies" the symbols; but mabye I haven't dug enough
14:18mikerodI know the idea is to make the AST data though
14:18amalloyit knows where they come from
14:18mikerodok
14:18mikerodI think I will continue to explore that then
14:18amalloyand then you can write a pass that consumes the AST and produces whatever you want. if you want, that can be a source-code form with qualified symbols, i imagine
14:19mikerodthat makes sense
14:19mikerodthis sounds promising
14:19mikerodI've only scratched the surface on tools.analyzer; and recently listened to the talk by umm
14:19amalloyby tbaldridge
14:19amalloy(i guess, anyway)
14:20mikerodyes
14:20mikerodthat is it :)
14:20mikerod"data all the ASTs"
14:20tbaldridgemikerod: you might checkout this : https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/ast/query.clj
14:20tbaldridgeit stores tools.analyzer asts in Datomic
14:21tbaldridgehaven't tried it, but it looks cool.
14:21Bronsamikerod: there's an emit-form pass that compiles the AST back to clojure source. It doesn't return qualified symbols but I have a branch locally that enables that, I can finish that and push that if you need it.
14:21mikerodtbaldridge: awesome and Bronsa that certainly sounds valuable
14:21Bronsatbaldridge: it doesn't really store asts in Datomic, it just uses Datomic's datalog
14:22mikerodI have done some "hand-rolling" of my own to qualify symbols
14:22mikerodbut not to the extent of the full-blown AST analysis
14:22tbaldridgeBronsa: yeah I just noticed that, lol
14:22Bronsamikerod: beware that it will macroexpand the source though
14:24mikerodBronsa: yeah, I am curious on this. I technically have some symbols in the source that do not "make sense" in the initial context. I'm wondering if this will cause the analysis to fail, or if I can "mock out" those symbols into the context to avoid failure.
14:24mikerodThis is DSL-stuff
14:24Bronsamikerod: the analyzis will work only if the source can be eval'ed.
14:25Bronsamikerod: however you can cheat and give the analyzer a patched-up env
14:25mikerode.g. I have some code like: (+ a b im-a-undefined-symbol) ; where a and b are defined, the other is not; I will fill it in at a later time when reading back out the code and evaluating
14:25mikerodBronsa: I think the patched-up env was my hopes/thoughts
14:26Bronsamikerod: to do that you need to know what locals/vars your code is going to use that are not already defined though
14:26jcromartiefor some reason I'm stumped on this one: how to write a HOF which takes a function and returns a new function that ensures the original function is called once and only once
14:27mikerodBronsa: I figured. I do wish I could "catch" failures to resolve symbols and provide a handler for it. I'm not thinking this is possible, but just a cool idea.
14:27Bronsamikerod: if you can't know that, a really hackish way to make that work is to redefine this multimethod https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/passes/jvm/validate.clj#L19 not to throw
14:27Averella closure with a flag is not good enough?
14:27jcromartieAverell: derp
14:28jcromartiewell no
14:28jcromartiethat's not good enough
14:28jcromartiewhat if it's called from two threads?
14:29mikerodBronsa: interesting, thanks for the reference
14:29jcromartieoh, maybe a promise is what I'm looking for
14:29jcromartieeh… still, race condition
14:30jcromartiethe function that I want to once-ify has side effects
14:31jcromartiehm, maybe laziness is the answer
14:31amalloyjcromartie: you close over a delay
14:31amalloyassuming the args are known already?
14:31jcromartieargs are not known
14:32jcromartiebasically like memoize
14:32jcromartiebut safe for side effects
14:32amalloyeh. so you use the same trick that's available to make memoize avoid side effects
14:33amalloy(defn call-once [f] (let [value (atom nil)] (fn [& args] @(swap! value #(or % (delay (apply f args)))))))
14:33amalloyer, avoid side-effect problems
14:34justin_smithjcromartie: maybe something like https://www.refheap.com/77421
14:34jcromartieamalloy: memoize is not safe
14:34jcromartie,(let [f (memoize println)] (dorun (pmap f (repeatedly 10 #(rand-int 10)))))
14:34clojurebot#<SecurityException java.lang.SecurityException: no threads please>
14:34amalloyjcromartie: that's why i said, the trick that's available. you can make memoize safe by storing a delay
14:34jcromartieok
14:35jcromartieahhh
14:35amalloyinstead of storing the actual value
14:35amalloyi mean, i just typed out my call-once in irc, but i think it's the solution you want
14:37amalloyholy smokes, justin_smith. if you use @ and reset!, you're like never thread-safe
14:38justin_smithgood point
14:39amalloyjcromartie: my version returns the result of the first call, regardless of what args are passed to the second call. so that may not be what you want, i suppose
14:44Bronsamikerod: just pushed the impl: http://sprunge.us/WLaL?clj
14:45justin_smithamalloy: jcromartie: edited https://www.refheap.com/77421
14:45jcromartiesee, this is harder than everybody thinks it is :)
14:45mikerodBronsa: awesome! thanks. I will definitely start experimenting with this then.
14:46amalloythat has the same problem memoize has, justin_smith. two threads can both be inside that swap! at the same time
14:46justin_smithoh, tricky
14:47amalloythat's, again, not a problem in my solution
14:48koreth_I want to parse a whitespace-delimited string into a vector of integers. (mapv #(Long. %) (clojure.string/split my-string #"\s")) does the trick but #(Long. %) seems unnecessarily ugly -- is there a more idiomatic "parse a number" function?
14:48jcromartieif it's a thunk it's not a problem
14:49amalloyjcromartie: huh?
14:49justin_smithamalloy: yours not intended for usage with functions that return nil, I assume?
14:49amalloyjustin_smith: works for all functions
14:49amalloytry it and see
14:50Averellwhy is it safe? i don't understand which part hides the locking
14:50amalloyAverell: it's dereffing the delay
14:50amalloythere's a lock around that
14:50justin_smithamalloy: oh, of course, because it returns the delay, and derefs, so that delay will not be nil after the first call
14:50justin_smithsmart
14:51jcromartieamalloy: I think yours is good BTW
14:51jcromartieI was saying that if you want to make a thunk callable once it's really easy
14:51jcromartieif you don't have to worry about args
14:52amalloyoh, for sure. that was my original suggestion: close over a delay
14:52amalloybut it only works for thunks
14:52nullptr`koreth_: somewhat clunky, but you can use read-string instead of #(Long. %)
14:52koreth_Thanks
15:10jcromartieIs there a simpler version of: (not-any? nil? coll)
15:10jcromartieI think it's pretty clear, myself.
15:16jcromartielong-running futures are probably not a good way to handle periodic background tasks
15:16jcromartielike, (loop … (Thread/sleep 300000) (recur))
15:16jcromartiewrapped in a future
15:19teslanickYou could use core.async to handle occasional background tasks.
15:21seangrovebbloom: https://www.refheap.com/fa7a23df23c6a97e7725391be => http://dl.dropbox.com/u/412963/Screenshots/du.png, slots working, content up next
15:22bbloomseangrove: cool
15:22Rosnecis it possible to use ztellman's gloss library to decode bytes from a file where you don't know the byte-count ahead of time?
15:22bbloomseangrove: happy with my approach? i don't remember how i felt about it ;-)
15:23seangroveBlack space represent difference between slot-space and content-space. Some cheating in that the browser is still doing some layout intra-component.
15:23seangrovebbloom: So far, mostly very happy. Few questions though
15:23bbloomseangrove: relying on browser for text layout etc is probably quite sensible
15:23RosnecI can put byte-counts as prefix information, but I still need to be able to read from the file without knowing the size right away
15:24bbloomseangrove: definitely check out how that newer code i gave you access to handles margin & alignment
15:24jcromartiethis is how I roll https://gist.github.com/jcromartie/11052252
15:25Bronsajcromartie: jesus christ.
15:25amalloyjcromartie: (partial - 0)? that's just -
15:26bbloomjcromartie: #concatenative is that way ---->
15:26amalloyoh, no, i guess it's not, if you pass multiple args?
15:26amalloybut in your case you're not
15:26jcromartieoh, good to know!
15:27amalloyand what is the deal with (comp f (comp g h) blah blah)?
15:27amalloy(if you're going to post silly point-free code i have to assume you're willing to have it picked apart)
15:27jcromartiewhich line?
15:27jcromartieyes, please
15:27amalloy10-12
15:28jcromartieah yes
15:28Averellbtw, vigenere is no longer considered safe by many people.
15:28amalloy(comp (partial map (comp f g)) (partial map h)) is (partial map (comp f g h))
15:28mi6x3mclojure, why is this working: (map (fn [a] { :a a }) "aaaa"), but this doesn't: (map #({ :a % }) "aaaa")
15:28Bronsami6x3m: #(f) is (fn [] (f)) not (fn [] f)
15:29seangrovebbloom: Should components be able to provide default layout guidance? e.g. I have a bootstrap panel, it conceptually has a header and a body. I probably want to think about layout for the body, but not necessarily the panel header (e.g. it should always be 15px heigh and 100% wide if that's what it suggests)
15:29amalloy,'#({ :a % })
15:29clojurebot(fn* [p1__25#] ({:a p1__25#}))
15:30bbloomseangrove: the parent shouldn't have any insight in to what's inside the children other than to parameterize them
15:30jcromartieamalloy: excellent
15:30amalloy(partial list cycle [0]) is weird but i don't really get what it's doing
15:30bbloomseangrove: so from the parent's perspective, layout is about bounding rect only
15:30mi6x3mBronsa: I see, so I have to use a function to create the map?
15:30amalloy(comp reverse (partial list ...)) seems like it ought to be (comp rseq (partial vector ...)) - gotta eke out all that performance!
15:31mi6x3mBronsa: yeah, works with hash-map
15:31mi6x3mtnx
15:32derek_cdoes anyone know how to specify a head value in a ring handler? it's returning something like {:status 200 :body "..."}, but I tried adding a :head key and it didn't work
15:32derek_cthe resulting HTML has an empty head element
15:32hfaafb:body doesn't mean the contents of <body>
15:33hfaafbit represents the body of the http response
15:33derek_chfaafb: ah!
15:33derek_chfaafb: got it. thanks a lot
15:34hfaafbyw
15:34jcromartieamalloy: I had never heard of rseq before… good to know!
15:37jcromartiealso, (comp vec (partial map f)) is (comp (partial mapv f))
15:37jcromartiesoon this will be as concise as it would be with arguments!
15:38justin_smithjcromartie: you could also maybe reverse the order of the code and use ->> instead of comp
15:39justin_smithdunno if that defeats the point of what you are trying to do
15:40hyPiRionjcromartie: and `(comp (partial mapv f))` is just `(partial mapv f)`
15:40amalloy(comp reverse (partial list 26)) could also be written as (partial conj '(26))
15:40jcromartiewell true but I have more in the comp
15:41jcromartieamalloy: yeah, just arrived at that oto
15:41jcromartietoo
15:41amalloythat's a better solution than my earlier suggestion of comping rseq and vector
15:41jcromartiesame for (partial conj (list [0] cycle)) for the args to (partial apply update-in)
15:41jcromartienow here's a question: is
15:41jcromartieis "let"
15:41jcromartie(excuse me, typing difficulties)
15:42jcromartieis "let" considered valid in point-free style?
15:42amalloycertainly not
15:42jcromartieok
15:42justin_smithit's not really point free is it?
15:42jcromartiejustin_smith: why not?
15:42justin_smiththe bindings have names
15:42amalloya "point" is a named variable
15:42bbloomjcromartie: post a before & after when you're done :-P
15:43jcromartieoh let, no
15:43justin_smithor am I missing what you are saying altogether
15:43seangrovebbloom: From the parent's perspective, layout (for the parent, or for any of its children) is about bounding rect only?
15:44seangroveWhoops, meant to ask essentailly, whether the parent knows the layout of its childrent or is allowed to set the bounding rect of its children
15:45bbloomseangrove: only the runtime does any sort of hierarchical layout. any given layout mechanism should only handle a list of rectangles
15:45jcromartiejustin_smith: I thought you were talking about the code as a whole, not just let bindings
15:45jcromartiebut point-free programming is not just programming without names
15:45jcromartieit's programming without named arguments to functions
15:45jcromartieyou still need to name things
15:46jcromartieI'd like to eliminate the redundant (int \A)
15:47derek_ccan you write simple text-substitution macros in Clojure? Like for instance, I want a macro that represents two literal elements 1 and 2, so that I can create a vector with 3 elements like this: [(my-macro) 3]. Is that possible?
15:47amalloythat's what juxt is for, jcromartie. create two different functions that both want to receive (int \A) and juxt em together
15:48amalloyderek_c: no
15:48amalloyyou can write `[~@(my-macro) 3]
15:48justin_smithderek_c: for that to work, it would need to be possible to return two things that are not joined by some structure, which just isn't a thing in clojure
15:49derek_cthe thing is, I'm working with hiccup templates, and I just can't figure out how to properly compose views
15:49derek_cyou guys know how hiccup/html takes an arbitrary number of arguments right
15:50jcromartieI can just (def a-start (int \A))
15:50derek_cso say all my views start with two certain elements, like
15:50amalloyderek_c: you want the function named: list
15:50amalloy(html (list a b) c) is the same as (html a b c)
15:50derek_camalloy: oh really?
15:51derek_camalloy: but that's not a language-level thing right? it's just hiccup looks at the argument and say, ok it's a list, so we do this
15:51justin_smith,(concat [1 2] [3]) in other contexts, there is concat
15:51clojurebot(1 2 3)
15:51amalloyindeed
15:51bbloomseangrove: does that make sense?
15:51arav93stuartsierra: Does the construct-calendar private function in clojure.instant take a string as input, I felt it's so by reading through the code, just need to confirm.\
15:53stuartsierraarav93: Honestly I don't remember anything about clojure.instant.
15:53arav93Yeah, I'm sorry to have disturbed you.
15:53derek_cis (list 1 2) the exact same thing as '(1 2)?
15:54derek_camalloy: thanks a lot!
15:54amalloywelllllll, there are a lot of ways to understand that question
15:55derek_cfound this: http://stackoverflow.com/questions/3896542/in-lisp-clojure-emacs-lisp-what-is-the-difference-between-list-and-quote
15:55amalloyif they're evaluated, then yes they have the same value. but if they're passed to a macro that inspects them, it will see something different. or if you need something that's not a literal, rather than 1 and 2, then the two forms do different things...
15:55justin_smith,(do (require 'clojure.instant 'clojure.repl) (clojure.repl/source clojure.instant/construct-calendar))
15:55clojurebotSource not found\n
15:55stuartsierra`clojure.instant/construct-calendar` just takes integer arguments for each component of the Calendar.
15:55stuartsierrahttps://github.com/clojure/clojure/blob/201a0dd9701e1a0ee3998431241388eb4a854ebf/src/clj/clojure/instant.clj#L237
15:55justin_smithas is clear if you look at the source
16:00jcromartie(def papply (partial partial apply))
16:00jcromartie #ohgodwhy
16:01amalloyjcromartie: that's in useful, named ap
16:02amalloythough i don't think i ever actually used it
16:04justin_smith(def pc (partial conj)) would also make it more succinct
16:04justin_smithI meant partial partial conj of course
16:04Rosnecdoes anybody know if the ztellman/gloss library has a means of reading encoded data from an input which possibly has extra bytes on the end?
16:05jcromartieoh god oh god oh god
16:05jcromartiehow about (comp (partial apply mod) reverse (partial list 26))
16:05jcromartieoops
16:06jcromartie(def parpar (partial partial partial))
16:07hyPiRionnow just throw in a juxt there and you're set
16:07justin_smith(def parpar (apply partial [(take 2 (repeatedly partial))])) ; easier to generalize
16:09justin_smith(def parpar (apply partial (take 2 (repeat partial)))) ; fixed
16:10hyPiRionjustin_smith: (repeat 2 partial) is shorter
16:10justin_smithtrue!
16:10jcromartienice
16:11mi6x3m-althey who here is using nightcode?
16:11mi6x3m-altis seems to be a fun IDE
16:11mi6x3m-altquick start and someone effective for small stuff
16:11justin_smith(defn parⁿ [n] (apply partial (take n (repeat partial))))
16:11jcromartiebeat me to it, justin_smith
16:11justin_smithheh, I even put a nice superscript in the name
16:13jcromartiejustin_smith: but you have a named arg!
16:22oinksoftwhat does &name mean in clojure?
16:23oinksoftlike &form and &env in the source on http://clojuredocs.org/clojure_core/clojure.core/defn
16:23Bronsaoinksoft: &name has no special meaning in clojure, it's a regular symbol
16:23justin_smith,((fn [& name] (concat name name)) 1 2 3 4)
16:23clojurebot(1 2 3 4 1 ...)
16:23justin_smith,((fn [& name] (concat name name)) 1 2)
16:23clojurebot(1 2 1 2)
16:23weavejesteroinksoft: They’re special macro symbols
16:23oinksoftBronsa: how does defn bind to the name without using a macro?
16:24weavejesteroinksoft: http://blog.jayfields.com/2011/02/clojure-and.html
16:24Bronsaoinksoft: &form and &env are implicit arguments on macros
16:24Bronsaoinksoft: thei are bound by the defmacro macro
16:24oinksoftbut defn isn't defined as a macro?
16:24oinksoftor am i readin gthis wrong http://clojuredocs.org/clojure_core/clojure.core/defn
16:25Bronsaoinksoft: it is declared as a macro later in the source
16:25Bronsaoinksoft: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L318
16:26weavejesteroinksoft: the clojure.core source code shouldn’t be considered idiomatic Clojure, because it’s bootstrapping the language
16:27oinksoftinteresting, thanks Bronsa
16:27weavejesterdefmacro is defined after defn in the source, so defn is “manually” converted into a macro
16:27rasmustodefmacro is a fn?
16:28oinksoftnope it is bootstrapped the same way as a macro
16:28weavejesterrasmusto: internally macros are functions that are tagged as being macros
16:28oinksoftand it calls (list '. (list 'var name) '(setMacro)), which is what is done manually for defn and defmacro
16:29rasmustooh this thing? (. (var defmacro) (setMacro))
16:29oinksoftthanks Bronsa and weavejester :)
16:29Bronsarasmusto: yeah. setMacro simply adds :macro true to the Var's meta
16:29weavejesterYeah. Needless to say, this isn’t what you should use in your own Clojure apps.
16:30rasmustohah, okay. Thanks for the clarification
16:31weavejesterHm, should I go with “reploaded” or “reloaded.repl” for a library of repl functions based off the reloaded workflow
16:32arrdemthe latter
16:32weavejesterThat was my inclination as well. It gives a nicer namespace
16:32arrdempunny names are awesome but hard to remember and search for :P
16:32Frozenlockreloaded.repl is indeed nicer
16:32arrdem$logs
16:33arrdemright. I'm bot ignored.
16:33weavejesterpunny names do have the advantage of being unique, though.
16:34FrozenlockIt's the wild west here, first one to grab a namespace gets it!
16:35arrdemplz no top level packages
16:35arrdemplz
16:37hrathodhttps://github.com/john2x/repload
16:37FrozenlockTake a dictionary, loop through it and create a clojars project for each one of them... yes, I can see how my master plan would work.
16:37Frozenlock*evil laugh*
16:37weavejesterFrozenlock: I actually got burned by something like that. Had to name a project package “lein-gen” instead of “lein-generate” because in Clojars there’s a “lein-generate” that was written in 2010, and has since been abandoned (deleted repo, deleted github user, etc.)
16:38rasmustoorg.clojure.core2
16:38Frozenlockperhaps a year prefix could be the best of both worlds :-/
16:40Frozenlockweavejester: and contrary to domain names, this one is forever lost :'-(
16:41weavejesterFrozenlock: Yeah. I toyed around with the idea of asking to see if it could be removed, since it was only downloaded 4 times, but that kinda sets a bad precedent.
16:42weavejesterI kinda think those people who use their domain names in their package names might have a point… :)
16:44arrdem$seen gtrak
16:44lazybotgtrak was last seen quitting 1 hour and 49 minutes ago.
16:45arrdemweavejester: yeah. my stuff is all me.arrdem/*
16:46technomancydomain names are great for common nouns
16:46arrdembecause I know _I_'m a singleton, so my stuff is safely unique :D
16:46technomancybut common nouns are boring
16:46technomancyarrdem: good thing domain registrations are forever, right?
16:47arrdemtechnomancy: I mean.. my namecoins are registered into the next millennium so...
16:48weavejesterstuartsierra: Out of curiousity, is the reason for creating one’s own start/stop/reset functions in user.clj just a question of customisability?
16:48stuartsierraweavejester: yes
16:49stuartsierraYou need some way to hook in to application code to call a constructor.
16:49stuartsierraI've been thinking about making a generic version using com.stuartsierra/component.
16:50weavejesterstuartsierra: That’s what I was thinking of doing. Not only would it cut down on some boilerplate, but I think it would be better when namespaces fail to load
16:51stuartsierraweavejester: Yes. At least one other person has done this that I know of.
16:51weavejesterstuartsierra: i.e. you could still have a “reset” even if your own code failed to load.
16:51weavejesterstuartsierra: Oh, do you recall who it was?
16:51stuartsierraweavejester: No, it's buried in the comments on my original blog post on thinkrelevance.com
16:51weavejesterstuartsierra: I’ll take a look through it. Thanks for the pointer.
16:51stuartsierrayou're welcome
16:53weavejesterstuartsierra: Incidentally, have you found yourself needing to use “bridge” components at all? For example, I have a HTTP server component, and a component that handles websocket connections. To connect them I use a bridging component that just creates a handler with some static content, but doesn’t actually have state.
16:54stuartsierraweavejester: All the time. Sometimes I even just have an empty map with some dependency metadata.
16:54weavejesterstuartsierra: Oh good. It’s not just me, then!
16:55stuartsierraI'm not sure yet if I like it, design-wise, but it doesn't cause any problems that I can see.
16:56weavejesterIt feels a little off, design-wise, for me too. But I haven’t been able to come up with anything better that doesn’t add unnecessary complication.
16:58weavejesterstuartsierra: I was toying around with the idea of a “::provides” metadata value though
16:58weavejesterFor components that have a single useful value, like :handler
16:59stuartsierraI justify it (empty components) on the grounds that I am merely reifying a structure that was implicit in the code anyway.
16:59weavejester(component/using (component/bridge make-handler) [:app])
17:00stuartsierraI have also written components whose main job is to create and cache a value.
17:00stuartsierraI usually provide access to that value through a function.
17:01stuartsierraI hadn't thought about declaring that in the metadata.
17:01weavejesterstuartsierra: It sounds like it might be possible to write some functions around common patterns, in the same way system-map exists
17:02stuartsierraVery likely.
17:02weavejesterI’ll toy around with the concept and see if I can’t come up with something useful.
17:02stuartsierraI always want to try those things out in apps before codifying them in a shared library. That's how system-map came about.
17:03weavejesterstuartsierra: Yeah, same here. My feeling is that you need to be pretty sure a function is going to be useful before including it in a library.
17:04weavejesterBut I think in all the component-based stuff I’ve done, I wind up with an awful lot of components who are depended upon for a single value.
17:04weavejestere.g. databases for their connections. apps for their handler functions. etc.
17:05weavejester^{::provides :handler} (new-hander-provider …), ^{{:provides :conn} (new-database …)
17:05stuartsierraYes, I've seen both types as well: "connection" objects and pre-compiled functions.
17:05weavejesterMaybe. I’m not sure :)
17:05stuartsierraWhat would you do with that metadata?
17:07weavejesterstuartsierra: Use it when handling the dependencies, so instead of passing the whole component, we pass the value it wraps.
17:07stuartsierraOh, I see.
17:07stuartsierraHmmm.
17:08weavejester{:server (using server [:app]), :app (provides app :handler)}
17:08stuartsierraNot sure about that. Feels like it's exposing internal details.
17:08weavejesterstuartsierra: Yeah, I’m not sure either. I got halfway writing up an issue about it, then changed my mind.
17:09stuartsierraTry it out and see how it goes.
17:11stuartsierraI'd much rather have experience reports than issues or patches.
17:14weavejesterstuartsierra: We’re thinking along the same lines. I was going to try it out in my next project.
17:14stuartsierraweavejester: cool
17:18shiranaihitohttps://www.refheap.com/77439 -- how do inner maps get created there?
17:21dnolen_,(assoc nil :foo 'bar)
17:21clojurebot{:foo bar}
17:21dnolen_shiranaihito: ^
17:21bbloomdnolen_: i was literally typing that
17:21noonianme too lol
17:21bbloomwell, :x and 1
17:21noonian:foo and 17
17:22bbloomnoonian: dnolen_ likes the classics
17:22shiranaihitooh :p
17:22noonianyeah, i like using symbols as values also; i think that's something that people new to clojure don't usually understand off the bat
17:22shiranaihitokinky
17:23shiranaihitothat seems like weird behaviour though
17:24H4nshi. it's the simple things that make me struggle always: how do i get {1 2, 3 4} from [1 2 3 4]?
17:24noonian,(apply hash-map [1 2 3 4])
17:24clojurebot{1 2, 3 4}
17:24noonian,(doc hash-map)
17:24clojurebot"([] [& keyvals]); keyval => key val Returns a new hash map with supplied mappings. If any keys are equal, they are handled as if by repeated uses of assoc."
17:24H4nsnoonian: ah, thanks!
17:25nooniannp
17:27shiranaihito"(apply hash-map [1 2 3 4])" <-- damn, i actually wrote a helper method for that.. :p
17:28dnolen_,(into {} [1 2 3 4])
17:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
17:29dnolen_oops
17:29dnolen_,(into {} [[1 2] [3 4])
17:29clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
17:29dnolen_,(into {} [[1 2] [3 4]])
17:29clojurebot{1 2, 3 4}
17:29dnolen_erg, anyways, also ^ depending
17:32rasmusto,(into {} (partition 2 [1 2 3 4]))
17:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry>
17:32rasmusto,(into {} (map vec (partition 2 [1 2 3 4])))
17:32clojurebot{1 2, 3 4}
17:32rasmustoalternatively ##(into {} (mapv identity (partition 2 [1 2 3 4])))
17:32lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry
17:32rasmustohah, nvm
17:38TEttingerI think the apply hash-map solution is cleanest?
17:39tufti think apply hash-map fixes the concrete type, while into {} doesn't
17:39TEttingerI don't even know what a concrete type is in this context
17:39noonianwith into you have to massage the input vector a bit
17:40noonianhash-map vs array-map or tree-map i guess
17:40noonianbut i doubt the OP care's
17:41itrusloveCan anyone tell me what the "dev-resources" resource path is intended for?
17:41itruslovehttps://github.com/technomancy/leiningen/blob/7cc9d6163244fba1f0eedea43396b2a6a04528e9/leiningen-core/src/leiningen/core/project.clj#L424
17:41itrusloveIt sounds like it's a default resources directory for dev, but it's defined in the :base profile.
17:46vendethielMhhm, isn't `(fn [& [a b]] ())` the same as `(fn [a b] ())` ?
17:46vendethielOoh; I guess the first form makes them optional
17:47technomancyitruslove: the purpsoe is the same
17:47technomancyif it were in :dev, user-defined :dev profiles would override it
17:50itruslovetechnomancy: gotcha, thanks
17:51holohi
17:53holoI have a dilemma (revisited): to store or not to store generated.js and generated.css in git. the problem is, other collaborators may forget to run build after pull and not understand immediately their problem is they are running some outdated version of .js or .css
17:54holohow are you guys/girls doing this?
17:55dbaschholo: explain the required steps in your README file
17:56holodbasch, that's what I'm doing. my thinking was: humans are just unreliable
17:57rasmustohow about a makefile? :)
17:57rasmustoeh, probably just a blurb in a readme telling them to rerun everything is good
17:57rasmustoso long as they don't have to do anything manually
17:58blakeStyle/idiom question: Given data of keyed values {:k1 :v1 :k2 :v2} and a map of new names for keys {:k1 :l1 :k2 :l2} I want an output of {:l1 :v1 :l2 :v3}. I'm using:
17:58blake(zipmap (map val a-map) (map data (map key a-map)))
17:58nullptr`echo 'alert("Hey! You need to run lein something-or-other!");' >> generated.js
17:58lazybot'alert("Hey! You need to run lein something-or-other!");' >> generated.js
17:59blake((I get the desired results.)
17:59holorasmusto, that's the point, rerun already implies manual! or at least I think it does
18:00rasmustoholo: so they're just opening this stuff in a browser (without running any clojure tools)?
18:02dbaschblake: http://clojuredocs.org/clojure_core/1.2.0/clojure.set/rename-keys
18:03holorasmusto, they (one person only actually) are using lein. yeah ok, maybe I can drop also a msg in :init
18:04dbasch,(clojure.set/rename-keys {:k1 :v1 :k2 :v2} {:k1 :l1 :k2 :l2})
18:04clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
18:04holorasmusto, actually :repl-options {:welcome "bla"}
18:04rasmustoholo: cool, that should work well imo
18:04holowe are running the app under lein repl :)
18:05holorasmusto, thanks for the chat hehe :)
18:08blakedbasch: Thanks!
18:11blakedbasch: rename-keys ... cannot resolve symbol.... I need to include clojure.set?
18:12dbaschblake: yes
18:12blakedbasch, tx
18:22justin_smithvendethiel: also the first form allows providing extra ignored args
18:22vendethieljustin_smith: noted, thanks :)
18:24perseswhat is the wrong in this code, http://sprunge.us/bEjG , it doesn't work
18:27justin_smithperses: I get a stack overflow, try changing the self call in find-sqrt to recur
18:28justin_smithnever mind, that just changes the overflow into a seemingly infinite loop
18:29persesjustin_smith: can't i make a recursing in clojure?
18:29justin_smithit is not tail call optimized unless you use recur or trampoline
18:29justin_smithwithout the optimization, this code is running out of stack
18:29justin_smithbecause somewhere the guess is not getting improved where it should be
18:30persesi guess it should be a very basic for a fp to use recursing in this way
18:31justin_smithyou guess wrong, or maybe clojure isn't fp
18:32justin_smithor maybe it is easy but we don't do it anyway
18:32persesmaybe i'm wrong about clojure
18:32persesjustin_smith: recur don't terminate
18:32justin_smithright, like I said, I added a print statement, and your code keeps guessing 2.0 but not accepting that guess
18:32Bronsaperses: your good-enough? function is wrong
18:33amalloyperses: you may want an absolute-value in good-enough
18:33amalloyoh, and it should read (* guess guess), not (* guess n)
18:33amalloymaybe? i dunno. i'm bad at this. i resign
18:34Bronsaperses: http://sprunge.us/SMec?clj
18:40justin_smith(defn good-enough? [n guess] (<= (Math/abs (- n (square guess))) 0.1))
18:40justin_smiththat def fixes the code
18:41justin_smithalso, a good trick when something is recursing infinitely is add a println of the args and a (Thread/sleep 1000) to the top of the thing
18:41justin_smiththat often helps expose the problem
18:49technomancy$seen brehaut
18:49lazybotbrehaut was last seen quitting 2 weeks ago.
19:02FrozenlockDoes lein select JRE by default?
19:03justin_smithit should use your default java
19:03justin_smithI don't think the question of whether it is jre / jdk would come into play normally
19:03koreth_Is there an equivalent of mapcat that returns a set rather than a list? Obviously (apply hash-set (map f coll)) works, but if there are a lot of duplicate values that'll waste memory building the intermediate list.
19:03Frozenlockjustin_smith: Ah I see, so it's my fault :)
19:04FrozenlockYeah, but I want to use the jvisualvm
19:04koreth_Or maybe I should be using reduce rather than map.
19:04justin_smithFrozenlock: ahh, so you need the dt-socket to be open - but that should work across jvm versions anyway
19:05Frozenlockjustin_smith: I don't know... when I ran jvisualvm it just said that I needed to run the JDK, not the JRE
19:05justin_smithkoreth_: yeah, or use into #{} - that shouldn't hold onto the head
19:05justin_smithFrozenlock: oh, ok then
19:06justin_smith,(into #{} (map inc (range 10)))
19:06clojurebot#{7 1 4 6 3 ...}
19:06rasmusto##(into #{} (map inc (range 10)))
19:06lazybot⇒ #{1 2 3 4 5 6 7 8 9 10}
19:06rasmustojust checking hashing order, don't mind me
19:06justin_smithversions!
19:07amalloyrasmusto: /msg the bots, if you don't have a reason for everyone to read what you're writing
19:07justin_smith,*clojure-version* ##*clojure-version*
19:07clojurebot{:major 1, :minor 6, :incremental 0, :qualifier nil}
19:08justin_smithI guess lazybot has some anti-quine magic
19:09hyPiRionjustin_smith: yeah, sorry about that
19:09justin_smith:)
19:09amalloyjustin_smith: really it's a quirk of how ## parses - he reads the string that comes after ##, and if it's not a collection (usually a list, of course), he assumes you are talking about an irc channel like ##java or something
19:09justin_smithoh, OK
19:09justin_smith,*clojure-version* ##(do *clojure-version*)
19:09clojurebot{:major 1, :minor 6, :incremental 0, :qualifier nil}
19:09lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
19:09amalloylazybot giving an error message after every mention of ##java gets old fast
19:09justin_smithright
19:10rasmusto"##java gets old fast" -amalloy
19:10rasmusto:)
19:11dbaschkoreth_: you could do (distinct (map …)), distinct is lazy
19:11justin_smith(inc dbasch)
19:11lazybot⇒ 1
19:11justin_smithgreat idea
19:13hyPiRionrasmusto: keep in mind that the order is incidental
19:14seangrovebbloom: In :fixed vs :canvas (absolute), is the fixed positioning still relative to the parent or to the root view of the UI? I would expect the former. Luckily, CSS does the latter.
19:15hyPiRion,(apply = (map (comp seq set) [(range -10 11) (range 10 -11 -1)]))
19:15clojurebottrue
19:15seangroves/luckily/irritatingly
19:15rasmustohyPiRion: ah, I knew that. Was just curious of how the new hash algo ordered integers
19:15hyPiRionalright
19:16bbloomseangrove: i don't recall
19:16justin_smith##(apply = (map (comp seq set) [(range -10 11) (range 10 -11 -1)]))
19:16lazybot⇒ false
19:16hyPiRionHrm, didn't know there were hashing changes from 1.4.0 to 1.5.0
19:16justin_smithnot that any of us should be using 1.4 at this point
19:16justin_smith1.6.0
19:16amalloyhyPiRion: there were some in 1.6, not 1.5
19:17amalloyafaik there weren't in 1.5, anyway
19:17hyPiRionamalloy: (apply = (mapv (comp seq set) [(range -10 11) (range 10 -11 -1)])) returns false on 1.5.1
19:17amalloyokay, and also in 1.4. so, both of those are different from 1.6, which supports my claim?
19:18hyPiRionoh, I mixed clojurebot and lazybot versions
19:24Frozenlockuh... what is this... I just changed my path, only to realize that the java in the /bin folder is a link to the JRE bin o_O
19:24Frozenlock(trying to get the JDK)
19:25justin_smithyou can just replace the symlink to the JRE with a symlink to the JDK, no?
19:25hyPiRionFrozenlock: which OS are you using?
19:25Frozenlockthat's the thing, where I was expecting the JDK java, I found a link to the JRE binary
19:25FrozenlockUbuntu
19:25justin_smithon a debian based system you would use update-alternatives, and it would bea symlink to a symlink
19:25justin_smithFrozenlock: use update-alternatives
19:26hyPiRionFrozenlock: `sudo update-alternatives --config java`
19:26justin_smithhttps://help.ubuntu.com/community/Java
19:26justin_smithabove link also covers manually installed java, so you can make sure it is visible to the alternatives system
19:26amalloyupdate-alternatives mystifies me. i don't know when i'm supposed to use it or how
19:26FrozenlockhyPiRion: That's what I used first, but I only saw JRE choices
19:27hyPiRionFrozenlock: did you install through apt-get/aptitude?
19:27FrozenlockI honestly don't remember. I might just reinstall everything
19:28amalloyFrozenlock: bathe your computer in acid to make sure the reinstall is complete
19:28justin_smithamalloy: picking defaults - it is done using a system of symlinks; you can manually replace the symlink with one pointing to a different target file, or use their weird semi-interactive CLI
19:28Frozenlockhttps://www.refheap.com/77448 <---- only JRE choices o_O
19:28justin_smithFrozenlock: you will know it was not installed via apt if it is not presented as an available alternative, my link above shows how to make it one
19:29justin_smithFrozenlock: OK, so use the instructions on my link above under "Oracle Java 7"
19:29justin_smithor just fuck it and replace /usr/bin/java with the symlink or binary of your choice
19:29amalloyFrozenlock: that's fine. my java bin lives in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
19:30hyPiRionFrozenlock: yeah, that's the JDK version. Try out `java -version` and see for yourself
19:30FrozenlockOpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
19:30FrozenlockOpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
19:30Frozenlock
19:30Frozenlockarggg
19:31rasmustokill -9gauge
19:31justin_smithFrozenlock: just tell the alternatives system that the jdk is the right default
19:31justin_smithhah
19:31justin_smithsometimes I miss xblast
19:32seancorfield(inc rasmusto)
19:32lazybot⇒ 8
19:32seancorfieldThat made me laugh out loud!
19:32rasmustoglad I could help :)
19:33technomancyupdate-alternatives is like if you took rvm and made it not suck and work for anything
19:36Frozenlockdoes JDK use a different name than java? (like I said, 'java' in the JDK is a link to the JRE java)
19:38amalloyi'm pretty sure the thing in .../jdk/jre/bin/java is what you want to use
19:39justin_smithFrozenlock: wait, the one inside the jdk folder is a symlink to the jre one?
19:39Frozenlockamalloy: I always used it without any problems. But I want to try jvisualvm and it insists on telling me that I'm using the JRE instead of the JDK.
19:39Frozenlockjustin_smith: looks like it
19:40amalloyFrozenlock: no, that's just how the jdk is distributed
19:40amalloymine looks that way too
19:40amalloywhen you download a jdk, it comes with a jre
19:40amalloyand that's the same java
19:40amalloyit's not like it has a different java executable based on whether you want to pretend you're not using a jdk
19:43justin_smithFrozenlock: it could be the jvisualvm is reporting the wrong error, and you are calling a jvisualvm that is incompatible with the specific jvm?
19:44Frozenlockmaybe
19:44FrozenlockI'm looking for vjisualvm similar problems
19:44justin_smiththere should be a version of visualvm inside the jdk file heirarchy - maybe that is not the same one you are invoking?
19:47Frozenlockeh, it works if I launch with --jdkhome <my-JDK-path>. GOOD ENOUGH
19:47blakeIf I want "(defn my-func [parm1 parm2 parm3=nil] ..." such that parm3 is either passed in by the user or is nil, do I have to do a multi-arity setup?
19:48amalloyblake: you want to support multiple arities (2 or 3), so...
19:49justin_smithit is doable with (fn [parm1 parm2 & [parm3]] ...) which is also multi-arity, but in a different way
19:49blakeamalloy: Just checkin'. It's not like there's only way to do stuff.
19:49blakejustin_smith: Yeah, but doesn't that have other implications?
19:49justin_smithalso means it will take and ignore any further arguments
19:50blake...because the remainder of the arguments are passed in a vector and I'm only taking the first element of any vector?
19:50justin_smithbut is more concise than the explicit (fn ([p1 p2] ... ) ([p1 p2 p3] ...)) version
19:50justin_smithblake: exactly
19:51blakejustin_smith: That makes me nervous because I'm still getting parens wrong enough to where the arity check probably helps me from tearing my hair out (as if I had hair).
19:52blakeI guess it seems goofy to have a fn[parm1 parm2 parm3] followed by fn[parm1 parm2]=>(fn parm1 parm2 nil).
19:52justin_smithfair enough, then use the more verbose, more strict version
19:53justin_smithor add an explicit check (fn [a b c & [d :as rest]] (assert (< (count rest) 2))) but that seems a little silly
19:53blakeHeh. Yeah.
19:53amalloyjustin_smith: btw, you should really avoid doing comparisons on the result of count. you never know when infinite sequences will crop up
19:54blakeooh
19:54amalloy(< (count x) 2) => (not (next x))
19:54justin_smithamalloy: even in a rest arg ? I guess if someone called apply on something infinite?
19:54amalloyfor sure
19:55amalloyyou can (apply f (range)), no problem
19:55justin_smithoh, of course
20:21coventryblake: If you're getting parens wrong a lot of the time, it's probably worth taking half and hour or so to learn paredit mode, or whatever the equivalent is in your browser.
20:21amalloycoventry: such a badass he turns paredit on in his browser
20:21coventrys/browser/editor/. :-) Thanks.
20:25dbaschcoventry: I’d say it’s worth it regardless. Nobody should be spending cognitive power balancing expressions.
20:27coventryAnyway, kovasb's session has paredit https://github.com/kovasb/session#paredit
20:35dsrxcoventry: holy cow that is really cool. stepped away from clj/cljs for a few weeks and this comes out O_O
20:42bbloomcoventry: i enjoy the namespace name for his paredit functionality
20:42bbloomit's in subpar/core.cljs :-)
20:45coventryHeh.
20:46bbloom$mail kovasb Hey man, you're paredit functionality is really *ahem* subpar.
20:46lazybotMessage saved.
20:46bbloomd'oh i suck at spelling
20:47amalloybbloom: you can $unmail kovasb, if you don't want him to know your a bad speller
20:47bbloom$unmail kovasb
20:47lazybotDeleted unread messages from bbloom to kovasb
20:47bbloom$mail kovasb Hey man, your paredit functionality is really *ahem* subpar.
20:47lazybotMessage saved.
20:48bbloomamalloy: spared me having to write a bad follow up self-deprecating joke
20:48amalloybbloom: i just wanted an excuse to use the wrong your in my response
20:48bbloomamalloy: haha i didn't even notice
20:49bbloomamalloy: this is my biggest debugging weakness. i'm so used to reading/writing error-filled nonsense on the internet... my eyeballs have built in auto correct
21:11eraserhdAnyone want to converse to try and find an elegant solution to a monad-like kind of problem?
21:12eraserhdThe problem is this: I want to find a way to thread functions that deal with two values. 1st is the "state", which should thread much like -> threads through composable functions.
21:13eraserhdBut the second is a list of "effects", which I want to hide most of the time.
21:19weavejestereraserhd: A list of effects? Effects on the state, or something else?
21:20eraserhdEffects are tokens that represent side-effectful things to be performed.
21:21eraserhdExamples: [:beep], [:write-file "/tmp/foo.txt" "hello"], ...
21:21eraserhdThe idea is to make a composable way to collect these.
21:22weavejesterThat’s an interesting problem, and as you point out, very close to the state monad.
21:26weavejestereraserhd: I don’t have an immediate answer for you, unless you want to try one of the monad libraries
21:40zspenceris there something similar to apply but doesn't take a collection?
21:41zspencerI've got a map of keywords to functions and I want to execute the returned function inside of a threading operator
21:41zspencer(making an example)
21:42eraserhdzspencer: apply, but make the last argument []
21:43eraserhdOh, you can't just ((:foo map)) in the threading operator?
21:44zspencerhttps://gist.github.com/zspencer/4d378e1d1d833041ccd5
21:44zspenceryeah, the last argument right now is a vector :(
21:44zspencerThe larger context: https://github.com/zspencer/clj-warrior/blob/master/src/play.clj
21:44zspenceralso, hi jason :)
21:45alewyou could define (defn invoke [f & args] (apply f args))
21:45zspencerALL MY FRIENDS ARE IN THE CLOJRUE CHANNEL
21:45eraserhdzspencer: We've been here for years. Glad you gave up ruby.
21:45zspenceralew: that's a reasonable thing; I just figured clojure would have something built in
21:46zspenceri.e in javascript func.call(context, foo, bar) vs func.apply(context, [foo, bar])
21:46eraserhdThe form you're looking for is really just (func foo bar) in clojure, it's the threading macro that's screwing you up.
21:47eraserhdIMHO
21:47zspencerYea, I switched to the threading operator beacause it seemed clearer
21:48zspencerbut maybe I should consider composition for the steps
21:48zspenceri.e. "take the players turn, then the ais turn"
21:48zspencerAll my code is bad and I feel bad
22:00eraserhdzspencer :/
22:08hlprmnkyzspencer: the best piece of advice I’ve gotten so far about the threading operator is this, from a code review I was fortunate enough to have Hugo Duncan do of some bad code I’d written - he said, and I paraphrase: What I usually do is get everything working the way I want first, and then go through and look to add threading in a second pass, to make things concise
22:22TravisDDoes anyone know of any libraries that allow you to manage your own random number generator, etc?
22:23zspencerhlprmnky: that's a reasonable thing.
22:37bob2TravisD, as in with a specific seed? http://docs.oracle.com/javase/7/docs/api/java/util/Random.html
22:38TravisDbob2: Ah, yeah, I keep forgetting that all of java is available
22:43TravisDI was also hoping to have some choice of the method used
22:44TravisDand for some snazzy clojure interface :)
22:44zspencerhlprmnky / eraserhd here's what I wound up with: https://github.com/zspencer/clj-warrior/blob/master/src/play.clj#L60
22:56coventryIs there any test.check code out there already for producing a lot of random deeply nested structures. Ideally with lots of structural sharing, but I can probably add that in myself.
23:25owl-v-how do i add v elements to vv one by one? (let [v [1 2 3]] (let [vv []] (map #(conj vv %) v)))
23:26amalloyowl-v-: you can't do that with map, because clojure data structures are immutable. instead, you would use reduce, something that builds up a single result from multiple input items
23:27amalloyor in the specific case of conj, you can just use into: (into [] v) yields a vector containing all the items in v
23:30bodie_hi all, not sure if I'm doing something stupid or what -- do I need to be mindful of using hyphens in namespaces / in paths in my project tree with lein?
23:30bodie_I keep getting a not found error
23:31koreth_What's the best way to do the equivalent of "rest" on a sorted set without losing the sortedness? (rest (sorted-set 0 1 2)) returns a plain old sequence.
23:31koreth_,(rest (sorted-set 0 1 2))
23:31amalloyyes. namespaces want -, and the path needs _ instead
23:31clojurebot(1 2)
23:31koreth_,(sorted-set 1 2)
23:31clojurebot#{1 2}
23:31amalloydisj
23:32koreth_Thanks
23:32bodie_http://paste.ubuntu.com/7280810/
23:32bodie_I see
23:32bodie_so, use _ in the path?
23:49amalloyyes, bodie_