2015-10-29
| 00:08 | Guest49090 | how to change a variable value , defined by let |
| 00:15 | jeaye | Guest49090: Do so in a loop or recurse or, if you absolutely must, use an atom. |
| 00:15 | Guest49090 | I'm writing a database query function, and the parameter is optional, how to deal with the sql condition. |
| 00:15 | Guest49090 | (defn query [& params] |
| 00:16 | Guest49090 | (jdbc/query (connection) ["select ........ "] |
| 00:16 | jeaye | Guest49090: Depends what params are. |
| 00:16 | Guest49090 | how to deal with the 'where' part, is there a library to use ? |
| 00:17 | Guest49090 | {:code "xx" :name "yy"} => "where code<@?:ltree and name like %?% |
| 00:21 | owlbird | I have tried several libs, but they doesn't support sql grammar like "?::ltree", so I have to built the sql manually |
| 00:29 | neoncontrails | owlbird: values are immutable in Clojure, so I'm not sure that there is an idiomatic way to mutate a value once it's been set |
| 00:30 | neoncontrails | You can use an atom to build the query procedurally, though |
| 00:35 | neoncontrails | owlbird: here's a quick illustration of how I might approach it |
| 00:35 | neoncontrails | (defn make-query [arg1 arg2] (let [query (atom {:value ""})] (swap! query update-in [:value] str arg1 "::" arg2))) |
| 00:35 | neoncontrails | ,(defn make-query [arg1 arg2] (let [query (atom {:value ""})] (swap! query update-in [:value] str arg1 "::" arg2))) |
| 00:35 | clojurebot | #'sandbox/make-query |
| 00:36 | neoncontrails | ,(make-query "something?" "ltree") |
| 00:36 | clojurebot | {:value "something?::ltree"} |
| 00:37 | neoncontrails | Combine with a dispatch procedure for best results |
| 01:19 | kurofune | Does anybody know why lein upgrade is says "Couldn't find project.clj, which is needed for upgrade" when I run it outside of a project? I want to upgrade it globally. |
| 04:24 | jonathanj | i don't quite understand what the value of promise-chan is, would someone mind explaining it like i'm five? |
| 04:36 | kungi | How can I format a #inst Timestamp in ClojureScript properly? |
| 04:40 | raspasov | jonathanj: it allows you to have multiple "things" (threads, go loops, etc) waiting on one thing to complete, i.e. the promise chan |
| 04:40 | raspasov | (def p-chan (promise-chan)) |
| 04:41 | ashwink005 | the for function in clojure.. gives a lazy sequence |
| 04:41 | raspasov | (>!! p-chan :cool) |
| 04:41 | raspasov | (<!! p-chan) => :cool |
| 04:41 | raspasov | (<!! p-chan) => :cool |
| 04:41 | ashwink005 | does that mean it has a caveat? |
| 04:41 | raspasov | etc, you can get :cool infinite amount of times |
| 04:41 | jonathanj | raspasov: and if you put another value? |
| 04:41 | jonathanj | does the output value change? or is that an error? |
| 04:42 | kungi | ashwink005: for is more like a list comprehension than a for loop in clojure. If you need side effects have a look at doseq |
| 04:42 | oddcully | kungi: with (.format f dt) where f is e.g. (DateTimeFormat. "yyyy-MM-dd HH:mm") |
| 04:42 | raspasov | jonathanj: (>!! p-chan :bla) => true |
| 04:42 | raspasov | but doesn't change the output |
| 04:42 | raspasov | (<!! p-chan) => :cool |
| 04:42 | kungi | oddcully: thank you |
| 04:42 | oddcully | kungi: if there is a log online for #clojurescript then there is a refheap from me two days ago |
| 04:43 | jonathanj | raspasov: i understand, thanks for explaining! |
| 04:43 | oddcully | kungi: DTF is (:import [goog.i18n DateTimeFormat]) |
| 04:43 | ashwink005 | kungi, I meant if I give it a large seq to evaluate, will it endup giving me like only 32 of the results? |
| 04:43 | ashwink005 | i.e. a lazy evaluation |
| 04:43 | kungi | ashwink005: initially yes |
| 04:44 | ashwink005 | kungi, how do I force a complete evaluation? |
| 04:44 | kungi | ashwink005: doall |
| 04:44 | ashwink005 | eeash that was simple :P thanks :) |
| 04:46 | kungi | oddcully: Do you happen to know reagent-forms a little? |
| 05:19 | lgrapenthin | how can I use a javascript library that uses require and module.exports= in ClojureScript? |
| 05:20 | lgrapenthin | i have tried foreign-libs but I get a "require is not defined" error in the console |
| 05:28 | ashwink005 | how can I create a list using network calls? |
| 05:28 | ashwink005 | calls being made using some data in another list |
| 05:33 | powered | what do you mean ashwink005 ? |
| 05:34 | ashwink005 | powered, I am confused as to what is the best method to create a sequence and return it, where network calls are required |
| 05:34 | ashwink005 | since network calls can give exceptions etc, I need to surround it in try catch |
| 05:35 | ashwink005 | and I can't recur in a try catch |
| 05:46 | powered | you can call a function and recur in that function right? then you call this function in a try-catch clause |
| 05:47 | powered | it might also be a middleware feature |
| 07:07 | necronian | I started an irc library using core.async https://gitlab.com/necronian/ircurple it wraps java socket i/o in channels and processes incoming messages with some middleware |
| 07:08 | necronian | I stalled on implementing error handling. To send a message I just put it onto the out channel which returns succees even if later the server returns an error |
| 07:09 | necronian | How, for instance would I write a command to set the user NICK and return an error if it is already taken. What I wrote in fact seems to preclude that possibility. |
| 07:19 | mungojelly | necronian: maybe like give a promise of success that's actually an error sometimes when it's realized, sounds like an awesome library btw i'd use that |
| 07:24 | kungi | Is there a function for moving keys in a map to a nested map (f {:a :b :c} [:b :c] :nested-key) => {:a :nested-key {:b :c}}? |
| 07:26 | necronian | mungojelly: I'll have to look into that, although it sounds complicated. I would probably have to keep track of a lot of state, the protocol rarely tells you if something succeeded either it worked and nothing happens or it sends an error message. |
| 07:29 | mungojelly | i'm mildly skeptical of this silence=success plan in general, maybe there should be stdsuccess |
| 07:33 | snowell | ,(defn nested [m ks nest] (reduce dissoc (assoc m nest (select-keys m ks)) ks)) ; <--- kungi |
| 07:33 | clojurebot | #'sandbox/nested |
| 07:34 | snowell | ,(nested {:a 0 :b 1 :c 2} [:b :c] :nested-key) |
| 07:34 | clojurebot | {:a 0, :nested-key {:b 1, :c 2}} |
| 07:34 | necronian | Maybe create a middleware that sends all errors to an err channel that sent messages can subscribe to. If it doesn't receive a message within a certain timeout then it succeeded. |
| 07:37 | kungi | snowell: Sweet :-) |
| 08:19 | visof | ,(into [] '(1 2 3)) |
| 08:19 | clojurebot | [1 2 3] |
| 08:19 | visof | ,(into [] '('(1 2 3) '(4 5)) |
| 08:19 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 08:19 | visof | ,(into [] '('(1 2 3) '(4 5))) |
| 08:19 | clojurebot | [(quote (1 2 3)) (quote (4 5))] |
| 08:20 | visof | ,(map #(into [] %) (into [] '('(1 2 3) '(4 5)))) |
| 08:20 | clojurebot | ([quote (1 2 3)] [quote (4 5)]) |
| 08:20 | visof | ,(map #(vec %) (into [] '('(1 2 3) '(4 5)))) |
| 08:20 | clojurebot | ([quote (1 2 3)] [quote (4 5)]) |
| 08:21 | visof | ,(map (fn [l] (into [] l)) (into [] '('(1 2 3) '(4 5)))) |
| 08:21 | clojurebot | ([quote (1 2 3)] [quote (4 5)]) |
| 08:21 | visof | how can i convert outer and inner lists to vectors? |
| 08:21 | snowell | visof: You can use mapv |
| 08:23 | Bronsa | visof: don't nest quotes like that |
| 08:36 | powered | how do I do a partial, but fill in elements at the end? |
| 08:37 | powered | so (fn f [a b]) reversed => (reverse-partial f b) => (reversed a) |
| 08:39 | algernon | #(f % b) |
| 08:40 | powered | lol so simple, why didn't I think of that |
| 08:52 | mpenet | jonathanj: it's also cheaper in many ways than a regular chan (it's not backed by a queue, makes it a lot simpler) |
| 09:03 | lxsameer | guys, how can I write this snippet using java interop ? http://dpaste.com/11XFK0P |
| 09:05 | luma | (reify XYZ (method1 [this int1] ...)) |
| 09:58 | kavkaz | What's the most idiomatic way to see if a collection contains the logical value true? |
| 09:59 | kavkaz | And most efficient |
| 10:00 | sobel | (some? true coll) |
| 10:00 | matthavener | kavkaz: (if (some true? collection) ...) |
| 10:00 | taylan | kavkaz: (contains? coll true) ? |
| 10:00 | sobel | (some? true? coll) |
| 10:00 | kavkaz | Actually I'm performing map with a function returning a logical value on a large collection |
| 10:00 | taylan | er, ignore me |
| 10:00 | taylan | .oO( they could have named that one better ) |
| 10:00 | kavkaz | Perhaps I should find a built in function that returns true as soon as it sees a logical true value |
| 10:00 | mavbozo | ,(map some? [true false nil]) |
| 10:01 | clojurebot | (true true false) |
| 10:01 | sobel | kavkaz: i think 'contains' is the wrong connotation in functional context |
| 10:01 | sobel | i mean, just destructure if you need 'contians' |
| 10:05 | kavkaz | Just ended up using (true? (some #{true} ....)) |
| 10:06 | kavkaz | Changed #{true} to true? |
| 10:17 | kavkaz | sobel: you're right the function some is best for this scenario |
| 13:20 | justin_smith | ,(some true? [:a nil true]) |
| 13:20 | clojurebot | true |
| 13:20 | justin_smith | no need for the true? / #{true} combo |
| 13:46 | sotojuan | How do I check if Agent.start_link was called? Trying to error out/send a message if it has not |
| 13:46 | sotojuan | Sorry wrong channel ~_~ |
| 14:08 | hlolli | Is it possible to create a map in project.clj and access it's values from a non-project file (core.clj) |
| 14:14 | snowell | hlolli: https://github.com/weavejester/environ |
| 14:17 | hlolli | ah thanks snowell, I did bump into this name environ few times as I was googling this. |
| 15:49 | nanuko | would there be any reason that emacs can’t find cider-debug-defun-at-point? |
| 16:47 | justin_smith | nanuko: if your cider version is old |
| 17:50 | simon1234 | Hi there! I have a question :) I'm loading a namespace manually using read/eval in a loop for every form. At any point an exception can be thrown (RunTime exception might be thrown: example unable to resolve a symbol.) Is there anyway to get which form actually threw the exception? Or to navigate the forms (like going to the parent etc.) around the one that threw it? Thanks a lot! |
| 17:55 | rhg135 | I think t.a.j exposes this but idk |
| 17:59 | simon1234 | rhg135: Thanks for your reply, what do you mean by t.a.j ? |
| 18:08 | simon1234 | hm clojure.tools.analyzer I guess |
| 18:16 | rhg135 | Yes, simon1234, that |
| 18:16 | rhg135 | The jvm one since I assumed clojure |
| 20:50 | celwell | Hello, how can I choose the best server for my production Clojure web service? (jetty, tomcat, nginx, Undertow, http-kit) |
| 20:51 | sobel | try them all |
| 21:08 | Leonidas | immutant, aleph |
| 21:39 | eraserhd | celwell: best for what purpose? |
| 21:40 | eraserhd | oh, gone huh. |
| 22:16 | BorbaGato | HELP |