#clojure log - Mar 02 2013

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

0:00 TimMc: I thought perhaps I had put a board in the wrong place somewhere.

0:20 tyler_: anyone know if you can call functions from clostache?

0:20 in the view

0:20 ah you can call lambas nice

0:21 n/m

0:21 found it

0:29 Frozenlock: Is 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)

0:30 tomoj: I think I usually (apply concat (for [x some-list] (if x [x] [1 2 3]))) :(

0:30 hmm

0:30 (for [x some-list y (if x [x] [1 2 3])] y) ?

0:31 Frozenlock: o_O

0:31 Never used `for' with more than a coll.

0:33 Looks like it could work, thanks :)

0:56 leku: how do I work with .jar files and clojure?

0:56 I'd like to be able to play around with this API and teach myself a little clojure at the same time

0:56 (require '(USGS jar [set :as u]))

0:56 not working

0:58 a stackoverflow page suggests putting it int he lib folder

0:59 i created a new project with lein but there is no lib dir

1:07 tomoj: which stackoverflow page?

1:07 leku: https://github.com/technomancy/leiningen/wiki/Repeatability

1:07 lib/ doesn't exist anymore in lein 2

1:08 leku: ah

1:08 ahh

1:08 i see what they did here

1:08 tomoj: if 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

1:08 leku: rgr

1:33 yedi: is clj-stripe the only stripe wrapper lib?

1:39 xeqi: yedi: I've been using clj-http to hit the api directly for a recent project

1:40 those were the two choices I found

1:40 yedi: theres no wrapper over javas native library?

1:47 xeqi: you could just inerop with it, but I didn't find it very nice when I tried

1:47 *interop

2:19 Frozenlock: "Cannot recur from catch/finally" Damn

3:06 Deece: I'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?

3:12 noidi: Deece, it's very rare for an anonymous function to not call another function, so mostly you'd end up with double parens #((...))

3:18 leku: how do I connect my emacs to the repl?

3:18 so that when I save I can run new functions in the lein repl?

3:23 noidi: leku, maybe this guide could help? http://clojure-doc.org/articles/tutorials/emacs.html

3:25 leku: thx

3:39 perfect noidi

3:39 thank you

3:50 babilen: Just 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?

3:50 (yeah, you guessed correctly this is about the reducers library)

4:00 fsvehla: Can 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

4:02 tomoj: you can r/reduce over any seq, but you can't r/fold

4:03 you would have to create your own IO folder

4:03 well

4:03 if you just slurp the line-seq into something foldable, you can fold that...

4:08 hmm, it seems you could define a partition folder over seqs?

4:13 but it wouldn't be fork/join suitable?

4:26 leku: how do I switch namespaces?

4:26 in my nREPL

4:27 just (ns foo) ?

4:28 borkdude: leku (in-ns 'foo)

4:29 leku from the docs I see it has the same effect if the namespace already exists

4:30 leku in-ns is more low level

4:30 leku: (ns foo) seemed to work

4:30 this emacs tutorial says to do C-c C-n

4:30 can't seem to get that to work

4:30 borkdude: hmm, interesting (macroexpand '(ns foo))

4:30 leku ns also refers clojure.core for you etc

4:31 leku: cool

4:31 Raynes: I've never used in-ns in my live.

4:31 leku: C-c M-n

4:33 leku: ahH!!

4:33 that works thanks

4:33 Raynes: life*

4:33 No probs.

4:35 * leku debates going to bed

4:37 leku: (macroexpand) is good

4:40 Raynes: macroexpand is much better than bed.

4:44 leku: https://github.com/relevance/clojure-conj/wiki/Clojure-conj-2012-Unsessions

4:44 wtf? clojure powered robots??

4:44 lazybot: leku: Definitely not.

4:44 leku: when the first bot writes his own REPL, does that mean Skynet has come ONLINE?

4:44 Ember-: lazybot: you are wrong :)

4:44 borkdude: leku most of us are robots

5:38 augustl: hmm, 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

5:50 leku: hm 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

5:58 how do I say if something exists, use that, otherwise use this?

6:00 Bodil: leku: (or something this)

6:01 leku: Assuming that by "exists" you mean truthy.

6:01 leku: hm

6:01 augustl: leku: (get my-map :key default-value-here) if you mean a map

6:01 leku: well if arguments were passed to main I was gonna use that, otherwise use a default

6:01 augustl: I'd use or for that

6:02 leku: (defn -main [& args] (get-data (or (args) ("http://foo.com"))..

6:02 Bodil: Yes, missing arguments to main would be nil, so or is the way to go.

6:02 leku: k

6:02 thx

6:02 Bodil: leku: (or args "http://foo.com")

6:02 leku: Otherwise you're trying to call args as a function...

6:02 augustl: leku: that's too many parenthesis :)

6:02 leku: ah ok

6:02 augustl: and you want (first args)

6:02 leku: ah indeed

6:04 borkdude: ,(clojure.xml/parse "http://www.w3schools.com/xml/note.xml")

6:04 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.xml>

6:05 borkdude: ,*e

6:05 clojurebot: #<Unbound Unbound: #'clojure.core/*e>

6:18 mpfundstein: hello can someone help me with this? http://ideone.com/gmqWz7

6:18 my question is that if i have a if-let statement

6:18 how can i do two things afters

6:19 (if-let [name (first waiting-line)]

6:19 1. print name

6:19 2. do something else with name

6:20 raek: mpfundstein: you can use 'do' to perform multiple actions in sequence

6:20 mpfundstein: is it like ->> ?

6:20 raek: no, it doesn't thread any value through the expressions

6:21 mpfundstein: thx

6:21 do what was i was searching for

6:21 raek: it takes a bunch of expression, evaluates them left ro right, and then returns the result of the last one

6:21 borkdude: do is usually needed when side effects have to occur before returning a value

6:21 mpfundstein: borkdude: yeah, in my case just a println

6:22 is there a function like slice( ) in javascript ?

6:22 where i can slice a list/vector

6:22 borkdude: mpfundstein example input output?

6:22 mpfundstein: '("Markus", "Nina", "Anna")

6:22 i want a new list

6:22 with

6:22 raek: mpfundstein: in this case you should also use 'recur' instead of the 'process-next' after the println

6:22 mpfundstein: only ("Nina", "Anna")

6:22 Bodil: mpfundstein: You'd use drop for that.

6:23 borkdude: ,(rest '("Markus", "Nina", "Anna"))

6:23 clojurebot: ("Nina" "Anna")

6:23 raek: mpfundstein: 'rest' or 'next'

6:23 mpfundstein: Ah

6:23 ok let me test

6:23 borkdude: mpfundstein in the context of recursion it is better to use next

6:24 raek: mpfundstein: if you don't use recur you will overflow the stack if you process long lists

6:24 borkdude: mpfundstein because it returns nil on empty collections

6:24 ,(rest [])

6:24 clojurebot: ()

6:24 borkdude: ,(next [])

6:24 clojurebot: nil

6:24 mpfundstein: ok

6:24 so recur will call the current function again

6:24 raek: yes

6:24 mpfundstein: but reuse the stack ?

6:24 raek: exactly

6:24 mpfundstein: ah thats nice

6:24 thanks

6:24 (first hour in clojure)

6:25 borkdude: mpfundstein most of the time you can avoid recursion altogether by using higher order functions

6:25 raek: not bad for just one hour...

6:25 mpfundstein: recur symbol not found

6:25 ah lol sorry

6:25 forgot (

6:26 ah awesome

6:26 hehehe

6:26 it works

6:26 but one question

6:27 this works perfect: http://ideone.com/X01WZV

6:28 borkdude: ,(doseq [name '("dude" "bar" "foo")] (println name " is next"))

6:28 clojurebot: dude is next\nbar is next\nfoo is next\n

6:28 mpfundstein: ah question solved

6:28 borkdude: hihi :-) yeah

6:28 borkdude: i try to understand the language so i am building stupid test cases for myself

6:29 borkdude: mpfundstein no problem, doing good for just one hour :)

6:29 mpfundstein: (probably 2 already ;-) )

6:29 i had yesterday the vision that i must learn a lisp like language now :D

6:30 raek: mpfundstein: in your code you are not really testing for the empty list, you are testing if the first thing in the list is nil

6:31 of course an empty list does not have a first element, but clojure returns nil in that case

6:31 mpfundstein: raek: mh yeah, because it pops anway the first element each time

6:31 raek: how would you write it?

6:31 raek: anyway, your function will stop on the first nil in the list

6:31 mpfundstein: let-if (= 0 (count waiting-list))

6:31 raek: mpfundstein: like this: https://www.refheap.com/paste/11997

6:31 mpfundstein: > 0 i mean

6:32 borkdude: or use next and test for argument = nil

6:32 mpfundstein: why if and not let-if

6:32 raek: sorry, that doesn't work

6:33 mpfundstein: no

6:33 name is not defined than

6:34 i could do

6:34 raek: mpfundstein: https://www.refheap.com/paste/11998

6:34 mpfundstein: yes precisible

6:34 can one negate a if?

6:34 (if (!emtpy?

6:34 if-not probably :-)

6:34 raek: yeah

6:35 but (empty? x) = (not (seq x))

6:35 so (if (seq x) ... ...)

6:35 or (when (seq x) ...)

6:35 mpfundstein: thanks

6:35 when doenst have else

6:35 ?

6:35 ok i go on with my stuff now :D too much n00bie questions popping up :-)

6:36 raek: yeah, (when c a b c) = (if c (do a b c) nil)

6:36 mpfundstein: thanks raek and borkdude

6:36 kkk

6:36 raek: though (if c a) = (if c a nil)

6:36 borkdude: mpfundstein https://www.refheap.com/paste/11999

6:37 mpfundstein the surrounding do can be ommitted

6:37 maxalwings: What is the best CSS DSL built in Clojure?

6:37 rcg: what's "more idiomatic": "(contains? #{:foo :bar} :foo)" or "(#{:foo :bar} :foo)"?

6:37 mpfundstein: ok ok

6:37 borkdude: so: https://www.refheap.com/paste/12000

6:37 mpfundstein: no it gets a bit tricky

6:38 rcg: when used, e.g., in a cond, both work.. but what's the preferred way to do it?

6:39 borkdude: rcg (if (#{:foo :bar} :foo) :yeah :no) is a pretty common pattern I think

6:41 rcg: borkdude, i see, thx

6:41 borkdude: rcg beware of this though: (if (#{nil :foo} nil) :yeah :no)

6:42 rcg: borkdude, sure :)

6:50 borkdude: I wonder where I can find the definition of nil as a value

6:54 probably this thing? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L1873

7:00 hmm, clojure.lang.Compiler/NIL_EXPR => Unable to find static field: NIL_EXPR in class clojure.lang.Compiler

7:02 raek: borkdude: clojure nil (the value) is JVM "null". I guess you'd need to look in the JVM spec?

7:02 borkdude: raek is null a value in the JVM?

7:02 raek: yes

7:02 it is a value that all reference types contain

7:03 borkdude: raek can I add null to a set in java?

7:04 raek: aconst_null in http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings

7:04 borkdude: you can certainly pass null to Set.add()

7:05 some implementations might not allow null as an element, though

7:05 ah, from the javadocs for java.util.HashSet: "This class permits the null element."

7:07 (doto (java.util.HashSet.) (.add nil) (.add 123))

7:07 #<HashSet [null, 123]>

7:09 borkdude: ah

7:13 raek: borkdude: I think NilExpr is the abstract syntax tree node for a nil literal (so not the runtime value)

7:58 stevenyi: hi all, question: is System/arraycopy supposed to be unusable? I get: CompilerException java.lang.NoSuchFieldException:

8:02 Ember-: why would you want to use it?

8:02 are you receiving arrays from java code?

8:03 borkdude: ,(System/arraycopy (to-array [1 2 3]) 0 (to-array [0 0 0]) 0 3)

8:03 clojurebot: nil

8:03 stevenyi: i'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

8:04 borkdude : thanks, i see that i flubbed the args

8:04 looks to compile fine now

8:06 odd though that (System/arraycopy) in repo showed the error, i'm still learning clojure so am making easy mistakes still :P

8:06 repl

8:18 borkdude: is there a reader macro for java arrays?

8:19 maybe someone has made a reader thingy for this?

8:20 tomoj: there's a base64 somewher

8:20 datomic.codec/base-64-literal

8:20 for bytes

8:21 it wouldn't make a whole lot of sense to me to have a tag for java arrays in particular

8:21 corecode: is there a way to get useful callgraph profiles for jvm/clojure code? i'm just starting with clojure and am a bit lost

8:23 borkdude: corecode that would be nice to have

8:26 corecode 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

8:28 corecode: well, just something :/

8:29 also i seem to have a lot of reflection going on

8:29 but i don't know where

8:29 borkdude: corecode did you set *warn-on-reflection* to true?

8:30 (set! *warn-on-reflection* true)

8:30 (defn foo [o] (.someMethod o)) ;;=> warning

8:30 corecode: yes

8:30 not sure why i don't get many reflection warnings

8:32 but from what i see visualvm showed a lot of reflection going on

8:33 ah i think i'm profiling the wrong thing :/

8:33 trying to make sense of hadoop and cascalog

8:33 tomoj: there is interesting looking stuff in ritz

8:33 but I don't immediately see how to use it

8:35 mpfundstein: is there a meaning behind

8:35 def -function-with-a-minus

8:35 ?

8:35 defn sry

8:45 borkdude: mpfundstein defn- defines private functions

8:46 mpfundstein ie the metadata of the function has ^:private true

8:46 mpfundstein: borkdude: ok and ^ refers to the function itself?

8:46 borkdude: mpfundstein (defn- foo [] nil)

8:46 (meta #'foo) ;;=> {:arglists ([]), :ns #<Namespace user>, :name foo, :column 1, :private true, :line 1, :file "NO_SOURCE_PATH"}

8:47 mpfundstein: oh wow this is awesome didnt now the meta call

8:47 like ruby cool

8:47 borkdude: mpfundstein ^: is a shorthand notation

8:47 mpfundstein: borkdude: (def ^:dynamic v 1) ; v is a global binding

8:47 borkdude: yes

8:47 mpfundstein: borkdude: what is here different than (def v 1)

8:47 ?

8:48 borkdude: mpfundstein dynamics can be rebound with binding

8:48 mpfundstein: aaah

8:48 yeah the author shows that letter , but he doesnt explain the ^:dynamic

8:48 borkdude: mpfundstein it's called dynamic scoping

8:49 mpfundstein: aah ok i get it now

8:49 super thanks

8:49 and the 0

8:49 sry -

8:49 means that if i include my clj file somewhere else than i cant call the function

8:49 thats probably what private means in a non oop language :-)

8:52 borkdude: ,(let [s (java.io.StringWriter.)] (binding [*out* s] (println "foo") (str s)))

8:52 clojurebot: "foo\n"

8:52 borkdude: mpfundstein yes

8:52 mpfundstein you cannot refer to it from another namespace (but with some trickery you can)

8:53 mpfundstein it's more to signal that it's an implementation detail you should probably not rely on

8:53 mpfundstein: ok

8:53 thanks

9:09 Ember-: 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)

9:09 I'm guessing I should use the walk api, but not quite sure how

9:10 borkdude: Ember- get-in doesn't suffice?

9:10 Ember-: no, I don't know the sequence of keys yet

9:10 that's the problem

9:10 so I need to first find those, then use update-in or get-in

9:10 borkdude: Ember- maybe a zipper or smth? http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/

9:11 Ember-: will check, thanks

9:19 mindbender1: Raynes: how are you depending on clojurescript?

9:22 clojurescript seem to lack a concrete way of obtaining it

9:23 Am I being forced to bundle a jar for myself?

9:30 (use '[cemerick.pomegranate :only (add-dependencies)])

9:31 Ember-: 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

9:31 for example seq-zip doesn't understand maps

9:31 guess I'll look more into the walk api

9:32 borkdude: Ember- ok, yes, that's why I said "or smth" ;)

9:33 Ember-: :)

9:33 but I learned something new with that article, so thanks :)

9:35 borkdude: Ember- I'm curious about your problem and solution since with walk, can you know what the path was for the visited element?

9:36 Ember-: yeah, I'm starting to lean on the fact that I need to do this myself recursively

9:36 which seems kinda suprising, I would have guessed this is a common enough problem to be covered in core api

9:37 borkdude: Ember- more zipper examples here http://www.ibm.com/developerworks/library/j-treevisit/index.html

9:37 Ember- first some walk examples, then some tree visiting examples with zipper

9:38 Ember-: something like (find-path #(= (:id %) 123) structure) -> [:foo :bar 3]

9:38 borkdude: Ember- I think that has to be find-paths, because there could be multiple, if not all nodes are unique

9:38 Ember-: would traverse the structure, check each element with the predicate and after finding an element which matches the predicate returns a sequence of keys

9:38 borkdude: Ember- I think you can do that with zippers

9:39 Ember-: and yes, you can have multiple paths and hits in that

9:39 but was a simplified example

9:39 s/find-path/find-first-path

9:39 ;P

9:40 in my case anyway there would be only one valid path since in my data structure :id is unique

9:41 borkdude: Ember- zee zip/next

9:41 Ember-: hmm

9:41 I wonder what that documentation really means :)

9:41 will have to try

9:44 borkdude: Ember- see here http://www.ibm.com/developerworks/library/j-treevisit/index.html at listing 13 for example

9:44 Ember-: I wonder what kind of zipper I should create, seq-zip just doesn't work like it should in this case

9:45 borkdude: Ember- yes, I'm also struggling with that. I think it either assumed nested vectors or nested seqs?

9:45 Ember-: well, I have both maps and vectors/lists

9:46 like: {:id 1 :something "foo" :children []}

9:46 a single element

9:46 you can have a list of those and inside :children a list of those and so on

9:47 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

9:47 borkdude: Ember- is it like xml?

9:47 Ember-: kinda yes

9:47 borkdude: Ember- there's also xml-zip

9:47 Ember-: yeah, I looked at that

9:47 it expects results from xml/parse

9:47 but hell, let's try :)

9:48 well, that's kinda sad

9:48 borkdude: Ember- maybe worth reading http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html

9:48 Ember-: doesn't work :/

9:48 each zip traversal function returns just nil

9:49 with xml-zip

9:49 seq-zip works as long as I'm within lists

9:49 but it can't handle maps

9:50 borkdude: Ember- so you need kind of hiccup format to clojure.xml/parse output format?

9:50 Ember-: hmm, not sure I'm following you with that

9:50 like I said, all I need is a way to get that path

9:51 I could easily do that with recursion and specific functions written for that purpose

9:51 but I'm having a feeling there *has* to be a more generic way to do this (zippers look promising)

9:51 borkdude: Ember- the difference between hiccup format and clojure.xml/parse is described here https://github.com/davidsantiago/hickory

9:52 Ember- xml-zip expects the parse format, not hiccup

9:52 Ember- ah look! hickory contains hiccup-zip

9:53 Ember-: so, it just takes a bunch of maps and vectors

9:53 and creates a zipper for those

9:53 sounds promising

9:54 borkdude: Ember- 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

9:54 Ember- check for the end with zip/end?

9:54 Ember-: zip/next does that already I think?

9:55 ah no

9:55 it *returns* stuff which can be recognized with it

9:55 sounds promising

9:55 guess I'll try that out

9:55 thanks man

9:56 just a teeny bit suprised that zipper is not in the core

9:56 seems to me having a bunch of maps and lists is a really common scenario

9:59 borkdude: Ember- (loop [data (zip/seq-zip '(1 2 3))] (if (zip/end? data) "end" (do (println (zip/next data)) (recur (zip/next data)))))

10:02 Ember-: hmm... I must be using the hickory hicckup-zip wrong

10:02 since zip/next with it reaches immediately the end

10:03 * Ember- needs to read more about that zipper

10:04 borkdude: I 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:04 Ember-: those zippers are a bit confusing I got to say :)

10:05 borkdude: Ember- maybe it means that it first visited the nodes 1 2 and then 3?

10:06 no

10:08 Ember-: (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:08 true

10:08 where hick is hickory

10:08 corecode: is there a faster way than using (union set1 set2)?

10:09 borkdude: Ember- in Clojure Programming, if you have that book, there is a html zipper on page 153

10:09 Ember-: unfortunately I don't have it

10:10 well, got to go. Will continue this later today

10:10 thanks for your help borkdude, really appreciated :)

10:11 corecode: so (set (concat seq1 seq2)) is much faster than (union seq1 seq2)

10:11 is that the right idiom to use?

10:12 borkdude: Ember- no problem, I hope I'm not guiding you the wrong way

10:12 I now get what the path means

10:12 (-> (zip/vector-zip [[1] [2] [3]]) zip/down zip/down zip/path) ;;=> [[[1] [2] [3]] [1]]

10:13 it 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:14 this isn't really helping for your answer

10:17 although the path shows.. the path that is possible, not the keys for get-in

10:22 preyalone: Anyone use msysGit?

10:36 Anyone use Cygwin?

10:45 Anyone use MSYS?

10:45 Anyone use git on Windows?

10:45 OE: yeah

10:46 TimMc: ~anyone

10:47 epitron: i use cygwin + cygwin git

10:47 TimMc: clojurebot: Alive?

10:47 Looks like they left, anyhow.

11:07 jcromartie: how can I get the fully-qualified version of a symbol from a namespace… I know how to get a var with ns-resolve

11:07 ,(ns-resolve *ns* 'map)

11:07 clojurebot: #'clojure.core/map

11:07 jcromartie: but what do I do with the var?

11:08 tutysra_: 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:17 jcromartie: tutysra_: sounds like you could design that differently

11:18 tutysra_: is this one big operation that happens concurrently, or is it something that is going on sporadically

11:21 tutysra_: 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:21 all the records are inserted below the root which is created once

11:22 jcromartie: why not create the root first, then use the ID in the parallel operations

11:22 i.e. (let [root (create-root …)] (pmap #(create-child root …) child-data-coll))

11:23 hiteki: hi

11:24 jcromartie: tutysra_: well you'd have to do (doall (pmap …)) to get them all to execute in that example, specifically

11:24 imdhmd: hello all ... is there a good repl or clojure coding env for android platform?

11:25 chronno: jcromartie: Don't know if it helps, but the meta for the var has the info you need

11:26 borkdude: Ember- here I made an example with xml-zip https://www.refheap.com/paste/12007

11:26 chronno: ,(ns-name (:ns (meta (resolve 'map))))

11:26 clojurebot: clojure.core

11:26 chronno: ,(:name (meta (resolve 'map)))

11:26 clojurebot: map

11:26 borkdude: Ember- at least you can see the path it take to get to the element

11:27 Ember- you could enhance the output so the path is somewhat nicer to read

11:27 jcromartie: imdhmd: the ones I've tried all suck

11:27 chronno: thanks, that's the route I was going down

11:27 tutysra_: 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:27 borkdude: Ember- I think you should use hickory's format though and not hiccup-zip, since that one doesn't handle attributes I think

11:28 jcromartie: tutysra_: ah, I see… so the root might not yet exist

11:28 tutysra_: yeah... i won't know then until i see the data

11:30 jcromartie: tutysra_: hm, well using some kind of memoization is a pretty stateful way to do it

11:30 chronno: jcromartie, found a better one

11:30 jcromartie: tutysra_: but no, built-in memoize won't help you there

11:30 chronno: ,`map

11:30 clojurebot: clojure.core/map

11:30 imdhmd: jcromartie: yeah .. I c it wud require a specialized keyboard support. hmm

11:30 tutysra_: yeah... it didn't worked

11:31 jcromartie: tutysra_: but you could write your own memoized function

11:32 tutysra_: 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:32 *this

11:34 jcromartie: (let [cache (atom {})] (defn get-root [key] (if-let [v (get cache key)] v (get (swap! cache assoc key (create-root key)) key)))

11:34 tutysra_: looking at the source of memoize

11:34 tutysra_: p.s. I just wrote that here in IRC… don't take it as truth

11:35 tutysra_: jcromartie, sure ;-), let me try that first

11:36 jcromartie: tutysra_: oh, an important change, you should (get @cache key)

11:36 not (get cache key)

11:36 wait a sec

11:37 tutysra_: 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:37 tutysra_: it should be fine if your get-root is correct

11:38 but like I said, this all sounds kind of fishy… memoize is not really for limiting side-effects

11:38 and what happens if you run your program twice?

11:38 it's better to make everything idempotent

11:39 tutysra_: 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:40 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:40 it prints "doing some work" more than once on my system

11:41 jcromartie: tutysra_: just a sec

11:44 tutysra_: I think this is an abuse of memoize :)

