shorter alternatives for `comp' and `partial'
Hi, I find myself frequently using the `comp' and `partial' functions and while I really enjoy being able to program in a point free style, the length (in characters) of these command names often has the effect of causing what should be a brief statement to span multiple lines. I'm about to begin starting all of my clojure namespaces with (def o comp) ; o for cOmp, Haskell's (.) or Mathematical composition \circ (def p partial) ; p for partial However, I'm worried that this could limit the readability of my code, and given that this issue has (sort of) come up previously [1] [2], I figured I'd ask... Is there any support for including these function aliases for `comp' and `partial' (or some other shortened names) in the core? Best -- Eric Footnotes: [1] http://groups.google.com/group/clojure/msg/f41f9866dc736077 [2] http://groups.google.com/group/clojure/msg/29ce4786c9cef754 -- 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
Re: (:multiplexing clojure.contrib.sql = nil?)
Not sure what you meant by multiplexing? Did you mean "concurrent execution" of SQL statements on the same connection? Regards, Shantanu On Nov 14, 4:00 am, Daniel Bell wrote: > I'm just getting my feet wet w/clojure's sql library, and I got to > wondering---is multiplexing implemented in a library somewhere? Or is > it already part of contrib.sql but executed behind the scenes? > > Thanks, > > ---Dan -- 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
Incorrect behaviour for large s-expressions :(
So my friend and I were screwing around, battling versions of LISP as nerds are wont to do, when I came across this: (eval `(clojure.core/+ ~@(take 1e4 (iterate inc 1 Invalid method Code length 89884 in class file user$eval13607 This is just trying to evaluate + directly on a bunch of arguments. Common Lisp on my friend's 30 year old Lisp machine does the equivalent of this with ease, even for much larger numbers. As I'm writing this, my "friend" is rubbing in this in my face by also doing the above with C-LISP on his laptop. (although his stack overflows for 1e5) I'm losing my battle!!! :( Pls. help! --Robert McIntyre -- 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
Re: Simple Neural Network DSL -- request for feedback
You might also consider using your DSL as a frontend to the Nengo neural simulator (http://nengo.ca). Nengo (which is written in Java) has recently added a Python scripting interface (http://www.frontiersin.org/neuroinformatics/ 10.3389/neuro.11/007.2009/abstract). Nengo has a lot to recommend it and is pretty mature, so you may save yourself a lot of effort under the covers - also the way Nengo conceptualises the neyworks might be useful feedback to your DSL design. Ross On Nov 14, 5:18 am, "Eric Schulte" wrote: > Hi Ross, > > > > #+begin_src clojure > (let [n {:phi identity > :accum (comp (partial reduce +) (partial map *)) > :weights [2 2 2]}] > [(repeat 3 n) (repeat 5 n) (assoc n :weights (vec (repeat 5 1)))]) > #+end_src > > would result in the following connection pattern > > [[file:/tmp/layers.png]] > > layers.png > 45KViewDownload > > > > > However, for other NNs you may care about the topological organisation > > of the neurons in a 1-D, 2-D, or 3-D space in order to do things like > > connecting corresponding neurons in different layers or having the > > probability of a connection be a function of the separation of the > > neurons. In this case, you might use a data structure representing > > the coordinates of each neuron as its key. > > Fully agreed, I'm partway through implementing what you've just > described (at least as I understand it), in that the library now > declares a new "Graph" data type which consists of a list of > keys->Neural mappings as well as a directed edge set. Using this new > data type it is possible to construct, run and train arbitrarily > connected graphs of Neural elements. See the fourth example > athttp://repo.or.cz/w/neural-net.git > > Best -- Eric > > > > > > > Ross- Hide quoted text - > > - Show quoted text - > > Ross Gayler writes: > > On Nov 13, 9:12 am, "Eric Schulte" wrote: > >> Albert Cardona writes: > > >> > Your neural network DSL looks great. One minor comment: why use lists > >> > instead of sets? ... > > >> I used lists because I want to be able to specify a network in which (at > >> least initially) all neurons in a hidden layer are identical e.g. the > >> list example athttp://cs.unm.edu/~eschulte/src/neural-net/. > > > You might want to consider maps. > > Currently I'm using maps to specify a single neuron, and I fear it would > add complexity to have two different meanings for maps. > > > For some NN models all you care about is that each neuron has a unique > > identity (in which case using an index value as a key is as good a > > solution as any). > > I'm currently using lists only for fully connected layers in a neural > network, e.g. the following code -- 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
(:multiplexing clojure.contrib.sql = nil?)
I'm just getting my feet wet w/clojure's sql library, and I got to wondering---is multiplexing implemented in a library somewhere? Or is it already part of contrib.sql but executed behind the scenes? Thanks, ---Dan -- 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
Re: Newbie question on defstructs
yeah, I think records are the best approach, but I just struggle with them. Unfortunately I need an article or 2 on these to really get them. Last time I tried I was pretty unsuccessful. On Nov 13, 11:41 am, Chris Maier wrote: > Another approach would be to use records and protocols: > > (defprotocol HasCees > (c [this] "Returns a 'c'")) > > (defrecord Foo [a b] > HasCees > (c [this] > (+ (:a this) (:b this > > Now, to use it: > > user> (def my-foo (Foo. 1 2) > #'user/my-foo > user> (c my-foo) > 3 > > This is practically a drop-in replacement for the struct-based code > (since Clojure records behave like maps). I think with the advent of > records, there isn't really any reason to use structs anymore. Also, > this is arguably more fitting with the semantics you have, as the "c" > is more of a behavior than a value. > > It's also common to have a factory function to create record instances > (just as Michel showed with structs), like this: > > (defn make-a-foo [a b] > (Foo. a b)) > > This helps to make dealing with the positional constructors of records > a bit less awkward. > > Here's some links:http://clojure.org/datatypeshttp://clojure.org/protocols > > Hope that helps, > Chris > > On Sat, Nov 13, 2010 at 11:48 AM, Michel Alexandre Salim > > > > > > > > wrote: > > On Sat, 13 Nov 2010 06:31:03 -0800, garf wrote: > > >> If I have a struct whose creation will require some function calls that > >> references some of its members, I am unsure how to go about it in a > >> clean way. For example: > >> (defstruct tz :a :b :c) > > >> (def tz1 1 2 (+ (:a tz1) (:b tz1)) > > > Could you give a more realistic example of how you plan to use this? > > > If the only restriction is that you only know the values for :a and :b at > > the time you want to create the structure, then this would work: > > > (defn create-tz [a-val b-val] > > (struct-map tz :a a-val :b b-val :c (some-fn a-val b-val))) > > >> will not work, but reflects the problem. Ideally at the end of this I > >> could do (:c tz1) and get 3 back. Any suggestions? Originally I had > >> used assocs, but that runs into the immutability problem, for example > > >> (defstruct tz :a :b) > >> (def tz1 1 2) > >> (assoc tz1 :c (+ (:a tz1) (:b tz1)) > > >> does not actually update tz1 > > > Correct. Values are immutable, and in Clojure, even collections are > > values! > > > If you want to have a variable hold a reference to some changing values > > then what you want is to use an atom or a ref. Atom is more easy to use, > > and unless you have several mutable values that need concurrent updating, > > is sufficient, so here's an example: > > >> (def tz1 (atom (struct-map tz :a 1 :b 2))) > > #'user/tz1 > >> @tz1 > > {:a 1, :b 2, :c nil} > >> (swap! tz1 #(assoc % :c (+ (:a %) (:b % > > {:a 1, :b 2, :c 3} > >> @tz1 > > {:a 1, :b 2, :c 3} > > > Hope that helps, > > > -- > > Michel Alexandre Salim > > Clojure contributor:http://clojure.org/contributing > > GPG key ID: 78884778 > > > µblog:http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de > > http://twitter.com/hircus| IRC: hir...@irc.freenode.net > > > () ascii ribbon campaign - against html e-mail > > /\ www.asciiribbon.org - against proprietary attachments > > > -- > > 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 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
Re: Newbie question on defstructs
thanks Michel, the more realistic form was quite a bit longer, but i will show just a piece of my (mis)direction (defstruct Ruleform-struct :rname :rule-seq :if-cnt :then-cnt ) (defn rule-if-names [{:keys [ rule-seq if-cnt ] :as ruleform } ] ; (Camoflage Spotted Cover Action Use-Cover) ;==> (Camoflage Spotted Cover) (assoc ruleform :if-names (take if-cnt rule-seq)) ) : : (defn rule-col-multiply [{:keys [ col-vectors ] :as ruleform } ] ; determine necessary increment for col counts to insure unique lookup sums ; column unique items: [ 4 3 8 ] --index increments--> [1 4 12] (assoc ruleform :col-multiply (->> (reductions * (map count col-vectors)) (cons 1) (drop-last so basically I was trying to add about 7 additional attributes after the initial creation. This was a part of a fuzzy state/rule engine that was compiled for high speed, thought I would port from my original Smalltalk version to Clojure. Well 'port' is the wrong word, rewrite in a functional manner. I should use defrecord, but it gave me fits first time I tried, so am keeping it simple for now. thanks for the input & any further advice On Nov 13, 10:48 am, Michel Alexandre Salim wrote: > On Sat, 13 Nov 2010 06:31:03 -0800, garf wrote: > > If I have a struct whose creation will require some function calls that > > references some of its members, I am unsure how to go about it in a > > clean way. For example: > > (defstruct tz :a :b :c) > > > (def tz1 1 2 (+ (:a tz1) (:b tz1)) > > Could you give a more realistic example of how you plan to use this? > > If the only restriction is that you only know the values for :a and :b at > the time you want to create the structure, then this would work: > > (defn create-tz [a-val b-val] > (struct-map tz :a a-val :b b-val :c (some-fn a-val b-val))) > > > will not work, but reflects the problem. Ideally at the end of this I > > could do (:c tz1) and get 3 back. Any suggestions? Originally I had > > used assocs, but that runs into the immutability problem, for example > > > (defstruct tz :a :b) > > (def tz1 1 2) > > (assoc tz1 :c (+ (:a tz1) (:b tz1)) > > > does not actually update tz1 > > Correct. Values are immutable, and in Clojure, even collections are > values! > > If you want to have a variable hold a reference to some changing values > then what you want is to use an atom or a ref. Atom is more easy to use, > and unless you have several mutable values that need concurrent updating, > is sufficient, so here's an example: > > > (def tz1 (atom (struct-map tz :a 1 :b 2))) > #'user/tz1 > > @tz1 > > {:a 1, :b 2, :c nil}> (swap! tz1 #(assoc % :c (+ (:a %) (:b % > {:a 1, :b 2, :c 3} > > @tz1 > > {:a 1, :b 2, :c 3} > > Hope that helps, > > -- > Michel Alexandre Salim > Clojure contributor:http://clojure.org/contributing > GPG key ID: 78884778 > > µblog:http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de > http://twitter.com/hircus| IRC: hir...@irc.freenode.net > > () ascii ribbon campaign - against html e-mail > /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Printing a table of data
print-table was actually just added to the master branch: https://github.com/clojure/clojure/commit/826ff8486fb3e742cea80ebc43d93afbd85b52d9 Justin On Nov 13, 1:02 pm, Shantanu Kumar wrote: > Does anybody know if a standard 'print-table' kind of function exists > in some library? Maybe if somebody can give an example of printing a > table using cl-format or pprint. > > Regards, > Shantanu -- 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
Re: Error in 1.3 alpha 3 - "Only long and double primitives are supported"
On Mon, 08 Nov 2010 14:14:16 -0500, lprefontaine wrote: > Sticking to long and double gets away from Java semantic but it is done > to improve numeric performances. You can actually hint in 1,3 on the > return type of a function to avoid automatic boxing and have your code > work entirely with a "native" type. Boxing if I recall correctly will > convert systematically to BigDecimal. > > Any computation could then be carried on, even if it does not fit in one > of the "native" types (long or double). > > If you work explicitly with longs or doubles, it's at the expense of > (potential) overflow exceptions. If you have a intense numeric > computations it is assumed that you know about these potential limits. > > As for the syntax to pass bytes, ints, ... to Java, I cannot recall the > exact syntax to do it but it should be similar to type hints used in > 1.2. > > No idea if the Conj videos are available yet... > They don't seem to be mentioned on http://clojure-conj.org/ -- and http:// clojure.blip.tv/ has been mostly inactive. Could we see more videos posted on blip.tv? I like how you can actually download the original video files from there (and revver, and vimeo; unlike YouTube, bah -- officially, anyway). -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Being "not Lisp" is a feature?
On Tue, 09 Nov 2010 12:08:35 -0500, David Sletten wrote: > I don't want to start any language wars, but this is funny: > http://gosu-lang.org/comparison.shtml > I love the part where it claims Scala has "solid IDE tooling". Ever since 2.8.0 comes out the Eclipse plugin auto-completion is broken. Ensime on Emacs works fine, yes, but so does clojure-mode and swank-clojure. -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Being "not Lisp" is a feature?
On Thu, 11 Nov 2010 06:01:55 -0800, Shantanu Kumar wrote: > And then comes this (Paul Stadig's tweet, RT by Stuart Sierra :) > > http://language-comparison.s3.amazonaws.com/comparison.html > >> Not Not Lisp (Ruby/Python/Java) Though actually, in Lisp dialects double-negation of something is just true, not the original item :) user> (not (not 'lisp)) true -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Simple Neural Network DSL -- request for feedback
#+begin_src clojure (let [n {:phi identity :accum (comp (partial reduce +) (partial map *)) :weights [2 2 2]}] [(repeat 3 n) (repeat 5 n) (assoc n :weights (vec (repeat 5 1)))]) #+end_src would result in the following connection pattern [[file:/tmp/layers.png]] > However, for other NNs you may care about the topological organisation > of the neurons in a 1-D, 2-D, or 3-D space in order to do things like > connecting corresponding neurons in different layers or having the > probability of a connection be a function of the separation of the > neurons. In this case, you might use a data structure representing > the coordinates of each neuron as its key. > Fully agreed, I'm partway through implementing what you've just described (at least as I understand it), in that the library now declares a new "Graph" data type which consists of a list of keys->Neural mappings as well as a directed edge set. Using this new data type it is possible to construct, run and train arbitrarily connected graphs of Neural elements. See the fourth example at http://repo.or.cz/w/neural-net.git Best -- Eric > > Ross <>-- 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
Re: Printing a table of data
On Sat, 13 Nov 2010 10:02:59 -0800, Shantanu Kumar wrote: > Does anybody know if a standard 'print-table' kind of function exists in > some library? Maybe if somebody can give an example of printing a table > using cl-format or pprint. > What is your table's representation? If it's CSV perhaps you can use clojure-csv: https://github.com/davidsantiago/clojure-csv Best, -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Slogan help
This is kind of a silly question, but I found this in my Clojure notes from last year: Contemporary Lisp Optimized for the JVM: Un- Restricted Expressiveness I can't remember whether I created it or I found it somewhere... Has anyone seen this phrase before? I can't find it on Google. Have all good days, David Sletten -- 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
Printing a table of data
Does anybody know if a standard 'print-table' kind of function exists in some library? Maybe if somebody can give an example of printing a table using cl-format or pprint. Regards, Shantanu -- 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
Re: Newbie question on defstructs
Another approach would be to use records and protocols: (defprotocol HasCees (c [this] "Returns a 'c'")) (defrecord Foo [a b] HasCees (c [this] (+ (:a this) (:b this Now, to use it: user> (def my-foo (Foo. 1 2) #'user/my-foo user> (c my-foo) 3 This is practically a drop-in replacement for the struct-based code (since Clojure records behave like maps). I think with the advent of records, there isn't really any reason to use structs anymore. Also, this is arguably more fitting with the semantics you have, as the "c" is more of a behavior than a value. It's also common to have a factory function to create record instances (just as Michel showed with structs), like this: (defn make-a-foo [a b] (Foo. a b)) This helps to make dealing with the positional constructors of records a bit less awkward. Here's some links: http://clojure.org/datatypes http://clojure.org/protocols Hope that helps, Chris On Sat, Nov 13, 2010 at 11:48 AM, Michel Alexandre Salim wrote: > On Sat, 13 Nov 2010 06:31:03 -0800, garf wrote: > >> If I have a struct whose creation will require some function calls that >> references some of its members, I am unsure how to go about it in a >> clean way. For example: >> (defstruct tz :a :b :c) >> >> (def tz1 1 2 (+ (:a tz1) (:b tz1)) >> > Could you give a more realistic example of how you plan to use this? > > If the only restriction is that you only know the values for :a and :b at > the time you want to create the structure, then this would work: > > (defn create-tz [a-val b-val] > (struct-map tz :a a-val :b b-val :c (some-fn a-val b-val))) > > >> will not work, but reflects the problem. Ideally at the end of this I >> could do (:c tz1) and get 3 back. Any suggestions? Originally I had >> used assocs, but that runs into the immutability problem, for example >> >> (defstruct tz :a :b) >> (def tz1 1 2) >> (assoc tz1 :c (+ (:a tz1) (:b tz1)) >> >> does not actually update tz1 >> > Correct. Values are immutable, and in Clojure, even collections are > values! > > If you want to have a variable hold a reference to some changing values > then what you want is to use an atom or a ref. Atom is more easy to use, > and unless you have several mutable values that need concurrent updating, > is sufficient, so here's an example: > >> (def tz1 (atom (struct-map tz :a 1 :b 2))) > #'user/tz1 >> @tz1 > {:a 1, :b 2, :c nil} >> (swap! tz1 #(assoc % :c (+ (:a %) (:b % > {:a 1, :b 2, :c 3} >> @tz1 > {:a 1, :b 2, :c 3} > > Hope that helps, > > -- > Michel Alexandre Salim > Clojure contributor: http://clojure.org/contributing > GPG key ID: 78884778 > > µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de > http://twitter.com/hircus | IRC: hir...@irc.freenode.net > > () ascii ribbon campaign - against html e-mail > /\ www.asciiribbon.org - against proprietary attachments > > -- > 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 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
Re: Newbie question
> Which natural language processing tools have you used that worked well with > clojure? I haven't personally, but heard someone saying he successfully used clojure-opennlp. -- 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
Re: Oracle and Apple announce OpenJDK support for Mac
On Fri, 12 Nov 2010 10:19:38 -0500, Steve Miner wrote: > Apple made some news during the Clojure Conj by announcing that Java > support from Apple was being deprecated. The good news today is that > Oracle will deliver future updates of Java on the Mac. I think it's > safe to say that the Mac remains a viable platform for Clojure > development. > > http://www.apple.com/pr/library/2010/11/12openjdk.html > That might mean Mac users will get the latest JDK concurrently with users of other platforms... on the other hand, Apple did put a lot of effort on GUI integration; hope the new development team can keep up. Oracle does not exactly have a stellar track record at accepting outside contributions to its software, after all .. :( -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Mobile Clojure
On Sat, 13 Nov 2010 17:34:00 +0600, Petr Gladkikh wrote: > If you do not need to load Clojure code at > run-time, then, I suppose, performance difference would be about the > same as Java vs Clojure on JVM. Nah, the slowness is actually due to the typical Clojure program generating lots of ephemeral objects (because data structures are immutable), relying on the JVM's efficient garbage collection. The Dalvik VM is less mature and does not do this as well. It's only in Android 2.2 that they even have a JIT! But things should improve over time, nonetheless. -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Newbie question on defstructs
On Sat, 13 Nov 2010 06:31:03 -0800, garf wrote: > If I have a struct whose creation will require some function calls that > references some of its members, I am unsure how to go about it in a > clean way. For example: > (defstruct tz :a :b :c) > > (def tz1 1 2 (+ (:a tz1) (:b tz1)) > Could you give a more realistic example of how you plan to use this? If the only restriction is that you only know the values for :a and :b at the time you want to create the structure, then this would work: (defn create-tz [a-val b-val] (struct-map tz :a a-val :b b-val :c (some-fn a-val b-val))) > will not work, but reflects the problem. Ideally at the end of this I > could do (:c tz1) and get 3 back. Any suggestions? Originally I had > used assocs, but that runs into the immutability problem, for example > > (defstruct tz :a :b) > (def tz1 1 2) > (assoc tz1 :c (+ (:a tz1) (:b tz1)) > > does not actually update tz1 > Correct. Values are immutable, and in Clojure, even collections are values! If you want to have a variable hold a reference to some changing values then what you want is to use an atom or a ref. Atom is more easy to use, and unless you have several mutable values that need concurrent updating, is sufficient, so here's an example: > (def tz1 (atom (struct-map tz :a 1 :b 2))) #'user/tz1 > @tz1 {:a 1, :b 2, :c nil} > (swap! tz1 #(assoc % :c (+ (:a %) (:b % {:a 1, :b 2, :c 3} > @tz1 {:a 1, :b 2, :c 3} Hope that helps, -- Michel Alexandre Salim Clojure contributor: http://clojure.org/contributing GPG key ID: 78884778 µblog: http://identi.ca/hircus | Jabber: hir...@jabber.ccc.de http://twitter.com/hircus | IRC:hir...@irc.freenode.net () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments -- 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
Re: Newbie question on defstructs
thank you! It seems so obvious now On Nov 13, 10:38 am, Benny Tsai wrote: > One way you could do it is by building up the members incrementally > via 'let': > > (defstruct tz :a :b :c) > > (def tz1 (let [a 1 > b 2 > c (+ a b)] > (struct tz a b c))) > > On Nov 13, 7:31 am, garf wrote: > > > > > > > > > If I have a struct whose creation will require some function calls > > that references some of its members, I am unsure how to go about it in > > a clean way. For example: > > (defstruct tz :a :b :c) > > > (def tz1 1 2 (+ (:a tz1) (:b tz1)) > > > will not work, but reflects the problem. Ideally at the end of this > > I could do (:c tz1) and get 3 back. Any suggestions? Originally I > > had used assocs, but that runs into the immutability problem, for > > example > > > (defstruct tz :a :b) > > (def tz1 1 2) > > (assoc tz1 :c (+ (:a tz1) (:b tz1)) > > > does not actually update tz1 > > > Advice for better approaches? -- 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
Re: Newbie question on defstructs
One way you could do it is by building up the members incrementally via 'let': (defstruct tz :a :b :c) (def tz1 (let [a 1 b 2 c (+ a b)] (struct tz a b c))) On Nov 13, 7:31 am, garf wrote: > If I have a struct whose creation will require some function calls > that references some of its members, I am unsure how to go about it in > a clean way. For example: > (defstruct tz :a :b :c) > > (def tz1 1 2 (+ (:a tz1) (:b tz1)) > > will not work, but reflects the problem. Ideally at the end of this > I could do (:c tz1) and get 3 back. Any suggestions? Originally I > had used assocs, but that runs into the immutability problem, for > example > > (defstruct tz :a :b) > (def tz1 1 2) > (assoc tz1 :c (+ (:a tz1) (:b tz1)) > > does not actually update tz1 > > Advice for better approaches? -- 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
Newbie question on defstructs
If I have a struct whose creation will require some function calls that references some of its members, I am unsure how to go about it in a clean way. For example: (defstruct tz :a :b :c) (def tz1 1 2 (+ (:a tz1) (:b tz1)) will not work, but reflects the problem. Ideally at the end of this I could do (:c tz1) and get 3 back. Any suggestions? Originally I had used assocs, but that runs into the immutability problem, for example (defstruct tz :a :b) (def tz1 1 2) (assoc tz1 :c (+ (:a tz1) (:b tz1)) does not actually update tz1 Advice for better approaches? -- 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
Re: Mobile Clojure
On Thu, Nov 11, 2010 at 5:49 AM, Glen Rubin wrote: > Are there any mobile platforms that clojure runs well on? I saw that > clojure is available for Android, but runs very slowly. There are some hacks (discussed on this list a while ago, IIRC) that convert dalvik code converter to dalvik bytecode to load clojure classes inside Android at run-time. If you do not need to load Clojure code at run-time, then, I suppose, performance difference would be about the same as Java vs Clojure on JVM. See this, for example, http://groups.google.com/group/clojure/browse_thread/thread/14725172c626642c?pli=1 -- Petr Gladkikh -- 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