2013-03-02
| 00:00 | TimMc | I thought perhaps I had put a board in the wrong place somewhere. |
| 00:20 | tyler_ | anyone know if you can call functions from clostache? |
| 00:20 | tyler_ | in the view |
| 00:20 | tyler_ | ah you can call lambas nice |
| 00:21 | tyler_ | n/m |
| 00:21 | tyler_ | found it |
| 00: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) |
| 00:30 | tomoj | I think I usually (apply concat (for [x some-list] (if x [x] [1 2 3]))) :( |
| 00:30 | tomoj | hmm |
| 00:30 | tomoj | (for [x some-list y (if x [x] [1 2 3])] y) ? |
| 00:31 | Frozenlock | o_O |
| 00:31 | Frozenlock | Never used `for' with more than a coll. |
| 00:33 | Frozenlock | Looks like it could work, thanks :) |
| 00:56 | leku | how do I work with .jar files and clojure? |
| 00:56 | leku | I'd like to be able to play around with this API and teach myself a little clojure at the same time |
| 00:56 | leku | (require '(USGS jar [set :as u])) |
| 00:56 | leku | not working |
| 00:58 | leku | a stackoverflow page suggests putting it int he lib folder |
| 00:59 | leku | i created a new project with lein but there is no lib dir |
| 01:07 | tomoj | which stackoverflow page? |
| 01:07 | tomoj | leku: https://github.com/technomancy/leiningen/wiki/Repeatability |
| 01:07 | tomoj | lib/ doesn't exist anymore in lein 2 |
| 01:08 | leku | ah |
| 01:08 | leku | ahh |
| 01:08 | leku | i see what they did here |
| 01: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 |
| 01:08 | leku | rgr |
| 01:33 | yedi | is clj-stripe the only stripe wrapper lib? |
| 01:39 | xeqi | yedi: I've been using clj-http to hit the api directly for a recent project |
| 01:40 | xeqi | those were the two choices I found |
| 01:40 | yedi | theres no wrapper over javas native library? |
| 01:47 | xeqi | you could just inerop with it, but I didn't find it very nice when I tried |
| 01:47 | xeqi | *interop |
| 02:19 | Frozenlock | "Cannot recur from catch/finally" Damn |
| 03: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? |
| 03: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 #((...)) |
| 03:18 | leku | how do I connect my emacs to the repl? |
| 03:18 | leku | so that when I save I can run new functions in the lein repl? |
| 03:23 | noidi | leku, maybe this guide could help? http://clojure-doc.org/articles/tutorials/emacs.html |
| 03:25 | leku | thx |
| 03:39 | leku | perfect noidi |
| 03:39 | leku | thank you |
| 03: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? |
| 03:50 | babilen | (yeah, you guessed correctly this is about the reducers library) |
| 04: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 |
| 04:02 | tomoj | you can r/reduce over any seq, but you can't r/fold |
| 04:03 | tomoj | you would have to create your own IO folder |
| 04:03 | tomoj | well |
| 04:03 | tomoj | if you just slurp the line-seq into something foldable, you can fold that... |
| 04:08 | tomoj | hmm, it seems you could define a partition folder over seqs? |
| 04:13 | tomoj | but it wouldn't be fork/join suitable? |
| 04:26 | leku | how do I switch namespaces? |
| 04:26 | leku | in my nREPL |
| 04:27 | leku | just (ns foo) ? |
| 04:28 | borkdude | leku (in-ns 'foo) |
| 04:29 | borkdude | leku from the docs I see it has the same effect if the namespace already exists |
| 04:30 | borkdude | leku in-ns is more low level |
| 04:30 | leku | (ns foo) seemed to work |
| 04:30 | leku | this emacs tutorial says to do C-c C-n |
| 04:30 | leku | can't seem to get that to work |
| 04:30 | borkdude | hmm, interesting (macroexpand '(ns foo)) |
| 04:30 | borkdude | leku ns also refers clojure.core for you etc |
| 04:31 | leku | cool |
| 04:31 | Raynes | I've never used in-ns in my live. |
| 04:31 | Raynes | leku: C-c M-n |
| 04:33 | leku | ahH!! |
| 04:33 | leku | that works thanks |
| 04:33 | Raynes | life* |
| 04:33 | Raynes | No probs. |
| 04:37 | leku | (macroexpand) is good |
| 04:40 | Raynes | macroexpand is much better than bed. |
| 04:44 | leku | https://github.com/relevance/clojure-conj/wiki/Clojure-conj-2012-Unsessions |
| 04:44 | leku | wtf? clojure powered robots?? |
| 04:44 | lazybot | leku: Definitely not. |
| 04:44 | leku | when the first bot writes his own REPL, does that mean Skynet has come ONLINE? |
| 04:44 | Ember- | lazybot: you are wrong :) |
| 04:44 | borkdude | leku most of us are robots |
| 05: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 |
| 05: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 |
| 05:58 | leku | how do I say if something exists, use that, otherwise use this? |
| 06:00 | Bodil | leku: (or something this) |
| 06:01 | Bodil | leku: Assuming that by "exists" you mean truthy. |
| 06:01 | leku | hm |
| 06:01 | augustl | leku: (get my-map :key default-value-here) if you mean a map |
| 06:01 | leku | well if arguments were passed to main I was gonna use that, otherwise use a default |
| 06:01 | augustl | I'd use or for that |
| 06:02 | leku | (defn -main [& args] (get-data (or (args) ("http://foo.com")).. |
| 06:02 | Bodil | Yes, missing arguments to main would be nil, so or is the way to go. |
| 06:02 | leku | k |
| 06:02 | leku | thx |
| 06:02 | Bodil | leku: (or args "http://foo.com") |
| 06:02 | Bodil | leku: Otherwise you're trying to call args as a function... |
| 06:02 | augustl | leku: that's too many parenthesis :) |
| 06:02 | leku | ah ok |
| 06:02 | augustl | and you want (first args) |
| 06:02 | leku | ah indeed |
| 06:04 | borkdude | ,(clojure.xml/parse "http://www.w3schools.com/xml/note.xml") |
| 06:04 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.xml> |
| 06:05 | borkdude | ,*e |
| 06:05 | clojurebot | #<Unbound Unbound: #'clojure.core/*e> |
| 06:18 | mpfundstein | hello can someone help me with this? http://ideone.com/gmqWz7 |
| 06:18 | mpfundstein | my question is that if i have a if-let statement |
| 06:18 | mpfundstein | how can i do two things afters |
| 06:19 | mpfundstein | (if-let [name (first waiting-line)] |
| 06:19 | mpfundstein | 1. print name |
| 06:19 | mpfundstein | 2. do something else with name |
| 06:20 | raek | mpfundstein: you can use 'do' to perform multiple actions in sequence |
| 06:20 | mpfundstein | is it like ->> ? |
| 06:20 | raek | no, it doesn't thread any value through the expressions |
| 06:21 | mpfundstein | thx |
| 06:21 | mpfundstein | do what was i was searching for |
| 06:21 | raek | it takes a bunch of expression, evaluates them left ro right, and then returns the result of the last one |
| 06:21 | borkdude | do is usually needed when side effects have to occur before returning a value |
| 06:21 | mpfundstein | borkdude: yeah, in my case just a println |
| 06:22 | mpfundstein | is there a function like slice( ) in javascript ? |
| 06:22 | mpfundstein | where i can slice a list/vector |
| 06:22 | borkdude | mpfundstein example input output? |
| 06:22 | mpfundstein | '("Markus", "Nina", "Anna") |
| 06:22 | mpfundstein | i want a new list |
| 06:22 | mpfundstein | with |
| 06:22 | raek | mpfundstein: in this case you should also use 'recur' instead of the 'process-next' after the println |
| 06:22 | mpfundstein | only ("Nina", "Anna") |
| 06:22 | Bodil | mpfundstein: You'd use drop for that. |
| 06:23 | borkdude | ,(rest '("Markus", "Nina", "Anna")) |
| 06:23 | clojurebot | ("Nina" "Anna") |
| 06:23 | raek | mpfundstein: 'rest' or 'next' |
| 06:23 | mpfundstein | Ah |
| 06:23 | mpfundstein | ok let me test |
| 06:23 | borkdude | mpfundstein in the context of recursion it is better to use next |
| 06:24 | raek | mpfundstein: if you don't use recur you will overflow the stack if you process long lists |
| 06:24 | borkdude | mpfundstein because it returns nil on empty collections |
| 06:24 | borkdude | ,(rest []) |
| 06:24 | clojurebot | () |
| 06:24 | borkdude | ,(next []) |
| 06:24 | clojurebot | nil |
| 06:24 | mpfundstein | ok |
| 06:24 | mpfundstein | so recur will call the current function again |
| 06:24 | raek | yes |
| 06:24 | mpfundstein | but reuse the stack ? |
| 06:24 | raek | exactly |
| 06:24 | mpfundstein | ah thats nice |
| 06:24 | mpfundstein | thanks |
| 06:24 | mpfundstein | (first hour in clojure) |
| 06:25 | borkdude | mpfundstein most of the time you can avoid recursion altogether by using higher order functions |
| 06:25 | raek | not bad for just one hour... |
| 06:25 | mpfundstein | recur symbol not found |
| 06:25 | mpfundstein | ah lol sorry |
| 06:25 | mpfundstein | forgot ( |
| 06:26 | mpfundstein | ah awesome |
| 06:26 | mpfundstein | hehehe |
| 06:26 | mpfundstein | it works |
| 06:26 | mpfundstein | but one question |
| 06:27 | mpfundstein | this works perfect: http://ideone.com/X01WZV |
| 06:28 | borkdude | ,(doseq [name '("dude" "bar" "foo")] (println name " is next")) |
| 06:28 | clojurebot | dude is next\nbar is next\nfoo is next\n |
| 06:28 | mpfundstein | ah question solved |
| 06:28 | mpfundstein | borkdude: hihi :-) yeah |
| 06:28 | mpfundstein | borkdude: i try to understand the language so i am building stupid test cases for myself |
| 06:29 | borkdude | mpfundstein no problem, doing good for just one hour :) |
| 06:29 | mpfundstein | (probably 2 already ;-) ) |
| 06:29 | mpfundstein | i had yesterday the vision that i must learn a lisp like language now :D |
| 06: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 |
| 06:31 | raek | of course an empty list does not have a first element, but clojure returns nil in that case |
| 06:31 | mpfundstein | raek: mh yeah, because it pops anway the first element each time |
| 06:31 | mpfundstein | raek: how would you write it? |
| 06:31 | raek | anyway, your function will stop on the first nil in the list |
| 06:31 | mpfundstein | let-if (= 0 (count waiting-list)) |
| 06:31 | raek | mpfundstein: like this: https://www.refheap.com/paste/11997 |
| 06:31 | mpfundstein | > 0 i mean |
| 06:32 | borkdude | or use next and test for argument = nil |
| 06:32 | mpfundstein | why if and not let-if |
| 06:32 | raek | sorry, that doesn't work |
| 06:33 | mpfundstein | no |
| 06:33 | mpfundstein | name is not defined than |
| 06:34 | mpfundstein | i could do |
| 06:34 | raek | mpfundstein: https://www.refheap.com/paste/11998 |
| 06:34 | mpfundstein | yes precisible |
| 06:34 | mpfundstein | can one negate a if? |
| 06:34 | mpfundstein | (if (!emtpy? |
| 06:34 | mpfundstein | if-not probably :-) |
| 06:34 | raek | yeah |
| 06:35 | raek | but (empty? x) = (not (seq x)) |
| 06:35 | raek | so (if (seq x) ... ...) |
| 06:35 | raek | or (when (seq x) ...) |
| 06:35 | mpfundstein | thanks |
| 06:35 | mpfundstein | when doenst have else |
| 06:35 | mpfundstein | ? |
| 06:35 | mpfundstein | ok i go on with my stuff now :D too much n00bie questions popping up :-) |
| 06:36 | raek | yeah, (when c a b c) = (if c (do a b c) nil) |
| 06:36 | mpfundstein | thanks raek and borkdude |
| 06:36 | mpfundstein | kkk |
| 06:36 | raek | though (if c a) = (if c a nil) |
| 06:36 | borkdude | mpfundstein https://www.refheap.com/paste/11999 |
| 06:37 | borkdude | mpfundstein the surrounding do can be ommitted |
| 06:37 | maxalwings | What is the best CSS DSL built in Clojure? |
| 06:37 | rcg | what's "more idiomatic": "(contains? #{:foo :bar} :foo)" or "(#{:foo :bar} :foo)"? |
| 06:37 | mpfundstein | ok ok |
| 06:37 | borkdude | so: https://www.refheap.com/paste/12000 |
| 06:37 | mpfundstein | no it gets a bit tricky |
| 06:38 | rcg | when used, e.g., in a cond, both work.. but what's the preferred way to do it? |
| 06:39 | borkdude | rcg (if (#{:foo :bar} :foo) :yeah :no) is a pretty common pattern I think |
| 06:41 | rcg | borkdude, i see, thx |
| 06:41 | borkdude | rcg beware of this though: (if (#{nil :foo} nil) :yeah :no) |
| 06:42 | rcg | borkdude, sure :) |
| 06:50 | borkdude | I wonder where I can find the definition of nil as a value |
| 06:54 | borkdude | probably this thing? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L1873 |
| 07:00 | borkdude | hmm, clojure.lang.Compiler/NIL_EXPR => Unable to find static field: NIL_EXPR in class clojure.lang.Compiler |
| 07:02 | raek | borkdude: clojure nil (the value) is JVM "null". I guess you'd need to look in the JVM spec? |
| 07:02 | borkdude | raek is null a value in the JVM? |
| 07:02 | raek | yes |
| 07:02 | raek | it is a value that all reference types contain |
| 07:03 | borkdude | raek can I add null to a set in java? |
| 07:04 | raek | aconst_null in http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings |
| 07:04 | raek | borkdude: you can certainly pass null to Set.add() |
| 07:05 | raek | some implementations might not allow null as an element, though |
| 07:05 | raek | ah, from the javadocs for java.util.HashSet: "This class permits the null element." |
| 07:07 | raek | (doto (java.util.HashSet.) (.add nil) (.add 123)) |
| 07:07 | raek | #<HashSet [null, 123]> |
| 07:09 | borkdude | ah |
| 07:13 | raek | borkdude: I think NilExpr is the abstract syntax tree node for a nil literal (so not the runtime value) |
| 07:58 | stevenyi | hi all, question: is System/arraycopy supposed to be unusable? I get: CompilerException java.lang.NoSuchFieldException: |
| 08:02 | Ember- | why would you want to use it? |
| 08:02 | Ember- | are you receiving arrays from java code? |
| 08:03 | borkdude | ,(System/arraycopy (to-array [1 2 3]) 0 (to-array [0 0 0]) 0 3) |
| 08:03 | clojurebot | nil |
| 08: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 |
| 08:04 | stevenyi | borkdude : thanks, i see that i flubbed the args |
| 08:04 | stevenyi | looks to compile fine now |
| 08:06 | stevenyi | odd though that (System/arraycopy) in repo showed the error, i'm still learning clojure so am making easy mistakes still :P |
| 08:06 | stevenyi | repl |
| 08:18 | borkdude | is there a reader macro for java arrays? |
| 08:19 | borkdude | maybe someone has made a reader thingy for this? |
| 08:20 | tomoj | there's a base64 somewher |
| 08:20 | tomoj | datomic.codec/base-64-literal |
| 08:20 | tomoj | for bytes |
| 08:21 | tomoj | it wouldn't make a whole lot of sense to me to have a tag for java arrays in particular |
| 08: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 |
| 08:23 | borkdude | corecode that would be nice to have |
| 08:26 | borkdude | 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 |
| 08:28 | corecode | well, just something :/ |
| 08:29 | corecode | also i seem to have a lot of reflection going on |
| 08:29 | corecode | but i don't know where |
| 08:29 | borkdude | corecode did you set *warn-on-reflection* to true? |
| 08:30 | borkdude | (set! *warn-on-reflection* true) |
| 08:30 | borkdude | (defn foo [o] (.someMethod o)) ;;=> warning |
| 08:30 | corecode | yes |
| 08:30 | corecode | not sure why i don't get many reflection warnings |
| 08:32 | corecode | but from what i see visualvm showed a lot of reflection going on |
| 08:33 | corecode | ah i think i'm profiling the wrong thing :/ |
| 08:33 | corecode | trying to make sense of hadoop and cascalog |
| 08:33 | tomoj | there is interesting looking stuff in ritz |
| 08:33 | tomoj | but I don't immediately see how to use it |
| 08:35 | mpfundstein | is there a meaning behind |
| 08:35 | mpfundstein | def -function-with-a-minus |
| 08:35 | mpfundstein | ? |
| 08:35 | mpfundstein | defn sry |
| 08:45 | borkdude | mpfundstein defn- defines private functions |
| 08:46 | borkdude | mpfundstein ie the metadata of the function has ^:private true |
| 08:46 | mpfundstein | borkdude: ok and ^ refers to the function itself? |
| 08:46 | borkdude | mpfundstein (defn- foo [] nil) |
| 08:46 | borkdude | (meta #'foo) ;;=> {:arglists ([]), :ns #<Namespace user>, :name foo, :column 1, :private true, :line 1, :file "NO_SOURCE_PATH"} |
| 08:47 | mpfundstein | oh wow this is awesome didnt now the meta call |
| 08:47 | mpfundstein | like ruby cool |
| 08:47 | borkdude | mpfundstein ^: is a shorthand notation |
| 08:47 | mpfundstein | borkdude: (def ^:dynamic v 1) ; v is a global binding |
| 08:47 | borkdude | yes |
| 08:47 | mpfundstein | borkdude: what is here different than (def v 1) |
| 08:47 | mpfundstein | ? |
| 08:48 | borkdude | mpfundstein dynamics can be rebound with binding |
| 08:48 | mpfundstein | aaah |
| 08:48 | mpfundstein | yeah the author shows that letter , but he doesnt explain the ^:dynamic |
| 08:48 | borkdude | mpfundstein it's called dynamic scoping |
| 08:49 | mpfundstein | aah ok i get it now |
| 08:49 | mpfundstein | super thanks |
| 08:49 | mpfundstein | and the 0 |
| 08:49 | mpfundstein | sry - |
| 08:49 | mpfundstein | means that if i include my clj file somewhere else than i cant call the function |
| 08:49 | mpfundstein | thats probably what private means in a non oop language :-) |
| 08:52 | borkdude | ,(let [s (java.io.StringWriter.)] (binding [*out* s] (println "foo") (str s))) |
| 08:52 | clojurebot | "foo\n" |
| 08:52 | borkdude | mpfundstein yes |
| 08:52 | borkdude | mpfundstein you cannot refer to it from another namespace (but with some trickery you can) |
| 08:53 | borkdude | mpfundstein it's more to signal that it's an implementation detail you should probably not rely on |
| 08:53 | mpfundstein | ok |
| 08:53 | mpfundstein | thanks |
| 09: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) |
| 09:09 | Ember- | I'm guessing I should use the walk api, but not quite sure how |
| 09:10 | borkdude | Ember- get-in doesn't suffice? |
| 09:10 | Ember- | no, I don't know the sequence of keys yet |
| 09:10 | Ember- | that's the problem |
| 09:10 | Ember- | so I need to first find those, then use update-in or get-in |
| 09:10 | borkdude | Ember- maybe a zipper or smth? http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/ |
| 09:11 | Ember- | will check, thanks |
| 09:19 | mindbender1 | Raynes: how are you depending on clojurescript? |
| 09:22 | mindbender1 | clojurescript seem to lack a concrete way of obtaining it |
| 09:23 | mindbender1 | Am I being forced to bundle a jar for myself? |
| 09:30 | mindbender1 | (use '[cemerick.pomegranate :only (add-dependencies)]) |
| 09: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 |
| 09:31 | Ember- | for example seq-zip doesn't understand maps |
| 09:31 | Ember- | guess I'll look more into the walk api |
| 09:32 | borkdude | Ember- ok, yes, that's why I said "or smth" ;) |
| 09:33 | Ember- | :) |
| 09:33 | Ember- | but I learned something new with that article, so thanks :) |
| 09: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? |
| 09:36 | Ember- | yeah, I'm starting to lean on the fact that I need to do this myself recursively |
| 09:36 | Ember- | which seems kinda suprising, I would have guessed this is a common enough problem to be covered in core api |
| 09:37 | borkdude | Ember- more zipper examples here http://www.ibm.com/developerworks/library/j-treevisit/index.html |
| 09:37 | borkdude | Ember- first some walk examples, then some tree visiting examples with zipper |
| 09:38 | Ember- | something like (find-path #(= (:id %) 123) structure) -> [:foo :bar 3] |
| 09:38 | borkdude | Ember- I think that has to be find-paths, because there could be multiple, if not all nodes are unique |
| 09: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 |
| 09:38 | borkdude | Ember- I think you can do that with zippers |
| 09:39 | Ember- | and yes, you can have multiple paths and hits in that |
| 09:39 | Ember- | but was a simplified example |
| 09:39 | Ember- | s/find-path/find-first-path |
| 09:39 | Ember- | ;P |
| 09:40 | Ember- | in my case anyway there would be only one valid path since in my data structure :id is unique |
| 09:41 | borkdude | Ember- zee zip/next |
| 09:41 | Ember- | hmm |
| 09:41 | Ember- | I wonder what that documentation really means :) |
| 09:41 | Ember- | will have to try |
| 09:44 | borkdude | Ember- see here http://www.ibm.com/developerworks/library/j-treevisit/index.html at listing 13 for example |
| 09:44 | Ember- | I wonder what kind of zipper I should create, seq-zip just doesn't work like it should in this case |
| 09:45 | borkdude | Ember- yes, I'm also struggling with that. I think it either assumed nested vectors or nested seqs? |
| 09:45 | Ember- | well, I have both maps and vectors/lists |
| 09:46 | Ember- | like: {:id 1 :something "foo" :children []} |
| 09:46 | Ember- | a single element |
| 09:46 | Ember- | you can have a list of those and inside :children a list of those and so on |
| 09:47 | Ember- | 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:47 | borkdude | Ember- is it like xml? |
| 09:47 | Ember- | kinda yes |
| 09:47 | borkdude | Ember- there's also xml-zip |
| 09:47 | Ember- | yeah, I looked at that |
| 09:47 | Ember- | it expects results from xml/parse |
| 09:47 | Ember- | but hell, let's try :) |
| 09:48 | Ember- | well, that's kinda sad |
| 09:48 | borkdude | Ember- maybe worth reading http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html |
| 09:48 | Ember- | doesn't work :/ |
| 09:48 | Ember- | each zip traversal function returns just nil |
| 09:49 | Ember- | with xml-zip |
| 09:49 | Ember- | seq-zip works as long as I'm within lists |
| 09:49 | Ember- | but it can't handle maps |
| 09:50 | borkdude | Ember- so you need kind of hiccup format to clojure.xml/parse output format? |
| 09:50 | Ember- | hmm, not sure I'm following you with that |
| 09:50 | Ember- | like I said, all I need is a way to get that path |
| 09:51 | Ember- | I could easily do that with recursion and specific functions written for that purpose |
| 09:51 | Ember- | but I'm having a feeling there *has* to be a more generic way to do this (zippers look promising) |
| 09:51 | borkdude | Ember- the difference between hiccup format and clojure.xml/parse is described here https://github.com/davidsantiago/hickory |
| 09:52 | borkdude | Ember- xml-zip expects the parse format, not hiccup |
| 09:52 | borkdude | Ember- ah look! hickory contains hiccup-zip |
| 09:53 | Ember- | so, it just takes a bunch of maps and vectors |
| 09:53 | Ember- | and creates a zipper for those |
| 09:53 | Ember- | sounds promising |
| 09: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 |
| 09:54 | borkdude | Ember- check for the end with zip/end? |
| 09:54 | Ember- | zip/next does that already I think? |
| 09:55 | Ember- | ah no |
| 09:55 | Ember- | it *returns* stuff which can be recognized with it |
| 09:55 | Ember- | sounds promising |
| 09:55 | Ember- | guess I'll try that out |
| 09:55 | Ember- | thanks man |
| 09:56 | Ember- | just a teeny bit suprised that zipper is not in the core |
| 09:56 | Ember- | seems to me having a bunch of maps and lists is a really common scenario |
| 09: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 | Ember- | since zip/next with it reaches immediately the end |
| 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 | borkdude | 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 | Ember- | true |
| 10:08 | Ember- | 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 | Ember- | well, got to go. Will continue this later today |
| 10:10 | Ember- | thanks for your help borkdude, really appreciated :) |
| 10:11 | corecode | so (set (concat seq1 seq2)) is much faster than (union seq1 seq2) |
| 10:11 | corecode | 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 | borkdude | I now get what the path means |
| 10:12 | borkdude | (-> (zip/vector-zip [[1] [2] [3]]) zip/down zip/down zip/path) ;;=> [[[1] [2] [3]] [1]] |
| 10:13 | borkdude | 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 | borkdude | this isn't really helping for your answer |
| 10:17 | borkdude | although the path shows.. the path that is possible, not the keys for get-in |
| 10:22 | preyalone | Anyone use msysGit? |
| 10:36 | preyalone | Anyone use Cygwin? |
| 10:45 | preyalone | Anyone use MSYS? |
| 10:45 | preyalone | 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 | TimMc | 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 | jcromartie | ,(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 | jcromartie | 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 | tutysra_ | 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 | jcromartie | 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 | borkdude | 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 | jcromartie | 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 | tutysra_ | *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 | jcromartie | tutysra_: looking at the source of memoize |
| 11:34 | jcromartie | 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 | jcromartie | not (get cache key) |
| 11:36 | jcromartie | wait a sec |
| 11:37 | jcromartie | 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 | jcromartie | tutysra_: it should be fine if your get-root is correct |
| 11:38 | jcromartie | but like I said, this all sounds kind of fishy… memoize is not really for limiting side-effects |
| 11:38 | jcromartie | and what happens if you run your program twice? |
| 11:38 | jcromartie | 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 | tutysra_ | 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 | tutysra_ | it prints "doing some work" more than once on my system |
| 11:41 | jcromartie | tutysra_: just a sec |
| 11:44 | jcromartie | 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 | jcromartie | and atoms (which memoize is built on) will retry when another thread tries to modify the atom at the same time |
| 11:48 | jcromartie | 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 | jcromartie | pure functions |
| 11:49 | jcromartie | ,(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 | tutysra_ | 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 | jcromartie | 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 | jcromartie | you could use an agent to do the inserts |
| 12:04 | jcromartie | i.e. you do the crawling in parallel, but serialize the DB activity |
| 12:05 | jcromartie | but that's very side-effecty |
| 12:06 | jcromartie | maybe you can describe the problem |
| 12:07 | jcromartie | 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 | jcromartie | ah ha |
| 12:08 | jcromartie | 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 | jcromartie | (I assume…) |
| 12:10 | jcromartie | 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 | fredyr | anybody think core.logic would be a good fit for this problem? |
| 12:21 | fredyr | 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 | tutysra_ | i will ping my mailid in a private msg |
| 12:31 | jcromartie | delegating it to the DB might be the best solution |
| 12:32 | jcromartie | in fact I'd say that's the best way to go when a DB is involved |
| 12:32 | jcromartie | 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 | bbloom | 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 | bbloom | 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 | bbloom | now i need two lines to do it :-/ |
| 12:45 | bbloom | i guess what i want is :require-clojure instead |
| 12:45 | bbloom | 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 | jeremyheiler | I see what you're after, though. |
| 12:52 | jeremyheiler | 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: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 | gfredericks | serialized-fn I think |
| 14:57 | gfredericks | 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 | borkdude | cemerick from text to published version |
| 15:00 | gfredericks | TimMc: only 104 mentions of "swearjure" over all time |
| 15:00 | TimMc | Unbelieveable. |
| 15:00 | TimMc | 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 | gfredericks | 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 | cemerick | borkdude: http://www.methods.co.nz/asciidoc/userguide.html#X105 |
| 15:04 | cemerick | 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 | cemerick | 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 | gfredericks | Frozenlock: did a `lein clean`? |
| 15:10 | Frozenlock | Yes |
| 15:10 | Frozenlock | No |
| 15:10 | Frozenlock | :/ |
| 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 | gfredericks | (also :refer takes a list) |
| 15:16 | Frozenlock | Yes. And yes, I did use a list :p |
| 15:18 | Frozenlock | 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 | gfredericks | I don't know if there's a standard mechanism for effecting that |
| 15:20 | gfredericks | 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 | gfredericks | that's only mostly equivalent if it's a function |
| 15:24 | gfredericks | not at all equivalent if it's a constant |
| 15:26 | bbloom | gfredericks: (def my-const @#'b.subs/my-const) |
| 15:26 | bbloom | :-) |
| 15:26 | bbloom | 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 | bbloom | hm or maybe not |
| 15:28 | bbloom | 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 | derekv | any help? |
| 15:31 | derekv | 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 | sritchie | vs syncing the entire database |
| 15:35 | gfredericks | you can put a filter on replication |
| 15:35 | gfredericks | I think that's the extent of it |
| 15:37 | cemerick | seangrove: interesting, thanks! |
| 15:38 | cemerick | sritchie: not AFAIK. Maybe with bigcouch? |
| 15:38 | sritchie | hmm |
| 15:38 | sritchie | cemerick: I'm working on an iPhone app for users of a CouchDB app -- |
| 15:39 | sritchie | the idea is that they'd be able to work with a view offline |
| 15:39 | sritchie | that might be too much functionality for now |
| 15:39 | sritchie | maybe just speaking with the view is enough |
| 15:39 | sritchie | 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 | sritchie | but I'll probably have to do that syncing manually |
| 15:41 | sritchie | 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 | sritchie | 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 | derekv | 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 | derekv | gfredericks, thanks |
| 15:47 | derekv | =] |
| 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 | sritchie | https://github.com/couchbaselabs/TouchDB-iOS/wiki/Guide%3A-Replication |
| 15:48 | sritchie | 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 | sritchie | man, what a cool DB |
| 15:50 | sritchie | 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 | gfredericks | 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 | gfredericks | 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: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 | amalloy | 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 | tyler_ | 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 | derekv | I get unable to resolve classname Doll |
| 17:07 | gfredericks | derekv: you have to import defrecords |
| 17:07 | gfredericks | if you want to use their java class name |
| 17:07 | gfredericks | looks like in this case you could use ->Doll instead |
| 17:07 | gfredericks | (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 | gfredericks | er |
| 17:10 | gfredericks | (->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 | derekv | ok |
| 17:11 | derekv | 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 | derekv | 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 | gfredericks | yes |
| 17:14 | derekv | cool |
| 17:24 | Raynes | Man, clj-time is such an inconsistent mess. |
| 17:25 | Raynes | clj-time.core/hour clj-time.core/minute (doing good so far!!!) clj-time.core/sec........ |
| 17:25 | Raynes | Ohai, let's name half of our functions in abbreviated form and the rest of them with the whole words! |
| 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: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 | Raynes | 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 | Raynes | But I don't know if that qualifies as the simplest possible approach. |
| 17:39 | Raynes | I'm pretty sure that just writing stuff to files is the simplest approach. |
| 17:40 | Raynes | Or tell it to amalloy and ask him later. |
| 17:40 | Raynes | Account for occasional data loss if he drinks to much, but that's rare. |
| 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 | jcromartie | 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 | jcromartie | 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 | TimMc | &#'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 | Frozenlock | It... works? :p |
| 17:58 | Frozenlock | 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 | Frozenlock | Hmm I wonder if it's easy to play with IOs via clojure. |
| 18:00 | jcromartie | Frozenlock: it's not |
| 18:00 | jcromartie | if you mean Apple's iOS |
| 18:01 | jcromartie | 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 | jcromartie | I mean hah hah |
| 18:01 | jcromartie | context :) |
| 18:01 | jcromartie | 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:08 | drewc | Frozenlock: I just got my gertboards, which means my arduino has not been used in a while! |
| 18:08 | drewc | http://www.raspberrypi.org/archives/tag/gertboard |
| 18:14 | derekv | emacs compilation buffer doesn't totally parse the lein output correctly |
| 18:14 | derekv | 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 | bbrittain | (def nums `(1 2 3 4 )) |
| 18:17 | bbrittain | (def nums2 (list 1 2 3 4 )) |
| 18:17 | bbrittain | 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 | tomoj | oh |
| 18:21 | tomoj | mmarcyzk says because an IPersistentStack has to have a count() |
| 18:21 | tomoj | but he was wrong |
| 18:23 | tomoj | 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 | derekv | something to test that it is a collection |
| 18:34 | alandipert | derekv: coll? |
| 18:35 | derekv | alandipert, thanks |
| 18:36 | derekv | alandipert, hey we met briefly at strangeloop 2011. just before simple iirc |
| 18:37 | derekv | 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 | derekv | s\ckle\cke |
| 18:43 | Raynes | derekv: Your life was so dull up until then. |
| 18:47 | derekv | =] |
| 18:47 | derekv | 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 | callenbot | 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 | callenbot | I'm migrating over to bootstrap right now. |
| 19:01 | yogthos | yeah good plan |
| 19:01 | yogthos | 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 | callenbot | yogthos: most of my bad experiences centered around making substantive modifications to the nav bar |
| 19:02 | yogthos | ahh |
| 19:02 | yogthos | 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 | yogthos | 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 | callenbot | 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 | derekv | That was ages ago I don't remember anymore. |
| 19:53 | derekv | 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 | mpfundstein | {tvod 75, svod 174647} |
| 20:23 | mpfundstein | 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 | mpfundstein | 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 | hyPiRion | 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 | hyPiRion | You're welcome. |
| 20:32 | hyPiRion | :) |
| 20:32 | Raynes | Good guy hyPiRion. |
| 20:32 | Raynes | 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 | bbloom | (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 | hyPiRion | Apparently System/in and InputStreams in general are really dirty if you want to do non-blocking stuff |
| 20:55 | hyPiRion | 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 | hyPiRion | 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 | lynaghk | 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 | Bronsa_ | lol |
| 21:37 | Bronsa_ | ho svegliato |
| 21:37 | Bronsa_ | mia madre |
| 21:49 | Bronsa | quanto |
| 21:49 | Bronsa | chap |
| 22:10 | muhoo | cosa di pazza |
| 22:10 | muhoo | 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 | TimMc | Basically, since parseInt is a method, it has to be in a call position. |
| 22:20 | derekv | I see |
| 22:44 | derekv | 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 | TimMc | 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 | derekv | There's probably some inbalanced paran or something, but i'm on about my 8th time checking it |
| 22:54 | derekv | i should probably just start over and rethink it |
| 23:00 | derekv | rewriting |
| 23:00 | derekv | hated it anyways |
| 23:00 | TimMc | derekv: Could it be that alter is passing 2 params to that fn literal? |
| 23:01 | TimMc | That's the only inner function I see, and it's plausible... |
| 23:01 | TimMc | (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 | muhoo | 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 | muhoo | 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 | muhoo | instead of having try/catch crap cluttering up the code |
| 23:08 | muhoo | 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 | TimMc | &(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 | TimMc | Example: ?page=wtf |
| 23:28 | Raynes | TimMc: Probably ignore it. |
| 23:29 | dcolish | TimMc: thats what a 400 page is for |
| 23:30 | dcolish | its best to let the client know if there's a malformed request unless there are security reasons not to |
| 23:30 | dcolish | s/page/response/ |
| 23:30 | dcolish | 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 |