11:47 tutysra_: 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:47 jcromartie: tutysra_: the problem is that the function you are memoizing can't be retried

11:48 and atoms (which memoize is built on) will retry when another thread tries to modify the atom at the same time

11:48 so pmap throws it all off

11:48 tutysra_: jcromartie, correct, i know that, i has side effects

11:48 jcromartie: better to stick with purs functions

11:48 pure functions

11:49 ,(let [a (atom 0) f (fn [_] (println "incrementing" @a) (swap! a inc))] (dorun (pmap f (range 10))) @a)

11:49 clojurebot: #<SecurityException java.lang.SecurityException: no threads please>

11:49 jcromartie: no, OK stick that in your own REPL tutysra_ :)

11:51 tutysra_: jcromartie, got your point, inc is pure

11:52 i would like to use pure functions everywhere... but can't escape here

11:52 jcromartie: tutysra_: you might be surprised… what's the bigger picture?

11:54 tutysra_: jcromartie, himmm not getting it... any hints?

11:57 jcromartie: tutysra_: can you gather up everything ahead of time before inserting it in a database?

11:57 i.e. get the structure out and then do the insert

11:59 tutysra_: 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:04 jcromartie: tutysra_: well you could do it in a couple of ways

12:04 you could use an agent to do the inserts

12:04 i.e. you do the crawling in parallel, but serialize the DB activity

