#clojure logs

2013-03-02

00:00TimMcI thought perhaps I had put a board in the wrong place somewhere.
00:20tyler_anyone know if you can call functions from clostache?
00:20tyler_in the view
00:20tyler_ah you can call lambas nice
00:21tyler_n/m
00:21tyler_found it
00:29FrozenlockIs there a way to unquote-splice inside a for? (for [x some-list] (or x [1 2 3])) ----> (x x x 1 2 3 x x)
00:30tomojI think I usually (apply concat (for [x some-list] (if x [x] [1 2 3]))) :(
00:30tomojhmm
00:30tomoj(for [x some-list y (if x [x] [1 2 3])] y) ?
00:31Frozenlocko_O
00:31FrozenlockNever used `for' with more than a coll.
00:33FrozenlockLooks like it could work, thanks :)
00:56lekuhow do I work with .jar files and clojure?
00:56lekuI'd like to be able to play around with this API and teach myself a little clojure at the same time
00:56leku(require '(USGS jar [set :as u]))
00:56lekunot working
00:58lekua stackoverflow page suggests putting it int he lib folder
00:59lekui created a new project with lein but there is no lib dir
01:07tomojwhich stackoverflow page?
01:07tomojleku: https://github.com/technomancy/leiningen/wiki/Repeatability
01:07tomojlib/ doesn't exist anymore in lein 2
01:08lekuah
01:08lekuahh
01:08lekui see what they did here
01:08tomojif the jar isn't in a maven repo you can access already, you'll have to either put it in one or use lein-localrepo or whatever
01:08lekurgr
01:33yediis clj-stripe the only stripe wrapper lib?
01:39xeqiyedi: I've been using clj-http to hit the api directly for a recent project
01:40xeqithose were the two choices I found
01:40yeditheres no wrapper over javas native library?
01:47xeqiyou could just inerop with it, but I didn't find it very nice when I tried
01:47xeqi*interop
02:19Frozenlock"Cannot recur from catch/finally" Damn
03:06DeeceI'm a bit confused by function literal syntax. I would have thought that #(%) was equivalent to (fn [x] x), but it's equivalent to (fn [x] (x)). maybe I'm crazy, but this seems odd?
03:12noidiDeece, it's very rare for an anonymous function to not call another function, so mostly you'd end up with double parens #((...))
03:18lekuhow do I connect my emacs to the repl?
03:18lekuso that when I save I can run new functions in the lein repl?
03:23noidileku, maybe this guide could help? http://clojure-doc.org/articles/tutorials/emacs.html
03:25lekuthx
03:39lekuperfect noidi
03:39lekuthank you
03:50babilenJust seen that maps (in addition to vectors) are now mentioned as being used with fork/join -- Does that also mean that reducing into maps is fast(er) now?
03:50babilen(yeah, you guessed correctly this is about the reducers library)
04:00fsvehlaCan the reducers library work with a line-seq as a input? Order doesn’t matter for the fold, and the source should be able to be read much faster than all the following steps
04:02tomojyou can r/reduce over any seq, but you can't r/fold
04:03tomojyou would have to create your own IO folder
04:03tomojwell
04:03tomojif you just slurp the line-seq into something foldable, you can fold that...
04:08tomojhmm, it seems you could define a partition folder over seqs?
04:13tomojbut it wouldn't be fork/join suitable?
04:26lekuhow do I switch namespaces?
04:26lekuin my nREPL
04:27lekujust (ns foo) ?
04:28borkdudeleku (in-ns 'foo)
04:29borkdudeleku from the docs I see it has the same effect if the namespace already exists
04:30borkdudeleku in-ns is more low level
04:30leku(ns foo) seemed to work
04:30lekuthis emacs tutorial says to do C-c C-n
04:30lekucan't seem to get that to work
04:30borkdudehmm, interesting (macroexpand '(ns foo))
04:30borkdudeleku ns also refers clojure.core for you etc
04:31lekucool
04:31RaynesI've never used in-ns in my live.
04:31Raynesleku: C-c M-n
04:33lekuahH!!
04:33lekuthat works thanks
04:33Rayneslife*
04:33RaynesNo probs.
04:37leku(macroexpand) is good
04:40Raynesmacroexpand is much better than bed.
04:44lekuhttps://github.com/relevance/clojure-conj/wiki/Clojure-conj-2012-Unsessions
04:44lekuwtf? clojure powered robots??
04:44lazybotleku: Definitely not.
04:44lekuwhen the first bot writes his own REPL, does that mean Skynet has come ONLINE?
04:44Ember-lazybot: you are wrong :)
04:44borkdudeleku most of us are robots
05:38augustlhmm, intellij and la clojure will get weird syntax error warnings when I use "#db/id[:db.part/user -100]" which is perfectly legal Clojure code
05:50lekuhm my compiler is complaining that clj-http.client is missing, yet I have it in my project.clj and lein deps is up to date
05:58lekuhow do I say if something exists, use that, otherwise use this?
06:00Bodilleku: (or something this)
06:01Bodilleku: Assuming that by "exists" you mean truthy.
06:01lekuhm
06:01augustlleku: (get my-map :key default-value-here) if you mean a map
06:01lekuwell if arguments were passed to main I was gonna use that, otherwise use a default
06:01augustlI'd use or for that
06:02leku(defn -main [& args] (get-data (or (args) ("http://foo.com"))..
06:02BodilYes, missing arguments to main would be nil, so or is the way to go.
06:02lekuk
06:02lekuthx
06:02Bodilleku: (or args "http://foo.com")
06:02Bodilleku: Otherwise you're trying to call args as a function...
06:02augustlleku: that's too many parenthesis :)
06:02lekuah ok
06:02augustland you want (first args)
06:02lekuah indeed
06:04borkdude,(clojure.xml/parse "http://www.w3schools.com/xml/note.xml")
06:04clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.xml>
06:05borkdude,*e
06:05clojurebot#<Unbound Unbound: #'clojure.core/*e>
06:18mpfundsteinhello can someone help me with this? http://ideone.com/gmqWz7
06:18mpfundsteinmy question is that if i have a if-let statement
06:18mpfundsteinhow can i do two things afters
06:19mpfundstein(if-let [name (first waiting-line)]
06:19mpfundstein1. print name
06:19mpfundstein2. do something else with name
06:20raekmpfundstein: you can use 'do' to perform multiple actions in sequence
06:20mpfundsteinis it like ->> ?
06:20raekno, it doesn't thread any value through the expressions
06:21mpfundsteinthx
06:21mpfundsteindo what was i was searching for
06:21raekit takes a bunch of expression, evaluates them left ro right, and then returns the result of the last one
06:21borkdudedo is usually needed when side effects have to occur before returning a value
06:21mpfundsteinborkdude: yeah, in my case just a println
06:22mpfundsteinis there a function like slice( ) in javascript ?
06:22mpfundsteinwhere i can slice a list/vector
06:22borkdudempfundstein example input output?
06:22mpfundstein'("Markus", "Nina", "Anna")
06:22mpfundsteini want a new list
06:22mpfundsteinwith
06:22raekmpfundstein: in this case you should also use 'recur' instead of the 'process-next' after the println
06:22mpfundsteinonly ("Nina", "Anna")
06:22Bodilmpfundstein: You'd use drop for that.
06:23borkdude,(rest '("Markus", "Nina", "Anna"))
06:23clojurebot("Nina" "Anna")
06:23raekmpfundstein: 'rest' or 'next'
06:23mpfundsteinAh
06:23mpfundsteinok let me test
06:23borkdudempfundstein in the context of recursion it is better to use next
06:24raekmpfundstein: if you don't use recur you will overflow the stack if you process long lists
06:24borkdudempfundstein because it returns nil on empty collections
06:24borkdude,(rest [])
06:24clojurebot()
06:24borkdude,(next [])
06:24clojurebotnil
06:24mpfundsteinok
06:24mpfundsteinso recur will call the current function again
06:24raekyes
06:24mpfundsteinbut reuse the stack ?
06:24raekexactly
06:24mpfundsteinah thats nice
06:24mpfundsteinthanks
06:24mpfundstein(first hour in clojure)
06:25borkdudempfundstein most of the time you can avoid recursion altogether by using higher order functions
06:25raeknot bad for just one hour...
06:25mpfundsteinrecur symbol not found
06:25mpfundsteinah lol sorry
06:25mpfundsteinforgot (
06:26mpfundsteinah awesome
06:26mpfundsteinhehehe
06:26mpfundsteinit works
06:26mpfundsteinbut one question
06:27mpfundsteinthis works perfect: http://ideone.com/X01WZV
06:28borkdude,(doseq [name '("dude" "bar" "foo")] (println name " is next"))
06:28clojurebotdude is next\nbar is next\nfoo is next\n
06:28mpfundsteinah question solved
06:28mpfundsteinborkdude: hihi :-) yeah
06:28mpfundsteinborkdude: i try to understand the language so i am building stupid test cases for myself
06:29borkdudempfundstein no problem, doing good for just one hour :)
06:29mpfundstein(probably 2 already ;-) )
06:29mpfundsteini had yesterday the vision that i must learn a lisp like language now :D
06:30raekmpfundstein: in your code you are not really testing for the empty list, you are testing if the first thing in the list is nil
06:31raekof course an empty list does not have a first element, but clojure returns nil in that case
06:31mpfundsteinraek: mh yeah, because it pops anway the first element each time
06:31mpfundsteinraek: how would you write it?
06:31raekanyway, your function will stop on the first nil in the list
06:31mpfundsteinlet-if (= 0 (count waiting-list))
06:31raekmpfundstein: like this: https://www.refheap.com/paste/11997
06:31mpfundstein> 0 i mean
06:32borkdudeor use next and test for argument = nil
06:32mpfundsteinwhy if and not let-if
06:32raeksorry, that doesn't work
06:33mpfundsteinno
06:33mpfundsteinname is not defined than
06:34mpfundsteini could do
06:34raekmpfundstein: https://www.refheap.com/paste/11998
06:34mpfundsteinyes precisible
06:34mpfundsteincan one negate a if?
06:34mpfundstein(if (!emtpy?
06:34mpfundsteinif-not probably :-)
06:34raekyeah
06:35raekbut (empty? x) = (not (seq x))
06:35raekso (if (seq x) ... ...)
06:35raekor (when (seq x) ...)
06:35mpfundsteinthanks
06:35mpfundsteinwhen doenst have else
06:35mpfundstein?
06:35mpfundsteinok i go on with my stuff now :D too much n00bie questions popping up :-)
06:36raekyeah, (when c a b c) = (if c (do a b c) nil)
06:36mpfundsteinthanks raek and borkdude
06:36mpfundsteinkkk
06:36raekthough (if c a) = (if c a nil)
06:36borkdudempfundstein https://www.refheap.com/paste/11999
06:37borkdudempfundstein the surrounding do can be ommitted
06:37maxalwingsWhat is the best CSS DSL built in Clojure?
06:37rcgwhat's "more idiomatic": "(contains? #{:foo :bar} :foo)" or "(#{:foo :bar} :foo)"?
06:37mpfundsteinok ok
06:37borkdudeso: https://www.refheap.com/paste/12000
06:37mpfundsteinno it gets a bit tricky
06:38rcgwhen used, e.g., in a cond, both work.. but what's the preferred way to do it?
06:39borkdudercg (if (#{:foo :bar} :foo) :yeah :no) is a pretty common pattern I think
06:41rcgborkdude, i see, thx
06:41borkdudercg beware of this though: (if (#{nil :foo} nil) :yeah :no)
06:42rcgborkdude, sure :)
06:50borkdudeI wonder where I can find the definition of nil as a value
06:54borkdudeprobably this thing? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L1873
07:00borkdudehmm, clojure.lang.Compiler/NIL_EXPR => Unable to find static field: NIL_EXPR in class clojure.lang.Compiler
07:02raekborkdude: clojure nil (the value) is JVM "null". I guess you'd need to look in the JVM spec?
07:02borkduderaek is null a value in the JVM?
07:02raekyes
07:02raekit is a value that all reference types contain
07:03borkduderaek can I add null to a set in java?
07:04raekaconst_null in http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
07:04raekborkdude: you can certainly pass null to Set.add()
07:05raeksome implementations might not allow null as an element, though
07:05raekah, from the javadocs for java.util.HashSet: "This class permits the null element."
07:07raek(doto (java.util.HashSet.) (.add nil) (.add 123))
07:07raek#<HashSet [null, 123]>
07:09borkdudeah
07:13raekborkdude: I think NilExpr is the abstract syntax tree node for a nil literal (so not the runtime value)
07:58stevenyihi all, question: is System/arraycopy supposed to be unusable? I get: CompilerException java.lang.NoSuchFieldException:
08:02Ember-why would you want to use it?
08:02Ember-are you receiving arrays from java code?
08:03borkdude,(System/arraycopy (to-array [1 2 3]) 0 (to-array [0 0 0]) 0 3)
08:03clojurebotnil
08:03stevenyii'm working on some code where performance is important and i need to minimize object allocation; i'm clearing an array by using an empty array to copy
08:04stevenyiborkdude : thanks, i see that i flubbed the args
08:04stevenyilooks to compile fine now
08:06stevenyiodd though that (System/arraycopy) in repo showed the error, i'm still learning clojure so am making easy mistakes still :P
08:06stevenyirepl
08:18borkdudeis there a reader macro for java arrays?
08:19borkdudemaybe someone has made a reader thingy for this?
08:20tomojthere's a base64 somewher
08:20tomojdatomic.codec/base-64-literal
08:20tomojfor bytes
08:21tomojit wouldn't make a whole lot of sense to me to have a tag for java arrays in particular
08:21corecodeis there a way to get useful callgraph profiles for jvm/clojure code? i'm just starting with clojure and am a bit lost
08:23borkdudecorecode that would be nice to have
08:26borkdudecorecode actually it would be a cool idea to have a leiningen plugin or smth that generates a kind of sequence diagram by running a clojure program
08:28corecodewell, just something :/
08:29corecodealso i seem to have a lot of reflection going on
08:29corecodebut i don't know where
08:29borkdudecorecode did you set *warn-on-reflection* to true?
08:30borkdude (set! *warn-on-reflection* true)
08:30borkdude(defn foo [o] (.someMethod o)) ;;=> warning
08:30corecodeyes
08:30corecodenot sure why i don't get many reflection warnings
08:32corecodebut from what i see visualvm showed a lot of reflection going on
08:33corecodeah i think i'm profiling the wrong thing :/
08:33corecodetrying to make sense of hadoop and cascalog
08:33tomojthere is interesting looking stuff in ritz
08:33tomojbut I don't immediately see how to use it
08:35mpfundsteinis there a meaning behind
08:35mpfundsteindef -function-with-a-minus
08:35mpfundstein?
08:35mpfundsteindefn sry
08:45borkdudempfundstein defn- defines private functions
08:46borkdudempfundstein ie the metadata of the function has ^:private true
08:46mpfundsteinborkdude: ok and ^ refers to the function itself?
08:46borkdudempfundstein (defn- foo [] nil)
08:46borkdude(meta #'foo) ;;=> {:arglists ([]), :ns #<Namespace user>, :name foo, :column 1, :private true, :line 1, :file "NO_SOURCE_PATH"}
08:47mpfundsteinoh wow this is awesome didnt now the meta call
08:47mpfundsteinlike ruby cool
08:47borkdudempfundstein ^: is a shorthand notation
08:47mpfundsteinborkdude: (def ^:dynamic v 1) ; v is a global binding
08:47borkdudeyes
08:47mpfundsteinborkdude: what is here different than (def v 1)
08:47mpfundstein?
08:48borkdudempfundstein dynamics can be rebound with binding
08:48mpfundsteinaaah
08:48mpfundsteinyeah the author shows that letter , but he doesnt explain the ^:dynamic
08:48borkdudempfundstein it's called dynamic scoping
08:49mpfundsteinaah ok i get it now
08:49mpfundsteinsuper thanks
08:49mpfundsteinand the 0
08:49mpfundsteinsry -
08:49mpfundsteinmeans that if i include my clj file somewhere else than i cant call the function
08:49mpfundsteinthats probably what private means in a non oop language :-)
08:52borkdude,(let [s (java.io.StringWriter.)] (binding [*out* s] (println "foo") (str s)))
08:52clojurebot"foo\n"
08:52borkdudempfundstein yes
08:52borkdudempfundstein you cannot refer to it from another namespace (but with some trickery you can)
08:53borkdudempfundstein it's more to signal that it's an implementation detail you should probably not rely on
08:53mpfundsteinok
08:53mpfundsteinthanks
09:09Ember-hmm, I have a nested structure of maps and lists, I want to find a path to a specific part of that structure based on a value of a specific key in one of those maps (id)
09:09Ember-I'm guessing I should use the walk api, but not quite sure how
09:10borkdudeEmber- get-in doesn't suffice?
09:10Ember-no, I don't know the sequence of keys yet
09:10Ember-that's the problem
09:10Ember-so I need to first find those, then use update-in or get-in
09:10borkdudeEmber- maybe a zipper or smth? http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/
09:11Ember-will check, thanks
09:19mindbender1Raynes: how are you depending on clojurescript?
09:22mindbender1clojurescript seem to lack a concrete way of obtaining it
09:23mindbender1Am I being forced to bundle a jar for myself?
09:30mindbender1(use '[cemerick.pomegranate :only (add-dependencies)])
09:31Ember-borkdude: read that, nice information but not quite what I need. As far as I understood, zippers need the same data structure all the way
09:31Ember-for example seq-zip doesn't understand maps
09:31Ember-guess I'll look more into the walk api
09:32borkdudeEmber- ok, yes, that's why I said "or smth" ;)
09:33Ember-:)
09:33Ember-but I learned something new with that article, so thanks :)
09:35borkdudeEmber- I'm curious about your problem and solution since with walk, can you know what the path was for the visited element?
09:36Ember-yeah, I'm starting to lean on the fact that I need to do this myself recursively
09:36Ember-which seems kinda suprising, I would have guessed this is a common enough problem to be covered in core api
09:37borkdudeEmber- more zipper examples here http://www.ibm.com/developerworks/library/j-treevisit/index.html
09:37borkdudeEmber- first some walk examples, then some tree visiting examples with zipper
09:38Ember-something like (find-path #(= (:id %) 123) structure) -> [:foo :bar 3]
09:38borkdudeEmber- I think that has to be find-paths, because there could be multiple, if not all nodes are unique
09:38Ember-would traverse the structure, check each element with the predicate and after finding an element which matches the predicate returns a sequence of keys
09:38borkdudeEmber- I think you can do that with zippers
09:39Ember-and yes, you can have multiple paths and hits in that
09:39Ember-but was a simplified example
09:39Ember-s/find-path/find-first-path
09:39Ember-;P
09:40Ember-in my case anyway there would be only one valid path since in my data structure :id is unique
09:41borkdudeEmber- zee zip/next
09:41Ember-hmm
09:41Ember-I wonder what that documentation really means :)
09:41Ember-will have to try
09:44borkdudeEmber- see here http://www.ibm.com/developerworks/library/j-treevisit/index.html at listing 13 for example
09:44Ember-I wonder what kind of zipper I should create, seq-zip just doesn't work like it should in this case
09:45borkdudeEmber- yes, I'm also struggling with that. I think it either assumed nested vectors or nested seqs?
09:45Ember-well, I have both maps and vectors/lists
09:46Ember-like: {:id 1 :something "foo" :children []}
09:46Ember-a single element
09:46Ember-you can have a list of those and inside :children a list of those and so on
09:47Ember-and each element has a unique id and I need to find a path to that element so I get a proper sequence of keys to pass to update-in
09:47borkdudeEmber- is it like xml?
09:47Ember-kinda yes
09:47borkdudeEmber- there's also xml-zip
09:47Ember-yeah, I looked at that
09:47Ember-it expects results from xml/parse
09:47Ember-but hell, let's try :)
09:48Ember-well, that's kinda sad
09:48borkdudeEmber- maybe worth reading http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html
09:48Ember-doesn't work :/
09:48Ember-each zip traversal function returns just nil
09:49Ember-with xml-zip
09:49Ember-seq-zip works as long as I'm within lists
09:49Ember-but it can't handle maps
09:50borkdudeEmber- so you need kind of hiccup format to clojure.xml/parse output format?
09:50Ember-hmm, not sure I'm following you with that
09:50Ember-like I said, all I need is a way to get that path
09:51Ember-I could easily do that with recursion and specific functions written for that purpose
09:51Ember-but I'm having a feeling there *has* to be a more generic way to do this (zippers look promising)
09:51borkdudeEmber- the difference between hiccup format and clojure.xml/parse is described here https://github.com/davidsantiago/hickory
09:52borkdudeEmber- xml-zip expects the parse format, not hiccup
09:52borkdudeEmber- ah look! hickory contains hiccup-zip
09:53Ember-so, it just takes a bunch of maps and vectors
09:53Ember-and creates a zipper for those
09:53Ember-sounds promising
09:54borkdudeEmber- yes, and then you could do a recursive call with zip/next, check the content, if it is ok, return the path into the node, else continue with the next zip/next
09:54borkdudeEmber- check for the end with zip/end?
09:54Ember-zip/next does that already I think?
09:55Ember-ah no
09:55Ember-it *returns* stuff which can be recognized with it
09:55Ember-sounds promising
09:55Ember-guess I'll try that out
09:55Ember-thanks man
09:56Ember-just a teeny bit suprised that zipper is not in the core
09:56Ember-seems to me having a bunch of maps and lists is a really common scenario
09:59borkdudeEmber- (loop [data (zip/seq-zip '(1 2 3))] (if (zip/end? data) "end" (do (println (zip/next data)) (recur (zip/next data)))))
10:02Ember-hmm... I must be using the hickory hicckup-zip wrong
10:02Ember-since zip/next with it reaches immediately the end
10:04borkdudeI don't know why this returns [[1 2 3]] (loop [data (zip/vector-zip '[1 2 3])] (cond (zip/end? data) "end" (= (zip/node data) 3) (zip/path data) :else (recur (zip/next data))))
10:04Ember-those zippers are a bit confusing I got to say :)
10:05borkdudeEmber- maybe it means that it first visited the nodes 1 2 and then 3?
10:06borkdudeno
10:08Ember-(let [test-data [{:id "root", :children [{:id "sub-1", :children [{:id "sub-1-1", :children []}]}]}]] (-> (hick/hiccup-zip test-data) zip/next zip/end?))
10:08Ember-true
10:08Ember-where hick is hickory
10:08corecodeis there a faster way than using (union set1 set2)?
10:09borkdudeEmber- in Clojure Programming, if you have that book, there is a html zipper on page 153
10:09Ember-unfortunately I don't have it
10:10Ember-well, got to go. Will continue this later today
10:10Ember-thanks for your help borkdude, really appreciated :)
10:11corecodeso (set (concat seq1 seq2)) is much faster than (union seq1 seq2)
10:11corecodeis that the right idiom to use?
10:12borkdudeEmber- no problem, I hope I'm not guiding you the wrong way
10:12borkdudeI now get what the path means
10:12borkdude(-> (zip/vector-zip [[1] [2] [3]]) zip/down zip/down zip/path) ;;=> [[[1] [2] [3]] [1]]
10:13borkdudeit just means, first the "cursor" was at the entire thing, then it zoomed in on the first thing down and then the first thing down
10:14borkdudethis isn't really helping for your answer
10:17borkdudealthough the path shows.. the path that is possible, not the keys for get-in
10:22preyaloneAnyone use msysGit?
10:36preyaloneAnyone use Cygwin?
10:45preyaloneAnyone use MSYS?
10:45preyaloneAnyone use git on Windows?
10:45OEyeah
10:46TimMc~anyone
10:47epitroni use cygwin + cygwin git
10:47TimMcclojurebot: Alive?
10:47TimMcLooks like they left, anyhow.
11:07jcromartiehow can I get the fully-qualified version of a symbol from a namespace… I know how to get a var with ns-resolve
11:07jcromartie,(ns-resolve *ns* 'map)
11:07clojurebot#'clojure.core/map
11:07jcromartiebut what do I do with the var?
11:08tutysra_hi room, I am implementing some concurrent code where some object should be initialized only once (inserted into db and its id fetched), many threads access it at a time and the first thread takes care of creating it and all others should use the already created copy... i thought a memoized function will do the job,but it didn't, any thoughts on how this can be done?
11:17jcromartietutysra_: sounds like you could design that differently
11:18jcromartietutysra_: is this one big operation that happens concurrently, or is it something that is going on sporadically
11:21tutysra_i am inserting n records and the record insertion is done from many threads (using pmap), they all call get-root to get the root element below which they are inserted, the first record that is inserted creates the root record and initializes the root before creating itself and all other records refer to the root-record created earlier
11:21tutysra_all the records are inserted below the root which is created once
11:22jcromartiewhy not create the root first, then use the ID in the parallel operations
11:22jcromartiei.e. (let [root (create-root …)] (pmap #(create-child root …) child-data-coll))
11:23hitekihi
11:24jcromartietutysra_: well you'd have to do (doall (pmap …)) to get them all to execute in that example, specifically
11:24imdhmdhello all ... is there a good repl or clojure coding env for android platform?
11:25chronnojcromartie: Don't know if it helps, but the meta for the var has the info you need
11:26borkdudeEmber- here I made an example with xml-zip https://www.refheap.com/paste/12007
11:26chronno,(ns-name (:ns (meta (resolve 'map))))
11:26clojurebotclojure.core
11:26chronno,(:name (meta (resolve 'map)))
11:26clojurebotmap
11:26borkdudeEmber- at least you can see the path it take to get to the element
11:27borkdudeEmber- you could enhance the output so the path is somewhat nicer to read
11:27jcromartieimdhmd: the ones I've tried all suck
11:27jcromartiechronno: thanks, that's the route I was going down
11:27tutysra_jcromartie, I can do that... but my data is just the record that i am inserting and i have various types of it and I get them from external data (scrapping website),i am segregating similar type of records by creating a root record and putting the different types of the records under different roots dynamically as and when i get the records
11:27borkdudeEmber- I think you should use hickory's format though and not hiccup-zip, since that one doesn't handle attributes I think
11:28jcromartietutysra_: ah, I see… so the root might not yet exist
11:28tutysra_yeah... i won't know then until i see the data
11:30jcromartietutysra_: hm, well using some kind of memoization is a pretty stateful way to do it
11:30chronnojcromartie, found a better one
11:30jcromartietutysra_: but no, built-in memoize won't help you there
11:30chronno,`map
11:30clojurebotclojure.core/map
11:30imdhmdjcromartie: yeah .. I c it wud require a specialized keyboard support. hmm
11:30tutysra_yeah... it didn't worked
11:31jcromartietutysra_: but you could write your own memoized function
11:32tutysra_thid doesn't work - (defn myfunc[a] (println "doing some work") (Thread/sleep 3000)(+ a 10)),(def myfunc-memo (memoize myfunc)), (pmap myfunc-memo [0 0 0])
11:32tutysra_*this
11:34jcromartie(let [cache (atom {})] (defn get-root [key] (if-let [v (get cache key)] v (get (swap! cache assoc key (create-root key)) key)))
11:34jcromartietutysra_: looking at the source of memoize
11:34jcromartietutysra_: p.s. I just wrote that here in IRC… don't take it as truth
11:35tutysra_jcromartie, sure ;-), let me try that first
11:36jcromartietutysra_: oh, an important change, you should (get @cache key)
11:36jcromartienot (get cache key)
11:36jcromartiewait a sec
11:37jcromartietutysra_: memoize should work there…. if you have a function (get-root …) which creates (in the DB) the value you want, then (memoize get-root) will only call it the first time for each new key
11:37jcromartietutysra_: it should be fine if your get-root is correct
11:38jcromartiebut like I said, this all sounds kind of fishy… memoize is not really for limiting side-effects
11:38jcromartieand what happens if you run your program twice?
11:38jcromartieit's better to make everything idempotent
11:39tutysra_it should create a record only if it doesn't exist, so in the second time if we get the same record and root type it should read the database and skip the insertion
11:40tutysra_jcromartie, reg memoize - (defn myfunc[a] (println "doing some work") (Thread/sleep 3000)(+ a 10)),(def myfunc-memo (memoize myfunc)), (pmap myfunc-memo [0 0 0])
11:40tutysra_it prints "doing some work" more than once on my system
11:41jcromartietutysra_: just a sec
11:44jcromartietutysra_: I think this is an abuse of memoize :)
11:47tutysra_jcromartie, before memoize i had written a function similar to the one you gave and I switched to memoize because that didn't worked, let me check the previous code you gave
11:47jcromartietutysra_: the problem is that the function you are memoizing can't be retried
11:48jcromartieand atoms (which memoize is built on) will retry when another thread tries to modify the atom at the same time
11:48jcromartieso pmap throws it all off
11:48tutysra_jcromartie, correct, i know that, i has side effects
11:48jcromartiebetter to stick with purs functions
11:48jcromartiepure functions
11:49jcromartie,(let [a (atom 0) f (fn [_] (println "incrementing" @a) (swap! a inc))] (dorun (pmap f (range 10))) @a)
11:49clojurebot#<SecurityException java.lang.SecurityException: no threads please>
11:49jcromartieno, OK stick that in your own REPL tutysra_ :)
11:51tutysra_jcromartie, got your point, inc is pure
11:52tutysra_i would like to use pure functions everywhere... but can't escape here
11:52jcromartietutysra_: you might be surprised… what's the bigger picture?
11:54tutysra_jcromartie, himmm not getting it... any hints?
11:57jcromartietutysra_: can you gather up everything ahead of time before inserting it in a database?
11:57jcromartiei.e. get the structure out and then do the insert
11:59tutysra_yeah i can do that if that is the only option.... will be interested in knowing how I can implement such scenario in clojure
12:04jcromartietutysra_: well you could do it in a couple of ways
12:04jcromartieyou could use an agent to do the inserts
12:04jcromartiei.e. you do the crawling in parallel, but serialize the DB activity
12:05jcromartiebut that's very side-effecty
12:06jcromartiemaybe you can describe the problem
12:07jcromartieyou could do an insert-or-update inside a DB transaction
12:07cliftonhave you looked at REPLACE INTO?
12:08tutysra_jcromartie, himm, problem is very much the same, to give more context i am using neo4j
12:08jcromartieooh, nice
12:08jcromartieah ha
12:08jcromartiethat helps
12:08tutysra_more specifically their rest binding
12:08jcromartieneo4j still has transactions, and you can do the same kind of create-or-update
12:10jcromartie(I assume…)
12:10jcromartiehm yeah, CREATE UNIQUE
12:11tutysra_yeah...create unique seems to be a nice option... let me try that
12:20fredyrhttps://www.refheap.com/paste/12009
12:21fredyranybody think core.logic would be a good fit for this problem?
12:21fredyror other ideas?
12:28tutysra_jcromartie, thx, unique worked...
12:29jcromartie:) glad there was a simple solution waiting to be coaxed out
12:30tutysra_we kind of delegated this to the db :-) ... if you think of any other solution, do keep me informed
12:30tutysra_i will ping my mailid in a private msg
12:31jcromartiedelegating it to the DB might be the best solution
12:32jcromartiein fact I'd say that's the best way to go when a DB is involved
12:32jcromartielet it do what it's designed to do
12:32tutysra_himm okie...
12:33jcromartieClojure's concurrency is designed around Clojure's own persistent datatypes and pure functions
12:36palangoI'm trying to get leiningen project information from a jar file, is there any api to do that?
12:40bbloomdoes (:refer-clojure :as clj) not work? what's the magic syntax there?
12:41jeremyheilerbbloom, I use (:require [clojure.core :as core])
12:42bbloomjeremyheiler: ok, that's what i'm doing, just wondering why :as doesn't work :-/
12:42bbloomthanks tho
12:42jeremyheiler,(doc refer)
12:42clojurebot"([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to somethin...
12:43jeremyheilerrefer seems to only support :exclude, :only, and :rename
12:43Bronsayeah, :as is alias
12:43bbloomi guess that makes sense since refer-clojure delegates to refer
12:43bbloombut i wish :as worked :-P
12:44jeremyheilerWell, the point of refer is to not have a namespace alias :-P
12:45bbloomjeremyheiler: right, but i want to do: (:refer-clojure :exclude [foo bar] :as clj) so that i can get to clj/foo and clj/bar
12:45bbloomnow i need two lines to do it :-/
12:45bbloomi guess what i want is :require-clojure instead
12:45bbloomwhich is what i often type at first, heh
12:48jeremyheilerThat seems confusing. I would think you're trying to exlucde foo adn bar, but namespace clojure.core as clj.
12:49jeremyheilerI see what you're after, though.
12:52jeremyheilerbbloom, To get it on one line you could say (:refer-clojure :rename {foo core-foo})
12:53bbloomjeremyheiler: i know, but i prefer the alias, thanks tho
12:54jeremyheilerbbloom, heh, so do i.
14:47gfredericks31mb of #clojure logs over two years, zipped
14:53borkdudegfredericks nice
14:56noncomonce i somehow managed to make REPL pprint functions not like something like #<pointers_and_stuff> but like their AST. but i cannot understand how it happened, i do not remember doing anything special and I can't find a doc on this. how to do that?
14:57bbloomnoncom: as far as i know, that doesn't exist in clojure
14:57gfrederickswhat was technomancy's lib for that?
14:57gfredericksserialized-fn I think
14:57gfrederickswouldn't directly apply to existing functions though
14:58borkdudecemerick hey, I was just re-reading some part from clojurebook and I wondered: what did you use to write/edit the book
14:58noncomnope. it happened spontaneously. i am using CCW
14:58muhooi have to interface with a java function that DEMANDS an arrya of FooObject. i've got a seq, need to turn it into an array of FooOBject. to-array just turns it into Object, which is not OK.
14:58gfredericks,(doc to-array)
14:58clojurebot"([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."
14:58gfredericks,(doc make-array)
14:58clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
14:58muhoomake-array, thanks!
14:59borkdude,(apropos "array")
14:59clojurebot(object-array boolean-array long-array short-array char-array ...)
14:59TimMcgfredericks: How far do your #clojure logs go back?
14:59gfredericksTimMc: I just ripped from n01se, all the way back to the dawn of swearjure
14:59cemerickborkdude: like, for markup?
15:00TimMcgfredericks: Ah, OK.
15:00borkdudecemerick yes, the process
15:00borkdudecemerick from text to published version
15:00gfredericksTimMc: only 104 mentions of "swearjure" over all time
15:00TimMcUnbelieveable.
15:00TimMcYou'd think it would be more. :-P
15:01cemerickwrite asciidoc -> git-svn push -> O'Reilly svn hooks convert asciidoc -> docbook -> #{:pdf :mobi :epub}
15:01gfredericksI'm appauled it isn't. Clearly we need to do a better job of educating the public.
15:01gfredericksTimMc: I'll put this on the agenda for the next committee meeting
15:02borkdudecemerick how do you write those labeled numbered balls in asciidoc?
15:03muhooactually, into-array was a drop-in relacement for to-array, and did exactly what i wanted
15:03borkdudecemerick btw I'm going to recommend this book for my course
15:03cemerickborkdude: which have bidirectional anchors in the PDF :-)
15:04cemerickborkdude: http://www.methods.co.nz/asciidoc/userguide.html#X105
15:04cemerickborkdude: sweet! :-)
15:04borkdudecemerick ah I see :) do all authors use asciidoc in oreilly?
15:05gfredericksmuhoo: I had hoped there was an easier one
15:06cemerickborkdude: no, most write directly in docbook
15:06cemerickor, last I knew, anyway
15:06FrozenlockHmmm.. I have some weird errors popping up. I moved some functions in another namespace, but I made sure to `refer' them in the namespace declaration. Now I have this error: java.lang.IllegalStateException: <my-fn> already refers to: #'my-ns.sub/<my-fn> in namespace: my-ns.core
15:07borkdudecemerick tnx
15:07cemerickso, that process held until "final review", at which point the whole thing was taken over by people using framemaker, and the only way to get edits through was via comments in a generated PDF :-x
15:07borkdudecemerick when co-writing it must be nice to use text based git approach
15:08cemerickit's a reasonable minimal toolchain :-)
15:09gfredericksFrozenlock: did you restart your repl?
15:09FrozenlockYup
15:09borkdudecemerick I'm using org-mode now, but keeping an eye on this for future work tnx
15:10gfredericksFrozenlock: and you're sure you deleted my-fn from the core ns?
15:10gfredericksFrozenlock: did a `lein clean`?
15:10FrozenlockYes
15:10FrozenlockNo
15:10Frozenlock:/
15:11gfrederickstry that and if that doesn't work start adding and removing parens at random
15:14FrozenlockWell now I get a 'not such var...' error. Perhaps I'm not using this correctly. Project A --> (:require [b.core :as c]) Project B --> (ns b.core (:require [b.subs :refer my-fn])). Then in project A ---> c/my-fn BAM error.
15:15gfredericksoh you want my-fn to be accessible from project A as if it's defined in b.core?
15:16gfredericks(also :refer takes a list)
15:16FrozenlockYes. And yes, I did use a list :p
15:18FrozenlockKind of like an API if you will. Gather all the functions the user might need in a common namespace.
15:19gfredericksyeah that's not what refer does
15:19gfredericksI don't know if there's a standard mechanism for effecting that
15:20gfredericksthere was a contrib lib that did it back in the day I think
15:22FrozenlockOh... disappointment :(
15:23gfrederickseasy enough to hack; (def my-fn #'b.subs/my-fn)
15:23gfredericksthat's only mostly equivalent if it's a function
15:24gfredericksnot at all equivalent if it's a constant
15:26bbloomgfredericks: (def my-const @#'b.subs/my-const)
15:26bbloom:-)
15:26bbloombreaks during interactive development tho, since it loses an indirection
15:26gfredericksbbloom: may as well (def my-const b.subs/my-const) then
15:27bbloomgfredericks: yes, i know. bad joke....
15:27seangrovecemerick: You mentioning working on a book with a git-like flow reminded me of Draft: http://ninjasandrobots.com/draft-preview-uber-for-writing
15:28bbloomgfredericks: can probably call `intern directly
15:28bbloomhm or maybe not
15:28bbloomwould have to construct a Var by hand, private constructors and things
15:28derekvjava -jar my-uberjar.jar yields "no main manifest attribute", I put :aot [mynamespace.core] :main mynamespace.core in my project.clj and have (ns mynamepsace.core (:gen-class)) with (defn -main [$ args] (println "hello"))
15:29derekvany help?
15:31derekvnevermind, did a clean and its fixed..
15:34sritchiecemerick, do you know if it's possible to sync a single view's worth of data between couchdb apps?
15:34sritchievs syncing the entire database
15:35gfredericksyou can put a filter on replication
15:35gfredericksI think that's the extent of it
15:37cemerickseangrove: interesting, thanks!
15:38cemericksritchie: not AFAIK. Maybe with bigcouch?
15:38sritchiehmm
15:38sritchiecemerick: I'm working on an iPhone app for users of a CouchDB app --
15:39sritchiethe idea is that they'd be able to work with a view offline
15:39sritchiethat might be too much functionality for now
15:39sritchiemaybe just speaking with the view is enough
15:39sritchieI just don't want the app to have to download the entire view
15:40cemericksritchie: well, query to limit the range you cache/store?
15:41sritchieit's the sync back to the app I was concerned with
15:41sritchiebut I'll probably have to do that syncing manually
15:41sritchieI was hoping that the replication feature could handle that somehow
15:41cemerickwell, views don't take updates anyway
15:41sritchiegotcha
15:41sritchieokay, cool
15:41cemerickyou've seen https://github.com/mikeal/pouchdb ?
15:45derekvhow do I test that a function fails an assert if I pass it a bad parameter?
15:45derekvsorry very new trying to get a grip on the language and testing framework
15:46gfredericksderekv: with clojure.test?
15:46seangrovecemerick: I think https://github.com/daleharvey/pouchdb is a bit more up to date, heh
15:46gfredericks(is (thrown? AssertionError (my-fn some bad parameters)))
15:46derekvyea... maybe its (is (thrown?
15:46gfredericksderekv: ^ I believe more or less like that
15:46derekvheh
15:47derekvgfredericks, thanks
15:47derekv=]
15:47cemerickseangrove: ah, fair enough; mobile isn't my bag :-)
15:47sritchiecemerick: very cool
15:47derekvI hit a point I wasn't ever sure where to look online then I realized that they were just java exceptions
15:47sritchiecemerick: looks like replication with a filter is what I want, I think
15:48sritchiehttps://github.com/couchbaselabs/TouchDB-iOS/wiki/Guide%3A-Replication
15:48sritchiefiltered replications. done.
15:49gfredericksderekv: and you could do something more sophisticated to expect on the msg in the error if you wanted
15:50cemericksritchie: Oh, certainly. I got thrown by the view part :-)
15:50sritchiecemerick: yeah, my bad -- I was looking to replicate all info required to create a view for some customer
15:50sritchieman, what a cool DB
15:50sritchietoo bad haters gonna hate :)
15:52devlolHi, I just wrote a small lib on top of compojure/clout which allow you to specify custom wrappers for specific endpoints, group of endpoints and generate iodocs documentation. What do you guys think of this approach ? https://gist.github.com/obohrer/c7011444273c36235558
16:10ivandid you know Sun launched a Java Store in 2009 https://www.youtube.com/watch?v=AZyHmLmPyTU that was silently killed in 2010
16:12gfredericksa what
16:13ivanan app store that would reach a billion people, presumably through the annoying updater
16:15akhudekoh my, those youtube comments D:
16:20gfredericksooh I somehow read "brick and mortar" into that
16:20TimMcJava t-shirts
16:20gfredericksJVMs on shelves
16:21gfrederickspeople lining up for java 7
16:21TimMcreinforced shelving, of course
16:21gfredericks6 foot posters with slick marketing about lambdas
16:22gfredericksand of course jeniuses trained to help you with the thorniest of NPEs
16:29amalloymaybe people would line up for java 7 if it had better beveled edges
16:53hyPiRiongfredericks: hahah
16:53gfrederickshave to escape every damn character in that
16:53hyPiRion~quicksort
16:54amalloygfredericks: grep -P "\Q(+(*)(*)\E"?
16:54amalloyi guess you'd need to escape the \ still, or use ' instead of "
16:56gfredericksamalloy: yes I probably should have done that
16:57tyler_whats the most stable/recommended irc client?
16:58tyler_library
17:00derekvnothing is working first try from any examples online... =[ what the heck in wrong about this : https://www.refheap.com/paste/12013
17:01derekvI get unable to resolve classname Doll
17:07gfredericksderekv: you have to import defrecords
17:07gfredericksif you want to use their java class name
17:07gfrederickslooks like in this case you could use ->Doll instead
17:07gfredericks(a function that defrecord implicitely defines for you)
17:09derekvcan you give me an example of using ->Doll ?
17:10gfredericks(->Doll. expected-name expected-weight expected-value)
17:10gfrederickser
17:10gfredericks(->Doll expected-name expected-weight expected-value)
17:10derekvgfredericks, thanks ... do I still need the (def ?
17:11gfrederickson an unrelated note, there's no need for def on line 13 -- you can do that as part of the let
17:11derekvor do I use set
17:11derekvok
17:11derekvsortof, had no idea what the def did
17:11gfredericksusing def not at the top level is rarely ever what you want to do
17:11derekvjust was looking at examples
17:12gfredericksa lot of example code will use def for toy things because it's useful at the repl, but not always what you'd put in real code
17:12derekvgfredericks, that worked, thanks
17:12gfredericksnp
17:12derekvyea I know some CL but wasn't familier with what def did, I thought maybe it had something to do with records specifically
17:13derekvso the dot in ClassName. means you want to create an instance of that java class?
17:13gfredericksit just makes a global thing within the namespace
17:13gfredericksyes
17:14derekvcool
17:24RaynesMan, clj-time is such an inconsistent mess.
17:25Raynesclj-time.core/hour clj-time.core/minute (doing good so far!!!) clj-time.core/sec........
17:25RaynesOhai, let's name half of our functions in abbreviated form and the rest of them with the whole words!
17:28gfredericksthe rule is "use abbreviated whenever possible and unambiguous"
17:28RaynesWhere is this rule?
17:29gfredericksI'm making shit up
17:29RaynesI was hoping that was the case.
17:29gfredericksactually now that I think about it both min and second are in clojure.core. so either way you're colliding, which I agree is totally okay to do.
17:32Raynesgfredericks: I've stopped caring completely about what is and isn't in core. People need to embrace the require!
17:33gfredericks(defn require! [& args] (throw (Exception. "require! is not defined. perhaps you meant `require`?")))
17:36Raynesgfredericks: You are a clever and amusing individual, but I can still match wits with you on any day.
17:37RaynesIn other news, wtf https://www.refheap.com/paste/12010
17:37jcromartiewhat's the simplest possible persistence approach for a really simple clojure system
17:37RaynesWell, how much do you need to persist?
17:37gfredericksRaynes: you are ten times more clever than me after normalizing for experience
17:38RaynesYou could spit out Clojure data structures to a file and read them back later, but that obviously becomes pretty insufficient pretty fast.
17:39ivaraasenRaynes: seen worse
17:39RaynesMongoDB is extremely simple and easy to get going.
17:39RaynesBut I don't know if that qualifies as the simplest possible approach.
17:39RaynesI'm pretty sure that just writing stuff to files is the simplest approach.
17:40RaynesOr tell it to amalloy and ask him later.
17:40RaynesAccount for occasional data loss if he drinks to much, but that's rare.
17:40Raynestoo*
17:41amalloyLeaveMeAloneImSleepingException
17:41RaynesGive him a can of campbells soup and he shut down with a non zero exit code.
17:41jcromartieRaynes: a few dozen small hash mas
17:42jcromartiehash maps
17:42derekv(if (not (seq? [])) 'groan)
17:42RaynesSure, you can just write that to a file and read it in later.
17:42jcromartieso, do the change, and then just (send-off file-writer save my-ref)
17:42gfredericksderekv: sequential?
17:42jcromartieyeah, can't get any simpler
17:43jcromartieno need for an append-only file-rotating journaled transactor :)
17:43derekvgfredericks, thanks again
17:45gfredericksnp
17:46TimMcRaynes: Looks like someone's writing Conway's Life, but I can't tell what language they're using.
17:47ryanfkinda looks like one of those apl-inspired languages maybe?
17:47amalloyspanish, TimMc. duh
17:50TimMcpff
17:51TimMc&#'clojure.core/add-doc-and-meta
17:51lazybot⇒ #'clojure.core/add-doc-and-meta
17:54alandipertjcromartie: i made https://github.com/alandipert/enduro to use on my raspberry pi, maybe you'd enjoy it?
17:57Frozenlockalandipert: you used clojure on the raspberry pi?
17:57alandipertFrozenlock: indeed!
17:57Frozenlock!!
17:57FrozenlockIt... works? :p
17:58FrozenlockSpeed/memory are sufficient?
17:58alandipertfor many neat things, yes
17:58FrozenlockDoes it mean you need to tweak .core?
17:58jcromartieoh neat
17:59alandipertFrozenlock: nope just need to install JDK, lein as on linux
17:59FrozenlockWow. Now I need a raspberry pi.
18:00FrozenlockHmm I wonder if it's easy to play with IOs via clojure.
18:00jcromartieFrozenlock: it's not
18:00jcromartieif you mean Apple's iOS
18:01jcromartieor do you mean like, ObjC on iOS and Clojure on a server
18:01FrozenlockNo, I mean input/output, as on a microcontroller
18:01jcromartiegag gag
18:01jcromartieI mean hah hah
18:01jcromartiecontext :)
18:01jcromartiealandipert: neat
18:01alandipertFrozenlock: i did some GPIO stuff from clojure - blinked some LEDs, didn't do much more, but it's all possible afaik
18:02FrozenlockNice!
18:08drewcFrozenlock: I just got my gertboards, which means my arduino has not been used in a while!
18:08drewchttp://www.raspberrypi.org/archives/tag/gertboard
18:14derekvemacs compilation buffer doesn't totally parse the lein output correctly
18:14derekvit doesn't always make filename - line numbers into hyperlinks
18:16bbrittainthis mighth seem like a silly question. What is the difference between
18:17bbrittain(def nums `(1 2 3 4 ))
18:17bbrittain(def nums2 (list 1 2 3 4 ))
18:17bbrittainwhy can I peek on one, and not the other?
18:17tyler_i have a ref thats a map and i just want to update one attribute of it, what si the best function?
18:17bbrittainand why does "(= nums nums2)" return true then?
18:18tyler_(= {:foo "bar" :biz "baz"} @ref)
18:19tomoj&(class `(1 2 3 4))
18:19lazybot⇒ clojure.lang.Cons
18:19tomoj&(class (next (concat (list 1 2 3) (list 4 5 6))))
18:19lazybot⇒ clojure.lang.Cons
18:19tomojit's not clear to me why you can't peek a Cons
18:20tomojoh
18:21tomojmmarcyzk says because an IPersistentStack has to have a count()
18:21tomojbut he was wrong
18:23tomojrelated: https://groups.google.com/d/msg/clojure/co8lcKymfi8/CjyOPpR6FRMJ
18:24bbrittaintomoj, good to know other people are confused too :P
18:24tomojI think mmarcyzk's last message is close to the truth
18:26callenbotyogthos|away: you. I like you.
18:27tomoja PersistentList's rest is always IPersistentList
18:32derekvis there a sort of (collection? #{})
18:32derekvsomething to test that it is a collection
18:34alandipertderekv: coll?
18:35derekvalandipert, thanks
18:36derekvalandipert, hey we met briefly at strangeloop 2011. just before simple iirc
18:37derekvsimple made easy rather
18:37alandipertderekv: oh yeah! tablemates iirc. sup :-)
18:37derekv=] Yea, I didn't know who Rich Hickley was when I sat down.
18:38derekvs\ckle\cke
18:43Raynesderekv: Your life was so dull up until then.
18:47derekv=]
18:47derekvOr you could say my life has been dull since then.
18:52yogthoscallenbot: I hear I am somewhat likeable :P
19:00callenbotyogthos: yes but I like very few people.
19:00callenbotyogthos: also, Zurb shit the bed.
19:00yogthoscallenbot: ha~
19:01callenbotyogthos: 4.0 release of Zurb is pretty fucked.
19:01callenbotI'm migrating over to bootstrap right now.
19:01yogthosyeah good plan
19:01yogthosI recall you had your reservations about it before
19:01callenbotyogthos: I've had bad experiences with bootstrap before but the community support and recent improvements seem like they might solve some of that for me.
19:02callenbotyogthos: most of my bad experiences centered around making substantive modifications to the nav bar
19:02yogthosahh
19:02yogthosthat's the thing with frameworks, they are opinionated :)
19:02callenbotyogthos: sigh. you're telling me.
19:03yogthosoh and played with korma finally, it is nice
19:03yogthosEd switched luminus to use it by default now
19:03callenbotyogthos: I told you korma was nice.
19:03yogthos:)
19:03callenbotyogthos: it seriously understands "make a language of reusable components" even if it has a long way to go.
19:03yogthosyup
19:03callenbotalso what's with the netsplit carnage lately?
19:04yogthoslol dunno what's up with that
19:04callenbotyogthos: sadly my work is in Flask/SQLAlchemy right now and will likely continue to be for awhile. I went independent, working on contract.
19:04callenbotyogthos: going to try to use contract as runway for my own shindig.
19:04yogthoshaha could be worse, some people actually have to work with java :P
19:05callenbotdon't get me wrong, I like Python
19:06yogthosyeah there are worse things that's for sure ;)
19:06callenbotyogthos: by a long yard.
19:20derekvso, subsets is lazy, does that mean something like (filter #(tasty-combo? %) (subsets things-in-my-pantry)) is lazy?
19:24yogthosderekv: yeah chaining lazy functions together is lazy
19:27derekvyogthos, if I wrap that in a defn, is that function automatically lazy or do I need write it that way somehow... seems like it would be because its evaluating to a lazy-seq ... i think..
19:28yogthosderekv: basically, it'll stay lazy until you force evaluation with something like doall
19:32derekvyogthos, very cool
19:47amalloyderekv: #(tasty-combo? %) is just tasty-combo?
19:47RaynesBut feel free to wrap functions in functions in functions if it makes you happy.
19:52derekvI'm not sure why I wrote it that way.
19:53derekvThat was ages ago I don't remember anymore.
19:53derekvI'm sure there was a good reason.
20:23mpfundsteindoes someone know how i can sum up all values of a map?
20:23mpfundstein{tvod 75, svod 174647}
20:23mpfundsteinshall return 174722
20:23danlarkin(reduce + (vals ...))
20:24hyPiRion,(vals {:tvod 75, :svod 174647})
20:24clojureboteval service is offline
20:24hyPiRionuh what
20:24mpfundsteinif i dont know the keys and dont know how much keys?
20:24metellus&(vals {:tvod 75, :svod 174647})
20:24lazybot⇒ (174647 75)
20:24mpfundsteinok thanks
20:25mpfundsteinworks perfect thanks
20:29sorbo_did clojure.contrib.lazy-seqs move? I don't see it listed as having migrated, but I can't lein deps it.
20:30hyPiRionsorbo_: which seq are you in need of?
20:30sorbo_hyPiRion: primes
20:31hyPiRionhttps://github.com/hyPiRion/primes/tree/0.1.0 <<
20:31hyPiRionIt's faster than the lazy-seq version
20:32sorbo_hyPiRion: awesome, thank you
20:32hyPiRionDocumentation here: http://hypirion.github.com/primes/0.1.0/com.hypirion.primes.html
20:32hyPiRionYou're welcome.
20:32hyPiRion:)
20:32RaynesGood guy hyPiRion.
20:32RaynesMakes. Me. Sick.
20:33hyPiRionRaynes: Want me to be the bad guy again?
20:37nonubywhats the easiest way to coerce a number say it must be 1-10 so if the input is 14 it yields 10?
20:38mattmoss&(min 10 14)
20:38lazybot⇒ 10
20:38cgag(min n 10)
20:38mattmoss&(max 1 (min 10 14))
20:38lazybot⇒ 10
20:39nonubythanks
20:44bbloomnonuby: mattmoss: for the record, that function is generally called "clamp" in game & simulation dev circles
20:45bbloom(defn clamp [lower upper x] (max lower (min upper x)))
20:49nonubythanks bbloom will remember that
20:49mattmossbbloom: ya, i know... used to work in game dev
20:49ivaraasenhyPiRion: sup
20:49mattmossDidn't think clojure had clamp in standard libs, tho. :)
20:51hyPiRionivaraasen: java concurrency and horrible reflection hacks. that's up
20:51Raynescallenbot: http://www.youtube.com/watch?v=Wk1_wJoGV5I
20:52ivaraasenhyPiRion: do tell
20:54hyPiRionivaraasen: techomancy/leiningen#957 is the main issue
20:55hyPiRionApparently System/in and InputStreams in general are really dirty if you want to do non-blocking stuff
20:55hyPiRionhttp://hypirion.com/musings/how-to-cancel-a-blocking-read
20:56akhudekhyPiRion: I appreciate the typography on your blog
20:56hyPiRionIt essentially boils down into a workaround for this 12 year old bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4514257
20:56hyPiRionakhudek: oh, thank you
20:57ivaraasenhyPiRion: actually looked into this the other day by chance. then I went to bed and cried myself to sleep
20:57hyPiRionYeah, that's the right way to handle it.
21:13ravsterAre there geo location libs in clojure? We're trying to figure out if we can find places of interest within a radius of a location (Denoted by latitude and longitude)
21:17lynaghkravster: there's an implementation of the haversine algorithm in c2, though it's not particularly optimized or anything
21:17lynaghkbut it'll give you the great circle distance between two lat/lons on a sphere
21:18danlarkinI think it's safe to assume there are some nice java libs to do spatial math
21:20ravsterlynaghk: thanks, I'll look into it.
21:37Bronsa_porcodio
21:37Bronsa_lol
21:37Bronsa_ho svegliato
21:37Bronsa_mia madre
21:49Bronsaquanto
21:49Bronsachap
22:10muhoocosa di pazza
22:10muhooi present for your ridicule, this steaming pile: https://www.refheap.com/paste/12019
22:17gfredericksmuhoo: wat it is
22:18muhoohehe. i'm not quite exactly sure.
22:18derekv(alter max-weight Integer/parseInt input-string) -> Unable to find static field: parseInt in class java.lang.Integer
22:19TimMcderekv: You'll want #(Integer/parseInt %) there.
22:19derekvTimMc, =] sweet
22:19TimMcInterop forms are annoying that way.
22:19TimMcBasically, since parseInt is a method, it has to be in a call position.
22:20derekvI see
22:44derekvHow am I supposed to figure out where the error is from "Wrong number of args (2) passed to: core$input-handler$fn--124$fn--125$fn"?
22:49TimMcderekv: So, that's some fn inside a fn called input-handler inside a namespace call core. Probably.
22:49TimMcAnd something is passing it two args.
22:51derekvI'm not sure what fn... sorry this is horrid, trying to get the test green so i can refactor.. https://www.refheap.com/paste/12020
22:53derekvThere's probably some inbalanced paran or something, but i'm on about my 8th time checking it
22:54derekvi should probably just start over and rethink it
23:00derekvrewriting
23:00derekvhated it anyways
23:00TimMcderekv: Could it be that alter is passing 2 params to that fn literal?
23:01TimMcThat's the only inner function I see, and it's plausible...
23:01TimMc(Macros could be introducing other fns, of course.)
23:02derekvthe parseInt?
23:03TimMcyeah
23:03derekvalthough I guess that means it could be the "catch" clause, i'm sure thats macro driven
23:03muhooi haven't seen any code that uses preconditions or postconditions in the wild. is that considered a deprecated feature? or one that's just not used? or am i missing something?
23:05TimMcmuhoo: https://github.com/timmc/pellucida/blob/master/src/org/timmc/pellucida/single.clj#L13
23:05Raynesmuhoo: Hi.
23:06muhooRaynes: yo
23:06muhooTimMc: thanks
23:06TimMcmuhoo: This one is better: https://github.com/timmc/pellucida/blob/master/src/org/timmc/pellucida/pager.clj
23:07Raynesmuhoo: I just recorded a video cover of a song for fun and I might be persuaded to let you see it.
23:07TimMcBasically, I use them both as sanity checks (so that a bad value doesn't cause a hard-to-debug stack trace) and as documentation.
23:07muhooRaynes: no shit? youtube that puppy
23:08muhooTimMc: looks useful. i can recall seeing in clojure sourcecode that dated back a long time, but not in any recent projects, until this one. seems really a useful thing
23:08muhooinstead of having try/catch crap cluttering up the code
23:08muhooactually no. instead of having if/throw cluttering up the code
23:09TimMcA really useful fn to use with pre/post is ##(doc cast)
23:09lazybot⇒ "([c x]); Throws a ClassCastException if x is not a c, else returns x."
23:09muhooheh, static typing!
23:09TimMcIsh.
23:10derekvso if i want to filter out the falsy things from a collection, is there a more elegant way than "(filter #(not (not %)) coll)"
23:10TimMcderekv: identity
23:10TimMc&(filter identity [1 2 false true nil "hi"])
23:10lazybot⇒ (1 2 true "hi")
23:11derekvTimMc, cool perfect
23:25TimMcGeneral question about web apps: Should I show an error page when I get a malformed optional querystring parameter, or just ignore it?
23:26TimMcExample: ?page=wtf
23:28RaynesTimMc: Probably ignore it.
23:29dcolishTimMc: thats what a 400 page is for
23:30dcolishits best to let the client know if there's a malformed request unless there are security reasons not to
23:30dcolishs/page/response/
23:30dcolishi assumed page, but you could be writing a rest client for all I know
23:31TimMcWeb page.
23:33dcolishimho, you should not ignore malformed inputs even if they're optional because the user is expecting a specific behavior and its less surprising to get an error with some suggestion of how to fix the request than return 200 with a default value
23:44amalloyTimMc: it's okay to ignore query params you don't use at all, but if ?page has any valid values then you should return 400 if something invalid is there