Re: Past and future of data.generators
For the record, after doing some simple speed comparisons of ampling functions from Incanter, data.generators, and bigml/sampling (using Criterium, and making sure to doall lazy sequences), it appears that data.generators performs very well in some situations. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Past and future of data.generators
For the record, I just did some simple speed comparisons of sampling functions from Incanter, data.generators, and bigml/sampling, and data.generators performs very well. It was fastest in some tests. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
ANN Cassaforte 2.0.0-beta1 is released
Cassaforte [1] is a Clojure Cassandra client built around CQL 3. 2.0 is a major release that introduces breaking public API changes announced earlier [2]. Release notes: http://blog.clojurewerkz.org/blog/2014/06/07/cassaforte-2-dot-0-0-beta1-is-released/ 1. http://clojurecassandra.info 2. http://blog.clojurewerkz.org/blog/2014/04/26/major-breaking-public-api-changes-coming-in-our-projects/ -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] clecs 0.2.1
clecs is an entity-component-system written in clojure. It is not production ready but it is complete in the sense you can use it for your hobby projects. It is available in clojars. The repo is here: https://github.com/muhuk/clecs I have written a rant about it[1] but I won't crosspost it here entirely, just this bit: ...if you can take a look and at least tell me about your first impressions it would be great. I have two main questions: - Do you think having a game development library that is completely agnostic about rendering, sound inputs, i.e. doesn't provide any of these, make sense? - Do you think the API looks right? Is it idiomatic Clojure from a library user's perspective? [1]: http://blog.muhuk.com/2014/06/08/entity_component_system_in_clojure.html -- Kind Regards, Atamert Ölçgen -+- --+ +++ www.muhuk.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Search seqs in seqs
Err, this was bugging me all day when I went afk. I wrote it too quickly and am missing the case where the sub-seq starts right after seeing the first val, [:b :b :c]. Will fix it if I have time today, but may need to take a slightly different approach. Fun problem, btw. :) On Saturday, June 7, 2014 2:31:04 PM UTC-5, Alex Walker wrote: Here's a solution based on your description that behaves like core partition fns, taking liberty to presume your example should've matched the output below. (defn partition-by-seq [sub-seq coll] (letfn [(step [coll] (when-let [coll (seq coll)] (let [[run more] (split-with (partial not= (first sub-seq)) coll) [possible-match more] (split-at (count sub-seq) more)] (if (= possible-match sub-seq) (if (seq run) (cons run (cons possible-match (lazy-seq (step more (cons possible-match (lazy-seq (step more (cons (concat run possible-match) (lazy-seq (step more)))] (or (step coll) ( = (partition-by-seq [:b :c] []) () = (partition-by-seq [:b :c] [:a :d]) ((:a :d)) = (partition-by-seq [:b :c] [:a :b :c :d :a :b :c :d :a :b :c]) ((:a) (:b :c) (:d :a) (:b :c) (:d :a) (:b :c)) On Tuesday, June 3, 2014 4:05:16 AM UTC-5, Ulrich Küttler wrote: Hi, what is the preferred way to find sub-seqs in a seq? I am trying to convert [:a :b :c :d :a :b :c :d :a :b :c] into ((:a) (:b :c) (:a :d) (:b :c) (:a)) using the sub-seq (:b :c) instead of positions. partition, partition-by and the like all look at one element at a time. What I need is a search based on seqs. Are there functions that support such a search / split? Uli -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] clecs 0.2.1
I think you're reaching for mutability a little too soon. You could aim to be more functional, then leave the mutation up to atoms or megarefs. For example: (def empty-system {:entities {}, :components {}}) (let [i (java.lang.concurrent.atomic.AtomicInteger. 1) (defn new-id [] (.getAndIncrement i))) (defn add-entity [system ent-id] (assoc system :entities ent-id {}))) (defn remove-entity [system ent-id] (dissoc system :entities ent-id)) (defn component-name [component] (- component meta ::name)) (defn set-component [system ent-id component] (let [comp-name (component-name component)] (- system (assoc-in [:entities ent-id comp-name] component) (assoc-in [:components comp-name ent-id] component (defn remove-component [system ent-id comp-name] (- system (update-in [:entities ent-id] dissoc comp-name) (update-in [:components comp-name] dissoc ent-id))) This would give you a way of adding and removing entities and components, and an way of looking up components by entity, and a way of looking up all entities that adhere to a particular component. - James On 8 June 2014 13:33, Atamert Ölçgen mu...@muhuk.com wrote: clecs is an entity-component-system written in clojure. It is not production ready but it is complete in the sense you can use it for your hobby projects. It is available in clojars. The repo is here: https://github.com/muhuk/clecs I have written a rant about it[1] but I won't crosspost it here entirely, just this bit: ...if you can take a look and at least tell me about your first impressions it would be great. I have two main questions: - Do you think having a game development library that is completely agnostic about rendering, sound inputs, i.e. doesn't provide any of these, make sense? - Do you think the API looks right? Is it idiomatic Clojure from a library user's perspective? [1]: http://blog.muhuk.com/2014/06/08/entity_component_system_in_clojure.html -- Kind Regards, Atamert Ölçgen -+- --+ +++ www.muhuk.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClojureScript Clojure 1.6.0
I don't think we want cut such a release just yet. I think it would be more informative to understand what's holding people off of 1.6.0. David On Sat, Jun 7, 2014 at 4:42 PM, Joshua Ballanco jball...@circleci.com wrote: At the risk of suggesting something completely heretical… Would it be possible to declare a v0.1 release before making the cut over to 1.6? At least then, if anyone were so inclined, those stuck on Clojure v1.5.1 for whatever reason could at least submit/backport critical bug-fixes for potential v0.1.1, etc. releases going forward. On Saturday, June 7, 2014 at 4:16, David Nolen wrote: Given the feedback so far such a request seems to be in the minority. You could run a separate project for the CLJS parts. That said, is there something in the latest release (0.0-2227) that you find problematic that you can't continue with it? David On Fri, Jun 6, 2014 at 8:36 PM, Matching Socks phill.w...@gmail.com (mailto:phill.w...@gmail.com) wrote: Can a lein-cljsbuild clj+cljs project specify separate versions of Clojure for the cljs and clj parts? If not, please give it another 6 months. On Friday, June 6, 2014 10:43:42 AM UTC-4, David Nolen wrote: Future releases of ClojureScript will have a hard dependency on Clojure 1.6.0. If you have any objections, speak up now :) David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com (mailto: clojure@googlegroups.com) Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com (mailto: clojure%2bunsubscr...@googlegroups.com) For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com (mailto: clojure+unsubscr...@googlegroups.com). For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure Dev group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscr...@googlegroups.com (mailto: clojure-dev+unsubscr...@googlegroups.com). To post to this group, send email to clojure-...@googlegroups.com (mailto:clojure-...@googlegroups.com). Visit this group at http://groups.google.com/group/clojure-dev. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure Dev group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev+unsubscr...@googlegroups.com. To post to this group, send email to clojure-...@googlegroups.com. Visit this group at http://groups.google.com/group/clojure-dev. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Search seqs in seqs
https://gist.github.com/alexpw/f20c7b3ac858003e07e2 This version supports the missing case: ;; Case: false match :b, followed by true match :b :c (= (partition-by-seq [:b :c] [:a :b :b :c :e :d :a :b :c :d :a :b :c]) '((:a :b) (:b :c) (:e :d :a) (:b :c) (:d :a) (:b :c))) On Sunday, June 8, 2014 8:52:09 AM UTC-5, Alex Walker wrote: Err, this was bugging me all day when I went afk. I wrote it too quickly and am missing the case where the sub-seq starts right after seeing the first val, [:b :b :c]. Will fix it if I have time today, but may need to take a slightly different approach. Fun problem, btw. :) On Saturday, June 7, 2014 2:31:04 PM UTC-5, Alex Walker wrote: Here's a solution based on your description that behaves like core partition fns, taking liberty to presume your example should've matched the output below. (defn partition-by-seq [sub-seq coll] (letfn [(step [coll] (when-let [coll (seq coll)] (let [[run more] (split-with (partial not= (first sub-seq)) coll) [possible-match more] (split-at (count sub-seq) more)] (if (= possible-match sub-seq) (if (seq run) (cons run (cons possible-match (lazy-seq (step more (cons possible-match (lazy-seq (step more (cons (concat run possible-match) (lazy-seq (step more)))] (or (step coll) ( = (partition-by-seq [:b :c] []) () = (partition-by-seq [:b :c] [:a :d]) ((:a :d)) = (partition-by-seq [:b :c] [:a :b :c :d :a :b :c :d :a :b :c]) ((:a) (:b :c) (:d :a) (:b :c) (:d :a) (:b :c)) On Tuesday, June 3, 2014 4:05:16 AM UTC-5, Ulrich Küttler wrote: Hi, what is the preferred way to find sub-seqs in a seq? I am trying to convert [:a :b :c :d :a :b :c :d :a :b :c] into ((:a) (:b :c) (:a :d) (:b :c) (:a)) using the sub-seq (:b :c) instead of positions. partition, partition-by and the like all look at one element at a time. What I need is a search based on seqs. Are there functions that support such a search / split? Uli -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClojureScript Clojure 1.6.0
1.6.0 branch is ready to be tested http://github.com/clojure/clojurescript/tree/1.6.0, please give it a try in your projects. You can install this version of ClojureScript by * checking out the repo * git checkout 1.6.0 * ./script/install Take note of the version number that gets installed into your local Maven. Use this in version number in your project. David On Fri, Jun 6, 2014 at 10:43 AM, David Nolen dnolen.li...@gmail.com wrote: Future releases of ClojureScript will have a hard dependency on Clojure 1.6.0. If you have any objections, speak up now :) David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] dar.async - lighter, faster alternative to core.async
https://github.com/dar-clojure/async core.async is heavily focused on CSP. While CSP itself might be a good idea, it's certainly not the case that every async problem is a CSP problem. For example, you often use go block just because it allows to write non-blocking code in a regular linear fashion, not because it is a funky way to get values from channels. For such case channels are too heavy. When you have lots of async values coming from cache their impact on performance might be unacceptable. dar.async https://github.com/dar-clojure/async provides just a go block without unnecessary features. The go block itself is taken as-is. However, channels are replaced with lightweight promises and dispatches to threadpool are removed from everywhere. Go block runs synchronously (like a do block) until it hits the first async point. Then if the result is immediately available it just continues running in the current thread, otherwise the execution will be resumed on a thread that delivered result. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to debug this trace involving Korma
Thank you Sean and Zeynel! This has been really useful: lein repl = (in-ns 'guestbook.db.schema) = (require :reload 'guestbook.db.schema) = (create-tables) Le dimanche 29 décembre 2013 18:43:34 UTC-5, Zeynel a écrit : Yes, I was having problems with the emacs repl http://stackoverflow.com/questions/20828985/compilerexception-java-lang-runtimeexception-unable-to-resolve-symbol-cloju after I created the tables I did not get the error. On Sunday, December 29, 2013 6:43:59 PM UTC-4, Sean Corfield wrote: Reading that tutorial, it looks like it expects you to call (create-tables) manually via the REPL. On Sun, Dec 29, 2013 at 3:47 AM, Zeynel azey...@gmail.com wrote: The first lines of the trace says: Failure to execute query with SQL: SELECT GUESTBOOK .* FROM GUESTBOOK :: [] JdbcSQLException: Message: Table GUESTBOOK not found; SQL statement SELECT GUESTBOOK.* FROM GUESTBOOK ... I see that there is a create-guestbook-table in schema.clj (defn create-guestbook-table [] (sql/with-connection db-spec (sql/create-table :guestbook [:id INTEGER PRIMARY KEY AUTO_INCREMENT] [:timestamp :timestamp] [:name varchar(30)] [:message varchar(200)]) (sql/do-commands CREATE INDEX timestamp_index ON guestbook (timestamp which is called by create-tables function underneath it (defn create-tables creates the database tables used by the application [] (create-guestbook-table)) How can I find out why this table is not created? I copied the code from this tutorial http://www.luminusweb.net/docs/guestbook.md I am looking for help about how to read these traces and good practice to debug. This is just my first clojure project. And these are the references and line numbers to .clj files in the trace that I could find: db.clj line #21 20 (defn get-messages [] 21 (select guestbook)) home.clj line #34 33 (defn about-page [] 34(GET / [] (home-page)) The entirety of the trace is copied below: Failure to execute query with SQL: SELECT GUESTBOOK.* FROM GUESTBOOK :: [] JdbcSQLException: Message: Table GUESTBOOK not found; SQL statement: SELECT GUESTBOOK.* FROM GUESTBOOK [42102-174] SQLState: 42S02 Error Code: 42102 org.h2.jdbc.JdbcSQLException: Table GUESTBOOK not found; SQL statement: SELECT GUESTBOOK.* FROM GUESTBOOK [42102-174] DbException.java:332 org.h2.message.DbException.getJdbcSQLException DbException.java:172 org.h2.message.DbException.get DbException.java:149 org.h2.message.DbException.get Parser.java:4900 org.h2.command.Parser.readTableOrView Parser.java:1117 org.h2.command.Parser.readTableFilter Parser.java:1724 org.h2.command.Parser.parseSelectSimpleFromPart Parser.java:1832 org.h2.command.Parser.parseSelectSimple Parser.java:1718 org.h2.command.Parser.parseSelectSub Parser.java:1560 org.h2.command.Parser.parseSelectUnion Parser.java:1548 org.h2.command.Parser.parseSelect Parser.java:415 org.h2.command.Parser.parsePrepared Parser.java:289 org.h2.command.Parser.parse Parser.java:261 org.h2.command.Parser.parse Parser.java:226 org.h2.command.Parser.prepareCommand Session.java:437 org.h2.engine.Session.prepareLocal Session.java:380 org.h2.engine.Session.prepareCommand JdbcConnection.java:1138 org.h2.jdbc.JdbcConnection.prepareCommand JdbcPreparedStatement.java:70 org.h2.jdbc.JdbcPreparedStatement.init JdbcConnection.java:267 org.h2.jdbc.JdbcConnection.prepareStatement jdbc.clj:474 clojure.java.jdbc/prepare-statement RestFn.java:425 clojure.lang.RestFn.invoke AFn.java:163 clojure.lang.AFn.applyToHelper RestFn.java:132 clojure.lang.RestFn.applyTo core.clj:621 clojure.core/apply jdbc.clj:670 clojure.java.jdbc/with-query-results* db.clj:216 korma.db/exec-sql db.clj:239 korma.db/do-query[fn] jdbc.clj:302 clojure.java.jdbc/with-connection* db.clj:238 korma.db/do-query core.clj:476 korma.core/exec db.clj:21 guestbook.models.db/get-messages home.clj:12 guestbook.routes.home/home-page
a data conversion question
Is there a better way to take this... [[:a [1 2]] [:b [3 4]]] and convert it to this... [[:a 1] [:a 2] [:b 3] [:b 4]] than using a loop like this... (defn doit [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) ??? Thanks! ,boz -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
(for[[k v] [[:a [1 2]] [:b [3 4]]] n v] [k n]) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
(mapcat (fn [[k coll]] (map vector (repeat k) coll)) [[:a [1 2]] [:b [3 4]]]) = '([:a 1] [:a 2] [:b 3] [:b 4]) On Sunday, June 8, 2014 2:12:19 PM UTC-5, boz wrote: Is there a better way to take this... [[:a [1 2]] [:b [3 4]]] and convert it to this... [[:a 1] [:a 2] [:b 3] [:b 4]] than using a loop like this... (defn doit [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) ??? Thanks! ,boz -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
On Jun 8, 2014, at 3:12 PM, boz b...@cox.net wrote: Is there a better way to take this... [[:a [1 2]] [:b [3 4]]] and convert it to this... [[:a 1] [:a 2] [:b 3] [:b 4]] than using a loop like this... (defn doit [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) ??? Lots of possibilities, and your loop doesn't look to me like it's handling the ids right, but FWIW I might do something like: (defn split-key-pairs [grouped-data] (vec (apply concat (for [[key vals] grouped-data] (for [v vals] [key v]) = (split-key-pairs [[:a [1 2]] [:b [3 4]]]) [[:a 1] [:a 2] [:b 3] [:b 4]] -Lee -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
If you really want a vector, just wrap my answer with (into [] ...): (into[] (for[[k v] [[:a [1 2]] [:b [3 4]]] n v] [k n])) = [[:a 1] [:a 2] [:b 3] [:b 4]] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
Thanks for the replies!! I goofed and only gave part of my loopy solution ... here's the whole thing (defn do-one [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) (defn do-all [x] (loop [a (first x) b (rest x) result []] (if a (recur (first b) (rest b) (into result (do-one (first a) (flatten (rest a) result))) On Sunday, June 8, 2014 12:12:19 PM UTC-7, boz wrote: Is there a better way to take this... [[:a [1 2]] [:b [3 4]]] and convert it to this... [[:a 1] [:a 2] [:b 3] [:b 4]] than using a loop like this... (defn doit [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) ??? Thanks! ,boz -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Extend-protocol to numbers fails with zero in CLJS
Thanks, Logan - that helped indeed! I also saw the compiler warning about that, but wasn't quite sure what to make of it and my solution seemed to work, at least until I tested with zero... Having said this, I've never seen or heard of a `number` type and found the lowercase naming very misleading until I just browsed once more the source for cljs.core cljs.analyzer. Is there maybe some more official documentation about this too? Thanks again! K. On 7 June 2014 01:15, Logan Linn logan.l...@gmail.com wrote: It will work for 0 if you use `number` instead of `js/Number`. Generally you shouldn't extend any js/* type On Friday, June 6, 2014 9:57:38 AM UTC-7, Karsten Schmidt wrote: I'm trying to extend-protocol for numbers and various other types (incl. collections nil) in CLJS, so have been doing something like this (reduced email version): (defprotocol PDeltaEq (delta= [a b])) (extend-protocol PDeltaEq js/Number (delta= [a b] :yay) nil (delta= [_ b] (nil? b))) (delta= 1 1) ;; :yay (delta= 0 0) Error: No protocol method Foo.foo defined for type number: 0 Now I guessed, this might have something to do with JS' considering 0 as `false` somewhere in the internal protocol machinery... and I was right! Here's a relevant excerpt from the compiled protocol dispatch fn: var delta_EQ___2 = function(a, b) { if (function() { var and__3466__auto__ = a; if (and__3466__auto__) { return a.thi$ng$common$math$core$PDeltaEq$delta_EQ_$arity$2; } else { return and__3466__auto__; } }()) { return a.thi$ng$common$math$core$PDeltaEq$delta_EQ_$arity$2(a, b); } else { } }; Obviously, with the `a` arg being 0, that `if (and__3466__auto__)` check is always failing, so shouldn't this check be rewritten as: if (goog.isDefAndNotNull(and__3466__auto__) a.thi$ng$common$math$core$PDeltaEquals$delta_EQ_$arity$2) { return a.thi$ng$common$math$core$PDeltaEquals$delta_EQ_$arity$2; } ... This change seems to fix this kind of error and AFAIK doesn't impact any of my other (30+) test cases for this protocol... Thoughts? :) Thanks, K. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Karsten Schmidt http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: a data conversion question
Wow! 'for' is a powerful thing!! This is perfect! On Sunday, June 8, 2014 12:32:44 PM UTC-7, François Rey wrote: (for [[k v] [[:a [1 2]] [:b [3 4]]] n v] [k n]) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Search seqs in seqs
This is sweet. Thanks a lot Linus and Alex. So there is no function to do it, you just have to build it yourself. I was not sure of that. I like Alex's solution. This is something I can read and understand. Also, it would be nice to compare and split in one loop. This is what I came up with, based on Alex's work: (defn partition-by-seq [sub-seq coll] (letfn [(take-sub-seq [coll] (loop [[fcoll rcoll] (seq coll) [fsub rsub] (seq sub-seq)] (if (= fcoll fsub) (if (nil? rsub) [sub-seq rcoll] (if rcoll (recur rcoll rsub) [nil coll])) [nil coll]))) (step [coll] (loop [run [] coll (seq coll)] (let [[match more] (take-sub-seq coll)] (if match (if (seq run) (cons run (cons match (lazy-seq (step more (cons match (lazy-seq (step more (if (seq coll) (recur (conj run (first coll)) (drop 1 coll)) (when (seq run) [run]) )] (if (seq sub-seq) (step coll) [coll]))) ;; Case: empty sub-seq (= (partition-by-seq [] [:a]) '([:a])) ;; Case: empty coll (= (partition-by-seq [:b :c] []) nil) ;; Case: no match (= (partition-by-seq [:b :c] [:a :d]) '([:a :d])) ;; Case: example input (= (partition-by-seq [:b :c] [:a :b :c :d :a :b :c :d :a :b :c]) '((:a) (:b :c) (:d :a) (:b :c) (:d :a) (:b :c))) ;; Case: false match :b, followed by true match :b :c (= (partition-by-seq [:b :c] [:a :b :b :c :e :d :a :b :c :d :a :b :c]) '((:a :b) (:b :c) (:e :d :a) (:b :c) (:d :a) (:b :c))) ;; Case: non-matched remainder (= (partition-by-seq [:b :c] [:a :b :c :b]) '([:a] [:b :c] [:b])) ;; Case: handle nil gracefully (= (partition-by-seq [:b nil nil] [:a :b nil nil :c :b]) '([:a] [:b nil nil] [:c :b])) On Sun, Jun 8, 2014 at 6:27 PM, Alex Walker alex.wal...@answers.com wrote: https://gist.github.com/alexpw/f20c7b3ac858003e07e2 This version supports the missing case: ;; Case: false match :b, followed by true match :b :c (= (partition-by-seq [:b :c] [:a :b :b :c :e :d :a :b :c :d :a :b :c]) '((:a :b) (:b :c) (:e :d :a) (:b :c) (:d :a) (:b :c))) On Sunday, June 8, 2014 8:52:09 AM UTC-5, Alex Walker wrote: Err, this was bugging me all day when I went afk. I wrote it too quickly and am missing the case where the sub-seq starts right after seeing the first val, [:b :b :c]. Will fix it if I have time today, but may need to take a slightly different approach. Fun problem, btw. :) On Saturday, June 7, 2014 2:31:04 PM UTC-5, Alex Walker wrote: Here's a solution based on your description that behaves like core partition fns, taking liberty to presume your example should've matched the output below. (defn partition-by-seq [sub-seq coll] (letfn [(step [coll] (when-let [coll (seq coll)] (let [[run more] (split-with (partial not= (first sub-seq)) coll) [possible-match more] (split-at (count sub-seq) more)] (if (= possible-match sub-seq) (if (seq run) (cons run (cons possible-match (lazy-seq (step more (cons possible-match (lazy-seq (step more (cons (concat run possible-match) (lazy-seq (step more)))] (or (step coll) ( = (partition-by-seq [:b :c] []) () = (partition-by-seq [:b :c] [:a :d]) ((:a :d)) = (partition-by-seq [:b :c] [:a :b :c :d :a :b :c :d :a :b :c]) ((:a) (:b :c) (:d :a) (:b :c) (:d :a) (:b :c)) On Tuesday, June 3, 2014 4:05:16 AM UTC-5, Ulrich Küttler wrote: Hi, what is the preferred way to find sub-seqs in a seq? I am trying to convert [:a :b :c :d :a :b :c :d :a :b :c] into ((:a) (:b :c) (:a :d) (:b :c) (:a)) using the sub-seq (:b :c) instead of positions. partition, partition-by and the like all look at one element at a time. What I need is a search based on seqs. Are there functions that support such a search / split? Uli -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the
Re: a data conversion question
Yet another way: (reduce #(let [[k [v1 v2]] %2] (vec (concat % [[k v1]] [[k v2]]))) [] [[:a [1 2]] [:b [3 4]]]) On Jun 8, 2014, at 3:43 PM, boz b...@cox.net wrote: Thanks for the replies!! I goofed and only gave part of my loopy solution ... here's the whole thing (defn do-one [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) (defn do-all [x] (loop [a (first x) b (rest x) result []] (if a (recur (first b) (rest b) (into result (do-one (first a) (flatten (rest a) result))) On Sunday, June 8, 2014 12:12:19 PM UTC-7, boz wrote: Is there a better way to take this... [[:a [1 2]] [:b [3 4]]] and convert it to this... [[:a 1] [:a 2] [:b 3] [:b 4]] than using a loop like this... (defn doit [id v] (loop [a (first v) r (rest v) result []] (if a (recur (first r) (rest r) (conj result [id a])) result))) ??? Thanks! ,boz -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Is there a zero-to-hero guide regarding clj-http (or its alternatives) and making API calls with google apps?
Hi! Using gcal https://github.com/owainlewis/gcal, I have been able to authenticate with OAuth2 (for my first time!) and use it's provided function to create a quick-event. I'd like to extend the functionality to create a more complicated event, but I get an API parse error from Google when I try to make the POST. What really needs to happen here is a deeper understanding of making the API call. I'm starting to get a slight grasp, but not enough to wield something like clj-http on its own and make an API call to anywhere. Cheers -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
clj-commons-exec/sh adding newline to command
(ns gh1.tmp (:require [clj-commons-exec :as exec] [clj-time.core :as t])) (defn calc [day month year hour min sec zone] (let [bin /Users/zephyr/html/astro/bin/swetest data (str -p0123456789t -fPZl -b day . month . year -ut hour : min) flags -roundmin -head -true -eswe] (exec/sh [bin data flags]))) gh1.tmp @(calc 31 11 1967 16 45 0 Europe/London) {:exit 1, :out illegal option -roundmin -head -true -eswe\n, :err nil, :exception #ExecuteException org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)} Why has exec/sh added a newline to the command line? How to get rid of it? gvim -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.