12:05 but that's very side-effecty

12:06 maybe you can describe the problem

12:07 you could do an insert-or-update inside a DB transaction

12:07 clifton: have you looked at REPLACE INTO?

12:08 tutysra_: jcromartie, himm, problem is very much the same, to give more context i am using neo4j

12:08 jcromartie: ooh, nice

12:08 ah ha

12:08 that helps

12:08 tutysra_: more specifically their rest binding

12:08 jcromartie: neo4j still has transactions, and you can do the same kind of create-or-update

12:10 (I assume…)

12:10 hm yeah, CREATE UNIQUE

12:11 tutysra_: yeah...create unique seems to be a nice option... let me try that

12:20 fredyr: https://www.refheap.com/paste/12009

12:21 anybody think core.logic would be a good fit for this problem?

12:21 or other ideas?

12:28 tutysra_: jcromartie, thx, unique worked...

12:29 jcromartie: :) glad there was a simple solution waiting to be coaxed out

12:30 tutysra_: we kind of delegated this to the db :-) ... if you think of any other solution, do keep me informed

12:30 i will ping my mailid in a private msg

12:31 jcromartie: delegating it to the DB might be the best solution

12:32 in fact I'd say that's the best way to go when a DB is involved

12:32 let it do what it's designed to do

12:32 tutysra_: himm okie...

12:33 jcromartie: Clojure's concurrency is designed around Clojure's own persistent datatypes and pure functions

12:36 palango: I'm trying to get leiningen project information from a jar file, is there any api to do that?

12:40 bbloom: does (:refer-clojure :as clj) not work? what's the magic syntax there?

12:41 jeremyheiler: bbloom, I use (:require [clojure.core :as core])

12:42 bbloom: jeremyheiler: ok, that's what i'm doing, just wondering why :as doesn't work :-/

12:42 thanks tho

12:42 jeremyheiler: ,(doc refer)

12:42 clojurebot: "([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:43 jeremyheiler: refer seems to only support :exclude, :only, and :rename

12:43 Bronsa: yeah, :as is alias

12:43 bbloom: i guess that makes sense since refer-clojure delegates to refer

12:43 but i wish :as worked :-P

12:44 jeremyheiler: Well, the point of refer is to not have a namespace alias :-P

12:45 bbloom: jeremyheiler: 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:45 now i need two lines to do it :-/

12:45 i guess what i want is :require-clojure instead

12:45 which is what i often type at first, heh

12:48 jeremyheiler: That seems confusing. I would think you're trying to exlucde foo adn bar, but namespace clojure.core as clj.

12:49 I see what you're after, though.

12:52 bbloom, To get it on one line you could say (:refer-clojure :rename {foo core-foo})

12:53 bbloom: jeremyheiler: i know, but i prefer the alias, thanks tho

12:54 jeremyheiler: bbloom, heh, so do i.

14:31 * gfredericks looking through old #clojure logs and sees a reference to sexpbot

14:47 gfredericks: 31mb of #clojure logs over two years, zipped

14:53 borkdude: gfredericks nice

14:56 noncom: once 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:57 bbloom: noncom: as far as i know, that doesn't exist in clojure

14:57 gfredericks: what was technomancy's lib for that?

14:57 serialized-fn I think

14:57 wouldn't directly apply to existing functions though

14:58 borkdude: cemerick hey, I was just re-reading some part from clojurebook and I wondered: what did you use to write/edit the book

14:58 noncom: nope. it happened spontaneously. i am using CCW

14:58 muhoo: i 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:58 gfredericks: ,(doc to-array)

14:58 clojurebot: "([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."

14:58 gfredericks: ,(doc make-array)

14:58 clojurebot: "([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:58 muhoo: make-array, thanks!

14:59 borkdude: ,(apropos "array")

14:59 clojurebot: (object-array boolean-array long-array short-array char-array ...)

14:59 TimMc: gfredericks: How far do your #clojure logs go back?

14:59 gfredericks: TimMc: I just ripped from n01se, all the way back to the dawn of swearjure

14:59 cemerick: borkdude: like, for markup?

15:00 TimMc: gfredericks: Ah, OK.

15:00 borkdude: cemerick yes, the process

15:00 cemerick from text to published version

15:00 gfredericks: TimMc: only 104 mentions of "swearjure" over all time

15:00 TimMc: Unbelieveable.

15:00 You'd think it would be more. :-P

15:01 cemerick: write asciidoc -> git-svn push -> O'Reilly svn hooks convert asciidoc -> docbook -> #{:pdf :mobi :epub}

15:01 gfredericks: I'm appauled it isn't. Clearly we need to do a better job of educating the public.

15:01 TimMc: I'll put this on the agenda for the next committee meeting

15:02 borkdude: cemerick how do you write those labeled numbered balls in asciidoc?

15:03 muhoo: actually, into-array was a drop-in relacement for to-array, and did exactly what i wanted

15:03 borkdude: cemerick btw I'm going to recommend this book for my course

15:03 cemerick: borkdude: which have bidirectional anchors in the PDF :-)

15:04 borkdude: http://www.methods.co.nz/asciidoc/userguide.html#X105

15:04 borkdude: sweet! :-)

15:04 borkdude: cemerick ah I see :) do all authors use asciidoc in oreilly?

15:05 gfredericks: muhoo: I had hoped there was an easier one

15:06 cemerick: borkdude: no, most write directly in docbook

15:06 or, last I knew, anyway

15:06 Frozenlock: Hmmm.. 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:07 borkdude: cemerick tnx

15:07 cemerick: so, 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:07 borkdude: cemerick when co-writing it must be nice to use text based git approach

15:08 cemerick: it's a reasonable minimal toolchain :-)

15:09 gfredericks: Frozenlock: did you restart your repl?

15:09 Frozenlock: Yup

15:09 borkdude: cemerick I'm using org-mode now, but keeping an eye on this for future work tnx

15:10 gfredericks: Frozenlock: and you're sure you deleted my-fn from the core ns?

15:10 Frozenlock: did a `lein clean`?

15:10 Frozenlock: Yes

15:10 No

15:10 :/

15:11 gfredericks: try that and if that doesn't work start adding and removing parens at random

15:14 Frozenlock: Well 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:15 gfredericks: oh you want my-fn to be accessible from project A as if it's defined in b.core?

15:16 (also :refer takes a list)

15:16 Frozenlock: Yes. And yes, I did use a list :p

15:18 Kind of like an API if you will. Gather all the functions the user might need in a common namespace.

15:19 gfredericks: yeah that's not what refer does

15:19 I don't know if there's a standard mechanism for effecting that

15:20 there was a contrib lib that did it back in the day I think

15:22 Frozenlock: Oh... disappointment :(

15:23 gfredericks: easy enough to hack; (def my-fn #'b.subs/my-fn)

15:23 that's only mostly equivalent if it's a function

15:24 not at all equivalent if it's a constant

15:26 bbloom: gfredericks: (def my-const @#'b.subs/my-const)

15:26 :-)

15:26 breaks during interactive development tho, since it loses an indirection

15:26 gfredericks: bbloom: may as well (def my-const b.subs/my-const) then

15:27 bbloom: gfredericks: yes, i know. bad joke....

15:27 seangrove: cemerick: You mentioning working on a book with a git-like flow reminded me of Draft: http://ninjasandrobots.com/draft-preview-uber-for-writing

15:28 bbloom: gfredericks: can probably call `intern directly

15:28 hm or maybe not

15:28 would have to construct a Var by hand, private constructors and things

15:28 derekv: java -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:29 any help?

15:31 nevermind, did a clean and its fixed..

15:34 sritchie: cemerick, do you know if it's possible to sync a single view's worth of data between couchdb apps?

15:34 vs syncing the entire database

15:35 gfredericks: you can put a filter on replication

15:35 I think that's the extent of it

15:37 cemerick: seangrove: interesting, thanks!

15:38 sritchie: not AFAIK. Maybe with bigcouch?

15:38 sritchie: hmm

15:38 cemerick: I'm working on an iPhone app for users of a CouchDB app --

15:39 the idea is that they'd be able to work with a view offline

15:39 that might be too much functionality for now

15:39 maybe just speaking with the view is enough

15:39 I just don't want the app to have to download the entire view

15:40 cemerick: sritchie: well, query to limit the range you cache/store?

15:41 sritchie: it's the sync back to the app I was concerned with

15:41 but I'll probably have to do that syncing manually

15:41 I was hoping that the replication feature could handle that somehow

15:41 cemerick: well, views don't take updates anyway

15:41 sritchie: gotcha

15:41 okay, cool

15:41 cemerick: you've seen https://github.com/mikeal/pouchdb ?

15:45 derekv: how do I test that a function fails an assert if I pass it a bad parameter?

15:45 sorry very new trying to get a grip on the language and testing framework

15:46 gfredericks: derekv: with clojure.test?

15:46 seangrove: cemerick: I think https://github.com/daleharvey/pouchdb is a bit more up to date, heh

15:46 gfredericks: (is (thrown? AssertionError (my-fn some bad parameters)))

15:46 derekv: yea... maybe its (is (thrown?

15:46 gfredericks: derekv: ^ I believe more or less like that

15:46 derekv: heh

15:47 gfredericks, thanks

15:47 =]

15:47 cemerick: seangrove: ah, fair enough; mobile isn't my bag :-)

15:47 sritchie: cemerick: very cool

15:47 derekv: I hit a point I wasn't ever sure where to look online then I realized that they were just java exceptions

15:47 sritchie: cemerick: looks like replication with a filter is what I want, I think

15:48 https://github.com/couchbaselabs/TouchDB-iOS/wiki/Guide%3A-Replication

15:48 filtered replications. done.

15:49 gfredericks: derekv: and you could do something more sophisticated to expect on the msg in the error if you wanted

15:50 cemerick: sritchie: Oh, certainly. I got thrown by the view part :-)

15:50 sritchie: cemerick: yeah, my bad -- I was looking to replicate all info required to create a view for some customer

15:50 man, what a cool DB

15:50 too bad haters gonna hate :)

15:52 devlol: Hi, 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:10 ivan: did you know Sun launched a Java Store in 2009 https://www.youtube.com/watch?v=AZyHmLmPyTU that was silently killed in 2010

16:12 gfredericks: a what

16:13 ivan: an app store that would reach a billion people, presumably through the annoying updater

16:15 akhudek: oh my, those youtube comments D:

16:20 gfredericks: ooh I somehow read "brick and mortar" into that

16:20 TimMc: Java t-shirts

16:20 gfredericks: JVMs on shelves

16:21 people lining up for java 7

16:21 TimMc: reinforced shelving, of course

16:21 gfredericks: 6 foot posters with slick marketing about lambdas

16:22 and of course jeniuses trained to help you with the thorniest of NPEs

16:29 amalloy: maybe people would line up for java 7 if it had better beveled edges

16:52 * gfredericks greps irc logs for '(+(*)(*)'

16:53 hyPiRion: gfredericks: hahah

16:53 gfredericks: have to escape every damn character in that

16:53 hyPiRion: ~quicksort

16:54 amalloy: gfredericks: grep -P "\Q(+(*)(*)\E"?

16:54 i guess you'd need to escape the \ still, or use ' instead of "

16:56 gfredericks: amalloy: yes I probably should have done that

16:57 tyler_: whats the most stable/recommended irc client?

16:58 library

17:00 derekv: nothing is working first try from any examples online... =[ what the heck in wrong about this : https://www.refheap.com/paste/12013

17:01 I get unable to resolve classname Doll

17:07 gfredericks: derekv: you have to import defrecords

17:07 if you want to use their java class name

17:07 looks like in this case you could use ->Doll instead

17:07 (a function that defrecord implicitely defines for you)

17:09 derekv: can you give me an example of using ->Doll ?

17:10 gfredericks: (->Doll. expected-name expected-weight expected-value)

17:10 er

17:10 (->Doll expected-name expected-weight expected-value)

17:10 derekv: gfredericks, thanks ... do I still need the (def ?

17:11 gfredericks: on an unrelated note, there's no need for def on line 13 -- you can do that as part of the let

17:11 derekv: or do I use set

17:11 ok

17:11 sortof, had no idea what the def did

17:11 gfredericks: using def not at the top level is rarely ever what you want to do

17:11 derekv: just was looking at examples

17:12 gfredericks: a 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:12 derekv: gfredericks, that worked, thanks

17:12 gfredericks: np

17:12 derekv: yea I know some CL but wasn't familier with what def did, I thought maybe it had something to do with records specifically

17:13 so the dot in ClassName. means you want to create an instance of that java class?

17:13 gfredericks: it just makes a global thing within the namespace

17:13 yes

17:14 derekv: cool

17:24 Raynes: Man, clj-time is such an inconsistent mess.

17:25 clj-time.core/hour clj-time.core/minute (doing good so far!!!) clj-time.core/sec........

17:25 Ohai, let's name half of our functions in abbreviated form and the rest of them with the whole words!

17:26 * Raynes mutters something about 'grown men these days' and contemplates forking clj-time but knows his commits would never make it in because nobody likes changing the names of functions in widely used projects.

17:28 gfredericks: the rule is "use abbreviated whenever possible and unambiguous"

17:28 Raynes: Where is this rule?

17:29 gfredericks: I'm making shit up

17:29 Raynes: I was hoping that was the case.

17:29 gfredericks: actually 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:32 Raynes: gfredericks: I've stopped caring completely about what is and isn't in core. People need to embrace the require!

17:32 * gfredericks is all on board with that

17:33 gfredericks: (defn require! [& args] (throw (Exception. "require! is not defined. perhaps you meant `require`?")))

17:36 Raynes: gfredericks: You are a clever and amusing individual, but I can still match wits with you on any day.

17:37 In other news, wtf https://www.refheap.com/paste/12010

17:37 jcromartie: what's the simplest possible persistence approach for a really simple clojure system

17:37 Raynes: Well, how much do you need to persist?

17:37 gfredericks: Raynes: you are ten times more clever than me after normalizing for experience

17:38 Raynes: You could spit out Clojure data structures to a file and read them back later, but that obviously becomes pretty insufficient pretty fast.

17:39 ivaraasen: Raynes: seen worse

17:39 Raynes: MongoDB is extremely simple and easy to get going.

17:39 But I don't know if that qualifies as the simplest possible approach.

17:39 I'm pretty sure that just writing stuff to files is the simplest approach.

17:40 Or tell it to amalloy and ask him later.

17:40 Account for occasional data loss if he drinks to much, but that's rare.

17:40 * gfredericks wonders what sorts of exceptions amalloy throws

17:40 Raynes: too*

17:41 amalloy: LeaveMeAloneImSleepingException

17:41 Raynes: Give him a can of campbells soup and he shut down with a non zero exit code.

17:41 jcromartie: Raynes: a few dozen small hash mas

17:42 hash maps

17:42 derekv: (if (not (seq? [])) 'groan)

17:42 Raynes: Sure, you can just write that to a file and read it in later.

17:42 jcromartie: so, do the change, and then just (send-off file-writer save my-ref)

17:42 gfredericks: derekv: sequential?

17:42 jcromartie: yeah, can't get any simpler

17:43 no need for an append-only file-rotating journaled transactor :)

17:43 derekv: gfredericks, thanks again

17:45 gfredericks: np

17:46 TimMc: Raynes: Looks like someone's writing Conway's Life, but I can't tell what language they're using.

17:47 ryanf: kinda looks like one of those apl-inspired languages maybe?

17:47 amalloy: spanish, TimMc. duh

17:50 TimMc: pff

17:51 &#'clojure.core/add-doc-and-meta

17:51 lazybot: ⇒ #'clojure.core/add-doc-and-meta

17:54 alandipert: jcromartie: i made https://github.com/alandipert/enduro to use on my raspberry pi, maybe you'd enjoy it?

17:57 Frozenlock: alandipert: you used clojure on the raspberry pi?

17:57 alandipert: Frozenlock: indeed!

17:57 Frozenlock: !!

17:57 It... works? :p

17:58 Speed/memory are sufficient?

17:58 alandipert: for many neat things, yes

17:58 Frozenlock: Does it mean you need to tweak .core?

17:58 jcromartie: oh neat

17:59 alandipert: Frozenlock: nope just need to install JDK, lein as on linux

17:59 Frozenlock: Wow. Now I need a raspberry pi.

18:00 Hmm I wonder if it's easy to play with IOs via clojure.

18:00 jcromartie: Frozenlock: it's not

18:00 if you mean Apple's iOS

18:01 or do you mean like, ObjC on iOS and Clojure on a server

18:01 Frozenlock: No, I mean input/output, as on a microcontroller

18:01 jcromartie: gag gag

18:01 I mean hah hah

18:01 context :)

18:01 alandipert: neat

18:01 alandipert: Frozenlock: i did some GPIO stuff from clojure - blinked some LEDs, didn't do much more, but it's all possible afaik

18:02 Frozenlock: Nice!

18:03 * Frozenlock throws his arduino in the trash.

18:08 drewc: Frozenlock: I just got my gertboards, which means my arduino has not been used in a while!

18:08 http://www.raspberrypi.org/archives/tag/gertboard

18:14 derekv: emacs compilation buffer doesn't totally parse the lein output correctly

18:14 it doesn't always make filename - line numbers into hyperlinks

18:16 bbrittain: this mighth seem like a silly question. What is the difference between

18:17 (def nums `(1 2 3 4 ))

18:17 (def nums2 (list 1 2 3 4 ))

18:17 why can I peek on one, and not the other?

18:17 tyler_: i have a ref thats a map and i just want to update one attribute of it, what si the best function?

18:17 bbrittain: and why does "(= nums nums2)" return true then?

18:18 tyler_: (= {:foo "bar" :biz "baz"} @ref)

18:19 tomoj: &(class `(1 2 3 4))

18:19 lazybot: ⇒ clojure.lang.Cons

18:19 tomoj: &(class (next (concat (list 1 2 3) (list 4 5 6))))

18:19 lazybot: ⇒ clojure.lang.Cons

18:19 tomoj: it's not clear to me why you can't peek a Cons

18:20 oh

18:21 mmarcyzk says because an IPersistentStack has to have a count()

18:21 but he was wrong

18:23 related: https://groups.google.com/d/msg/clojure/co8lcKymfi8/CjyOPpR6FRMJ

18:24 bbrittain: tomoj, good to know other people are confused too :P

18:24 tomoj: I think mmarcyzk's last message is close to the truth

18:26 callenbot: yogthos|away: you. I like you.

18:27 tomoj: a PersistentList's rest is always IPersistentList

18:32 derekv: is there a sort of (collection? #{})

18:32 something to test that it is a collection

18:34 alandipert: derekv: coll?

18:35 derekv: alandipert, thanks

18:36 alandipert, hey we met briefly at strangeloop 2011. just before simple iirc

18:37 simple made easy rather

18:37 alandipert: derekv: oh yeah! tablemates iirc. sup :-)

18:37 derekv: =] Yea, I didn't know who Rich Hickley was when I sat down.

18:38 s\ckle\cke

18:43 Raynes: derekv: Your life was so dull up until then.

18:47 derekv: =]

18:47 Or you could say my life has been dull since then.

18:52 yogthos: callenbot: I hear I am somewhat likeable :P

19:00 callenbot: yogthos: yes but I like very few people.

19:00 yogthos: also, Zurb shit the bed.

19:00 yogthos: callenbot: ha~

19:01 callenbot: yogthos: 4.0 release of Zurb is pretty fucked.

19:01 I'm migrating over to bootstrap right now.

19:01 yogthos: yeah good plan

19:01 I recall you had your reservations about it before

19:01 callenbot: yogthos: 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:02 yogthos: most of my bad experiences centered around making substantive modifications to the nav bar

19:02 yogthos: ahh

19:02 that's the thing with frameworks, they are opinionated :)

19:02 callenbot: yogthos: sigh. you're telling me.

19:03 yogthos: oh and played with korma finally, it is nice

19:03 Ed switched luminus to use it by default now

19:03 callenbot: yogthos: I told you korma was nice.

19:03 yogthos: :)

19:03 callenbot: yogthos: it seriously understands "make a language of reusable components" even if it has a long way to go.

19:03 yogthos: yup

19:03 callenbot: also what's with the netsplit carnage lately?

19:04 yogthos: lol dunno what's up with that

19:04 callenbot: yogthos: sadly my work is in Flask/SQLAlchemy right now and will likely continue to be for awhile. I went independent, working on contract.

19:04 yogthos: going to try to use contract as runway for my own shindig.

19:04 yogthos: haha could be worse, some people actually have to work with java :P

19:05 callenbot: don't get me wrong, I like Python

19:06 yogthos: yeah there are worse things that's for sure ;)

19:06 callenbot: yogthos: by a long yard.

19:20 derekv: so, subsets is lazy, does that mean something like (filter #(tasty-combo? %) (subsets things-in-my-pantry)) is lazy?

19:24 yogthos: derekv: yeah chaining lazy functions together is lazy

19:27 derekv: yogthos, 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:28 yogthos: derekv: basically, it'll stay lazy until you force evaluation with something like doall

19:32 derekv: yogthos, very cool

19:47 amalloy: derekv: #(tasty-combo? %) is just tasty-combo?

19:47 Raynes: But feel free to wrap functions in functions in functions if it makes you happy.

19:52 derekv: I'm not sure why I wrote it that way.

19:53 That was ages ago I don't remember anymore.

19:53 I'm sure there was a good reason.

20:23 mpfundstein: does someone know how i can sum up all values of a map?

20:23 {tvod 75, svod 174647}

20:23 shall return 174722

20:23 danlarkin: (reduce + (vals ...))

20:24 hyPiRion: ,(vals {:tvod 75, :svod 174647})

20:24 clojurebot: eval service is offline

20:24 hyPiRion: uh what

20:24 mpfundstein: if i dont know the keys and dont know how much keys?

20:24 metellus: &(vals {:tvod 75, :svod 174647})

20:24 lazybot: ⇒ (174647 75)

20:24 mpfundstein: ok thanks

20:25 works perfect thanks

20:29 sorbo_: did clojure.contrib.lazy-seqs move? I don't see it listed as having migrated, but I can't lein deps it.

20:30 hyPiRion: sorbo_: which seq are you in need of?

20:30 sorbo_: hyPiRion: primes

20:31 hyPiRion: https://github.com/hyPiRion/primes/tree/0.1.0 <<

20:31 It's faster than the lazy-seq version

20:32 sorbo_: hyPiRion: awesome, thank you

20:32 hyPiRion: Documentation here: http://hypirion.github.com/primes/0.1.0/com.hypirion.primes.html

20:32 You're welcome.

20:32 :)

20:32 Raynes: Good guy hyPiRion.

20:32 Makes. Me. Sick.

20:33 hyPiRion: Raynes: Want me to be the bad guy again?

20:37 nonuby: whats the easiest way to coerce a number say it must be 1-10 so if the input is 14 it yields 10?

20:38 mattmoss: &(min 10 14)

20:38 lazybot: ⇒ 10

20:38 cgag: (min n 10)

20:38 mattmoss: &(max 1 (min 10 14))

20:38 lazybot: ⇒ 10

20:39 nonuby: thanks

20:44 bbloom: nonuby: mattmoss: for the record, that function is generally called "clamp" in game & simulation dev circles

20:45 (defn clamp [lower upper x] (max lower (min upper x)))

20:49 nonuby: thanks bbloom will remember that

20:49 mattmoss: bbloom: ya, i know... used to work in game dev

20:49 ivaraasen: hyPiRion: sup

20:49 mattmoss: Didn't think clojure had clamp in standard libs, tho. :)

20:51 hyPiRion: ivaraasen: java concurrency and horrible reflection hacks. that's up

20:51 Raynes: callenbot: http://www.youtube.com/watch?v=Wk1_wJoGV5I

20:52 ivaraasen: hyPiRion: do tell

20:54 hyPiRion: ivaraasen: techomancy/leiningen#957 is the main issue

20:55 Apparently System/in and InputStreams in general are really dirty if you want to do non-blocking stuff

20:55 http://hypirion.com/musings/how-to-cancel-a-blocking-read

20:56 akhudek: hyPiRion: I appreciate the typography on your blog

20:56 hyPiRion: It essentially boils down into a workaround for this 12 year old bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4514257

20:56 akhudek: oh, thank you

20:57 ivaraasen: hyPiRion: actually looked into this the other day by chance. then I went to bed and cried myself to sleep

20:57 hyPiRion: Yeah, that's the right way to handle it.

21:13 ravster: Are 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:17 lynaghk: ravster: there's an implementation of the haversine algorithm in c2, though it's not particularly optimized or anything

21:17 but it'll give you the great circle distance between two lat/lons on a sphere

21:18 danlarkin: I think it's safe to assume there are some nice java libs to do spatial math

21:20 ravster: lynaghk: thanks, I'll look into it.

21:37 Bronsa_: porcodio

21:37 lol

21:37 ho svegliato

21:37 mia madre

21:49 Bronsa: quanto

21:49 chap

22:10 muhoo: cosa di pazza

22:10 i present for your ridicule, this steaming pile: https://www.refheap.com/paste/12019

22:17 gfredericks: muhoo: wat it is

22:18 muhoo: hehe. i'm not quite exactly sure.

22:18 derekv: (alter max-weight Integer/parseInt input-string) -> Unable to find static field: parseInt in class java.lang.Integer

22:19 TimMc: derekv: You'll want #(Integer/parseInt %) there.

22:19 derekv: TimMc, =] sweet

22:19 TimMc: Interop forms are annoying that way.

22:19 Basically, since parseInt is a method, it has to be in a call position.

22:20 derekv: I see

22:44 How 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:49 TimMc: derekv: So, that's some fn inside a fn called input-handler inside a namespace call core. Probably.

22:49 And something is passing it two args.

22:51 derekv: I'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:53 There's probably some inbalanced paran or something, but i'm on about my 8th time checking it

22:54 i should probably just start over and rethink it

23:00 rewriting

23:00 hated it anyways

23:00 TimMc: derekv: Could it be that alter is passing 2 params to that fn literal?

23:01 That's the only inner function I see, and it's plausible...

23:01 (Macros could be introducing other fns, of course.)

23:02 derekv: the parseInt?

23:03 TimMc: yeah

23:03 derekv: although I guess that means it could be the "catch" clause, i'm sure thats macro driven

23:03 muhoo: i 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:05 TimMc: muhoo: https://github.com/timmc/pellucida/blob/master/src/org/timmc/pellucida/single.clj#L13

23:05 Raynes: muhoo: Hi.

23:06 muhoo: Raynes: yo

23:06 TimMc: thanks

23:06 TimMc: muhoo: This one is better: https://github.com/timmc/pellucida/blob/master/src/org/timmc/pellucida/pager.clj

23:07 Raynes: muhoo: I just recorded a video cover of a song for fun and I might be persuaded to let you see it.

23:07 TimMc: Basically, 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:07 muhoo: Raynes: no shit? youtube that puppy

23:08 TimMc: 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:08 instead of having try/catch crap cluttering up the code

23:08 actually no. instead of having if/throw cluttering up the code

23:09 TimMc: A really useful fn to use with pre/post is ##(doc cast)

23:09 lazybot: ⇒ "([c x]); Throws a ClassCastException if x is not a c, else returns x."

23:09 muhoo: heh, static typing!

23:09 TimMc: Ish.

23:10 derekv: so if i want to filter out the falsy things from a collection, is there a more elegant way than "(filter #(not (not %)) coll)"

23:10 TimMc: derekv: identity

23:10 &(filter identity [1 2 false true nil "hi"])

23:10 lazybot: ⇒ (1 2 true "hi")

23:11 derekv: TimMc, cool perfect

23:25 TimMc: General question about web apps: Should I show an error page when I get a malformed optional querystring parameter, or just ignore it?

23:26 Example: ?page=wtf

23:28 Raynes: TimMc: Probably ignore it.

23:29 dcolish: TimMc: thats what a 400 page is for

23:30 its best to let the client know if there's a malformed request unless there are security reasons not to

23:30 s/page/response/

23:30 i assumed page, but you could be writing a rest client for all I know

23:31 TimMc: Web page.

23:33 dcolish: imho, 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:44 amalloy: TimMc: 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

Logging service provided by n01se.net