Re: Newbie question

2016-09-05 Thread Andy Fingerhut
On Mon, Sep 5, 2016 at 9:25 AM, hiskennyness wrote: > > In other languages you might see: > > (defn himom [] ..) > (defn himom [x] ...) > (defn himom [x y z] ...) > > > Come to think of it, maybe Clojure does that, too, (nooby myself) but the > Clojure syntax for overloading I know puts each defi

Re: Newbie question

2016-09-05 Thread hiskennyness
On Sunday, September 4, 2016 at 4:58:34 PM UTC-4, Charlie wrote: > > I'm going through the Do Things: A Clojure Crash Course, and the following > example (in REPL) is presented: > > (defn recursive-printer > ([] > (recursive-printer 0)) > ([iteration] > (println iteration) > (

Re: Newbie question

2016-09-04 Thread Charlie
Thanx Colin & James - got it now - Charlie On Sunday, September 4, 2016 at 5:31:40 PM UTC-4, Colin Yates wrote: > > This form allows the fn to have multiple arities. So if I call > (recursive-printer) it will 'invoke' ([] (recursive-printer 0)). If I call > (recursive-printer 1) then it will 'in

Re: Newbie question

2016-09-04 Thread Colin Yates
This form allows the fn to have multiple arities. So if I call (recursive- printer) it will 'invoke' ([] (recursive-printer 0)). If I call (recursive- printer 1) then it will 'invoke' ([iteration] ...). HTH -- Colin Yates colin.ya...@gmail.com On Sun, 4 Sep 2016, at 09:54 PM, Charlie wrote

Re: Newbie question

2016-09-04 Thread James Reeves
Functions in Clojure can behave differently depending on the number of arguments they receive (their "arity"). A function can be written: (defn foo [x] (str "foo" x)) But you can also write: (defn foo ([] "empty foo") ([x] (str "foo" x)) This will do different things d

Re: Newbie Question: Why is "reduced?" used in the reductions function?

2015-10-17 Thread Alex Eberts
Ah, that makes total sense. Thanks for the assistance! best, Alex On Saturday, October 17, 2015 at 7:35:00 AM UTC-4, Nicola Mometto wrote: > > > The `reduced?` check is there in case somebody returns a `reduced` as > acc value from the reducing function, as a way to terminate the > reduction ea

Re: Newbie Question: Why is "reduced?" used in the reductions function?

2015-10-17 Thread Nicola Mometto
The `reduced?` check is there in case somebody returns a `reduced` as acc value from the reducing function, as a way to terminate the reduction early: user=> (reductions (fn [_ x] (if (= 10 x) (reduced x) x)) (range)) (0 1 2 3 4 5 6 7 8 9 10) deref is the way to retrieve the value of a reduced o

Re: newbie question: how to selectively iterate through a tree of directories ?

2015-10-03 Thread Gary Verhaegen
I'm on Windows at the moment, so I can't test, but I think you can filter on isFile: (for [file (file-seq dir) :where (.isFile file)] (.getName file)) should work, I think. On 3 October 2015 at 07:36, wrote: > Under linux, I have a tree of directories like this: > > /path/top > > /path

Re: newbie question on agent/transaction

2015-07-15 Thread William la Forge
Or perhaps find a way to extend agents. hm? On Wednesday, July 15, 2015 at 9:45:29 AM UTC-4, William la Forge wrote: > > Thanks, Ragnar. > > My reason for asking is that I've implemented a robust form of actor in > Java https://github.com/laforge49/JActor2 and want to play with a > simplified ve

Re: newbie question on agent/transaction

2015-07-15 Thread William la Forge
Thanks, Ragnar. My reason for asking is that I've implemented a robust form of actor in Java https://github.com/laforge49/JActor2 and want to play with a simplified version in Clojure as a first project in the language. But I'm just hardly getting started. I've only been looking at Clojure for

Re: newbie question on agent/transaction

2015-07-15 Thread Ragnar Dahlén
You can check with `(clojure.lang.LockingTransaction/isRunning)` (the io! macro does this) but I'm not sure if it's considered a public API. https://github.com/clojure/clojure/blob/f6a90ff2931cec35cca0ca7cf7afe90ab99e3161/src/clj/clojure/core.clj#L2390 On Wednesday, 15 July 2015 13:53:11 UTC+1,

Re: newbie question on agent/transaction

2015-07-15 Thread Ragnar Dahlén
Hi Bill, You are correct in that this involves close integration with the STM. The agent implementation is aware of transactions and if a transaction is running when dispatching an action, it will be enqneued in a special agent action queue that STM implementation respects. AFAIK there is no p

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Paul L. Snyder
On Sun, 05 Apr 2015, Michael Blume wrote: > your list doesn't contain the records, your list contains the symbols 'a1 > and 'a2. You can't make a list the way you're trying to. To be specific, you're quoting the list in your def, so the a1 and a2 symbols are not evaluated. user=> (defrecord A

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Michael Blume
your list doesn't contain the records, your list contains the symbols 'a1 and 'a2. You can't make a list the way you're trying to. On Sat, Apr 4, 2015 at 5:14 PM Luc Préfontaine wrote: > You mean the a1 record no ? > > > > Hi! > > > > I'm new to clojure, and have problem understanding how to fil

Re: Newbie question about filtrering defrecord

2015-04-04 Thread Luc Préfontaine
You mean the a1 record no ? > Hi! > > I'm new to clojure, and have problem understanding how to filter a list of > defrecords. > I have tried different variations on the following: > > (defrecord Ape [fname lname]) > (def a1 (->Ape "test1" "test2")) > (def a2 (->Ape "test3" "test4")) > (def a

Re: newbie question: how to include external libraries from Leiningen REPL

2013-11-07 Thread Qiu Xiafei
you may have a look at alembic: https://github.com/pallet/alembic -- -- 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

Re: newbie question: how to include external libraries from Leiningen REPL

2013-11-07 Thread Sean Corfield
On Thu, Nov 7, 2013 at 5:18 AM, Starry SHI wrote: > Hi, I am new to clojure and I find lein REPL very convenient to use. But I > have one question: in REPL, how to include functions defined in other > libraries and call them in my clojure code? As Marshall indicated, you need to edit your project

Re: newbie question: how to include external libraries from Leiningen REPL

2013-11-07 Thread Mars0i
I'm pretty new, also. The Leiningen documentation that's easy to find has all of the information you need ... but it's not easy to sort out at first. Cedric Greevey gives the answer for standard libraries that usually come with Clojure. For others, I suggest: Find the library name and versio

Re: newbie question: how to include external libraries from Leiningen REPL

2013-11-07 Thread Cedric Greevey
Assuming the Java or Clojure library is on your classpath, it *should* be usable from the REPL. (import '[java.library SomeClass]) (.foo (SomeClass. 42)) (require '[clojure.contrib.math :as m]) (m/sqrt 42.0) or whatever. (Didn't this exact question just get asked by someone five minutes ago?

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-21 Thread Christopher Bird
Laurent, that is outstanding. Thank you so much. Yup, I am working from the particular to the general here, so having a working example really makes a big difference. I must say that this is a really helpful community. Thanks evryone Chris On Monday, October 21, 2013 7:15:38 AM UTC-5, Laurent P

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-21 Thread Laurent PETIT
Hello Christopher, I will try to address exactly your example, with Counterclockwise, and hopefully you'll get the general view of how to do things on the go. So you want to instanciate a new namespace like this : (ns play.xml-example (:require [clojure.zip :as zip] [clojure.data.zip :as zf] [cl

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-19 Thread John Mastro
> John, thanks. Not a stupid question at all. When learning a new language, a > new environment, and using an unfamiliar OS, there are so many moving parts > that it is sometimes hard to know where to begin when tracking stuff down. My > old and favorite line here is that "signposts are generall

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-19 Thread Christopher Bird
John, thanks. Not a stupid question at all. When learning a new language, a new environment, and using an unfamiliar OS, there are so many moving parts that it is sometimes hard to know where to begin when tracking stuff down. My old and favorite line here is that "signposts are generally made b

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-18 Thread John Mastro
> So, clearly I need to get the libs onto the classpath. The questions are > what libs, where and how? Forgive me if this is a stupid question, but have you already listed the dependency coordinates under the :dependencies key of your project.clj? Leiningen has a sample project.clj here: http

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-18 Thread Josh Kamau
Install counterclockwise plugin on your eclipse. Then import your project into eclipse. There right click the project and there is something like "Convert to leiningen project" . Hope that helps. Josh. On Fri, Oct 18, 2013 at 5:41 PM, Christopher Bird wrote: > Josh, thanks for replying. The cod

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-18 Thread Christopher Bird
Josh, thanks for replying. The code sample was from my batch lein and not the counterclockwise version. So I am clearly still totally messed up[! C On Friday, October 18, 2013 9:11:54 AM UTC-5, Josh Kamau wrote: > > I find it easier to let leiningen handle the dependencies. Eclipse via > count

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-18 Thread Josh Kamau
I find it easier to let leiningen handle the dependencies. Eclipse via counterclockwise plugin adds dependencies declared in project.clj to the classpath. Josh On Fri, Oct 18, 2013 at 4:42 PM, Christopher Bird wrote: > I know this is a pretty old thread, but my questions are quite > similar/re

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2013-10-18 Thread Christopher Bird
I know this is a pretty old thread, but my questions are quite similar/related, so I figured here would be a good place for them. I am seriously struggling with both the Eclipse/Kepler-CounterClockwise version in general and the command prompt versions of lein. My major issue is how to tell the

Re: newbie question about symbols

2013-05-30 Thread Brian Craft
ah, thanks. On Thursday, May 30, 2013 2:48:00 PM UTC-7, cjeris wrote: > > Commas are whitespace in Clojure. If you are looking for the unquote > operator, it is ~. > > user=> (first `(~+ 5)) > # > > peace, Chris > > > On Thu, May 30, 2013 at 5:42 PM, Brian Craft > > wrote: > >> What's up with t

Re: newbie question about symbols

2013-05-30 Thread Chris Jeris
Commas are whitespace in Clojure. If you are looking for the unquote operator, it is ~. user=> (first `(~+ 5)) # peace, Chris On Thu, May 30, 2013 at 5:42 PM, Brian Craft wrote: > What's up with the 3rd result here? > > user=> (symbol? +) > false > user=> (symbol? clojure.core/+) > false > u

Re: newbie question regarding maps

2012-09-27 Thread Mond Ray
Thanks for the support and especially the examples. I will be back when I bump into the next level of complexity ;-) On Monday, 24 September 2012 12:04:42 UTC+2, Mond Ray wrote: > > I am playing around with maps and using wish lists as a learning tool. I > have a list of items in wish lists lik

Re: newbie question regarding maps

2012-09-26 Thread Timo Mihaljov
On 24.09.2012 13:04, Mond Ray wrote: > user=> wish-lists > [{:name "WL1", :items [{:name "Item 1", :cost 20.0} {:name "Item 2", > :cost 40.0}]} {:name "WL2", :items [{:name "Wiggle 1", :cost 20.0} > {:name "Wiggle 2", :cost 40.0} [:name "Item 3" :cost 10.0]]}] > user=> (assoc-in wish-lists [:name

Re: newbie question regarding maps

2012-09-26 Thread vxm
(defn new-item-ks [wlists wlist-name] (first (keep-indexed #(when (= (:name %2) wlist-name) [%1 :items (count (:items %2))]) wlists))) (assoc-in wish-lists (new-item-ks wish-lists "WL2") {:name "Item 3" :cost 10.0}) On Monday, September 24, 201

Re: newbie question regarding maps

2012-09-25 Thread George Oliver
On Monday, September 24, 2012 3:04:42 AM UTC-7, Mond Ray wrote: > > > As you can see the REPL gives me an error stating that the keys must be > Integers. Is that right? Or is my call process faulty? > > I think the problem is that wish-lists is a vector, so you need a key for the vector first

Re: newbie question on namespaces and reference resources

2012-08-17 Thread Hugo Estrada
Thanks for answering both questions. I believe I saw some musical package, so maybe I will look at that code. Thanks so much :) On Fri, Aug 17, 2012 at 7:20 PM, Stephen Compall wrote: > On Sun, 2012-08-12 at 19:55 -0700, Hugo Estrada wrote: > > 1. What is the best practice with namespaces? Should

Re: newbie question on namespaces and reference resources

2012-08-17 Thread Stephen Compall
On Sun, 2012-08-12 at 19:55 -0700, Hugo Estrada wrote: > 1. What is the best practice with namespaces? Should I follow > java-style namespacing names, or does clojure has its own favored > style? Most packages simply have a prefix matching the name of the package, without domain. This isn't unive

Re: newbie question about the difference of proxy [Runnable] and fn

2012-07-06 Thread Moritz Ulrich
On Fri, Jul 6, 2012 at 5:22 PM, grahamke wrote: > (.start (Thread. (println "I ran!") "tName")) You're missing a # here. You create a new thread object passing two args to the Thread constructor: The return value of (println ...) and "tName". println returns nil, so you effectively do (Thread. ni

Re: Newbie question about rebinding local variables

2012-04-22 Thread Tim Cross
On Saturday, April 21, 2012 12:26:30 AM UTC+10, Craig Ching wrote: > > > > On Friday, April 20, 2012 9:07:49 AM UTC-5, Walter van der Laan wrote: >> >> You could start with pure functions to handle the game logic, e.g.: >> >> (defn new-game [] >> [[\- \- \-] >>[\- \- \-] >>[\- \- \-]])

Re: Newbie question about rebinding local variables

2012-04-22 Thread Tim Cross
On Friday, April 20, 2012 8:21:56 AM UTC+10, Craig Ching wrote: > > Ok, I've read that what I want to do is a no no. But this is the sort of > thing I did in Scheme about 20 years ago (and because of that I'm probably > misremembering ;-)). > > Basically I'm learning clojure and thought I'd wr

Re: Newbie question about rebinding local variables

2012-04-21 Thread Alex Baranosky
Another non-standard solution you could try is to use the state monad from the monad library. On Apr 21, 2012 3:22 PM, "Sergey Didenko" wrote: > There is also a non-idiomatic way - transform your code to use a > native Java data structure like ArrayList or primitive array. > > You may want it for

Re: Newbie question about rebinding local variables

2012-04-21 Thread Sergey Didenko
There is also a non-idiomatic way - transform your code to use a native Java data structure like ArrayList or primitive array. You may want it for the speed or if the mutable algorithm is more readable. Anyway isolation of the mutable code is always a good advice. (defn new-game [] (let [board

Re: Newbie question about rebinding local variables

2012-04-20 Thread Craig Ching
On Friday, April 20, 2012 1:15:11 PM UTC-5, kurtharriger wrote: > > > Game state does not have to be a map, it could be any datastructure > you want, perhaps a protocol that is implemented by a concrete class > in another JVM language. However, I avoid encapsulation unless there > is a compel

Re: Newbie question about rebinding local variables

2012-04-20 Thread kurtharriger
On Apr 20, 9:43 am, Craig Ching wrote: > Thanks for your input, I appreciate it. > > On Friday, April 20, 2012 10:16:51 AM UTC-5, kurtharriger wrote: > > > And you just need to keep the resulting state, no need to reapply the > > moves. > > Your main method might use a reduce or loop recur. > >

Re: Newbie question about rebinding local variables

2012-04-20 Thread nicolas.o...@gmail.com
This is not the idiomatic way but you can stay quite close from your code by: (defn game [ board ] (fn [n i] (cond (= n :x) (game (assoc board i 'x)) ( = n :o) (game (assoc board i 'o)) (= n :print) (println board (defn (new-game (game (in

Re: Newbie question about rebinding local variables

2012-04-20 Thread Walter van der Laan
You can save state in an atom like this: (def state (atom (new-game))) ; initial state (swap! state move \x [1 1]) ; make a move -- 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 po

Re: Newbie question about rebinding local variables

2012-04-20 Thread Phil Hagelberg
On Fri, Apr 20, 2012 at 7:07 AM, Walter van der Laan wrote: > You could start with pure functions to handle the game logic, e.g.: We did this during swarm coding at ClojureWest on the game of Go, but you could apply the same logic to any board game: https://github.com/technomancy/swarm-go/blob/m

Re: Newbie question about rebinding local variables

2012-04-20 Thread Craig Ching
Thanks for your input, I appreciate it. On Friday, April 20, 2012 10:16:51 AM UTC-5, kurtharriger wrote: > > And you just need to keep the resulting state, no need to reapply the > moves. > Your main method might use a reduce or loop recur. > > (loop [game (new-game)] > (if-not (complete? gam

Re: Newbie question about rebinding local variables

2012-04-20 Thread kurtharriger
And you just need to keep the resulting state, no need to reapply the moves. Your main method might use a reduce or loop recur. (loop [game (new-game)] (if-not (complete? game) (recur (make-random-move game))) -- You received this message because you are subscribed to the Google Groups

Re: Newbie question about rebinding local variables

2012-04-20 Thread kurtharriger
By creating new game objects rather than mutating existing ones you could do things you wouldnt otherwise be able to do. Perhaps you have different solver strategies that you want to apply in parallel. Provided you can give each solver its own copy this is trivial, but if your datastructures req

Re: Newbie question about rebinding local variables

2012-04-20 Thread Craig Ching
On Friday, April 20, 2012 9:07:49 AM UTC-5, Walter van der Laan wrote: > > You could start with pure functions to handle the game logic, e.g.: > > (defn new-game [] > [[\- \- \-] >[\- \- \-] >[\- \- \-]]) > > (defn print-game [game] > (doseq [row game] > (println (apply str row)))

Re: Newbie question about rebinding local variables

2012-04-20 Thread Walter van der Laan
You could start with pure functions to handle the game logic, e.g.: (defn new-game [] [[\- \- \-] [\- \- \-] [\- \- \-]]) (defn print-game [game] (doseq [row game] (println (apply str row (defn move [game mark pos] (assoc-in game pos mark)) (print-game (new-game)) (print-gam

Re: Newbie question about rebinding local variables

2012-04-20 Thread Craig Ching
Thanks for the help to both of you! Question, does it seem heavy handed to do it this way? I mean, atoms are more for thread-safety, aren't they? I don't have threads so it seems a bit much to use atoms for this. Am I better off using recur and trying to loop? Or is this considered an idio

Re: Newbie question about rebinding local variables

2012-04-19 Thread gaz jones
to answer your question directly, you would need to do something like this to make it work the way your example is set up: (defn new-game [] (let [board (atom (into [] (repeat 9 nil)))] (fn [n & [i]] (cond (= n :x) (swap! board assoc i 'x) (= n :o) (swap! board assoc i 'o

Re: Newbie question about rebinding local variables

2012-04-19 Thread Armando Blancas
You could keep the board in an atom so it can mutate; then try to find maybe two good places for mutation to happen, your move and the program's. With the rest being functional you'll avoid the problems of global state while not being forced to fit your logic into a loop of some re-binding that

Re: Newbie question on OO/records

2011-11-07 Thread Alan Malloy
Yes On Nov 7, 10:35 am, stevelewis wrote: > So, you can have records in one .clj file and implementations of the > protocols in another .clj file? > > On Nov 6, 1:43 am, Baishampayan Ghose wrote: > > > > > > > > > > Okay, I'm trying to understand records. I read this article: > > >http://freegee

Re: Newbie question on OO/records

2011-11-07 Thread stevelewis
So, you can have records in one .clj file and implementations of the protocols in another .clj file? On Nov 6, 1:43 am, Baishampayan Ghose wrote: > > Okay, I'm trying to understand records. I read this article: > >http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-p... > > (Cloju

Re: Newbie question on OO/records

2011-11-06 Thread Baishampayan Ghose
>> Records & Protocols are indeed a way of achieving polymorphism and is >> quite similar to class-based single dispatch found in Java, etc. Thus >> the calling conventions can look quite familiar. >> >> Having said that, records & protocols are fundamentally different from >> class based OO since

Re: Newbie question on OO/records

2011-11-06 Thread Alan Malloy
On Nov 5, 10:43 pm, Baishampayan Ghose wrote: > > Okay, I'm trying to understand records. I read this article: > >http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-p... > > (Clojure Protocols & Datatypes - A sneak peek by Baishampayan Ghose. I > > found it helpful, but the usage

Re: Newbie question on OO/records

2011-11-05 Thread Baishampayan Ghose
> Okay, I'm trying to understand records. I read this article: > http://freegeek.in/blog/2010/05/clojure-protocols-datatypes-a-sneak-peek/ > (Clojure Protocols & Datatypes - A sneak peek by Baishampayan Ghose. I > found it helpful, but the usage of datatypes and protocols looks/feels > very object-

Re: Newbie question on OO/records

2011-11-05 Thread Matt Hoyt
Protocols are a way to achieve polymorphism.  Clojure protocols are similar to Haskell types classes.  Here is a video that explains clojure protocols: http://vimeo.com/11236603   Matt Hoyt From: stevelewis To: Clojure Sent: Saturday, November 5, 2011 6:40 PM

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2011-09-12 Thread JosephLi
hi Laurent, Sorry for going silent for several days the usual excuse, work deadline, families etc Anyway, really appreciate ur jumping in and try to give me a hand. I finally found out why: 1.) I have to indicate in Eclipse that the user library, that pointed to the jar downloaded from

Re: Newbie question: How to add external clojure jars properly in Eclipse.

2011-09-08 Thread Laurent PETIT
Hi Joseph, can you show us the content of your .project and .classpath files under your project's root directory ? This should be necessary but enough to help you. 2011/9/7 JosephLi > hi all, > > I have a bare bone Clojure project created in Eclipse with > Counterclockwise plugin and am trying

Re: newbie question

2011-04-28 Thread lesni bleble
Simple switch from openjdk to sun-java6 problem resolved. On Apr 22, 8:18 pm, lesni bleble wrote: > hello again, > > i have another problem.  I'm trying simple applet: > > $ cat src/foo/applet.clj > > (ns foo.applet >   (:import (java.awt Graphics2D Graphics Frame Color Image Toolkit)) >   (:gen-

Re: newbie question

2011-04-22 Thread lesni bleble
hello again, i have another problem. I'm trying simple applet: $ cat src/foo/applet.clj (ns foo.applet (:import (java.awt Graphics2D Graphics Frame Color Image Toolkit)) (:gen-class :extends java.applet.Applet)) (defn -paint [#^Applet applet #^Graphics2D g] (.drawString g "Hello from

Re: newbie question

2011-04-20 Thread lesni bleble
thanks all, now it's clear to me. On Apr 19, 10:39 pm, Mark Nutter wrote: > Hmm, in your example you say you're code looks like > > (println "hello") > > but in your description you say > > ((println "hello")) > > Don't know if that's a just a typo or not, but if you actually did > type in double

Re: newbie question

2011-04-19 Thread Mark Nutter
Hmm, in your example you say you're code looks like (println "hello") but in your description you say ((println "hello")) Don't know if that's a just a typo or not, but if you actually did type in doubled parens like that it would give a null pointer exception because println returns nil, which

Re: newbie question

2011-04-18 Thread semperos
To use lein run, you need to do two things: 1) Write a -main function (defn -main [] ... ) in whatever namespace you like (you could put it in the core namescape, like you did in your echo statement for the (println "foo")). For example: (defn -main [] (println "foo")) 2) Specify which names

Re: newbie question

2011-04-18 Thread Ambrose Bonnaire-Sergeant
Hi, lein run looks for a -main function in your source file. This is a convention borrowed from java (and other languages). The null pointer exception is probably lein or clojure looking for -main. > echo '(defn -main [] (println "no exception)' >> src/foo/core.clj > lein run -m foo.core hello a

Re: Newbie question

2010-11-16 Thread Lee Hinman
On Tue, Nov 16, 2010 at 9:34 AM, Lee Hinman wrote: > On Fri, Nov 12, 2010 at 1:54 PM,   wrote: >> Which natural language processing tools have you used that worked well with >> clojure? > > I've had good luck with clojure-opennlp - > http://github.com/dakrone/clojure-opennlp > > However, I may be

Re: Newbie question

2010-11-16 Thread Lee Hinman
On Fri, Nov 12, 2010 at 1:54 PM, wrote: > Which natural language processing tools have you used that worked well with > clojure? I've had good luck with clojure-opennlp - http://github.com/dakrone/clojure-opennlp However, I may be a bit biased since I wrote it :) - Lee -- You received this m

Re: Newbie question on defstructs

2010-11-13 Thread garf
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: > > (defpr

Re: Newbie question on defstructs

2010-11-13 Thread garf
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

Re: Newbie question on defstructs

2010-11-13 Thread Chris Maier
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 replac

Re: Newbie question

2010-11-13 Thread Miki
> 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

Re: Newbie question on defstructs

2010-11-13 Thread Michel Alexandre Salim
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

Re: Newbie question on defstructs

2010-11-13 Thread garf
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

Re: Newbie question on defstructs

2010-11-13 Thread Benny Tsai
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 ca

Re: newbie question: where are my log messages going to?

2010-08-28 Thread ataggart
c.c.logging just delegates to the underlying logging implementation. If you haven't included a separate logging library on your classpath (e.g., log4j) then it will default to using java.util.logging. Note that by default the j.u.logging will output to stdout, and has a default threshold of INFO.

Re: newbie question casting java classes/interfaces

2010-07-28 Thread Tobias Ivarsson
Yes, this is a perfectly valid error, it simply means what it says. That it's impossible to cast an instance of EmbeddedGraphDatabase to the NeoService interface. The reason for this is of course that EmbeddedGraphDatabase does not implement the NeoService interface. As you said, you were mixing in

Re: newbie question casting java classes/interfaces

2010-07-28 Thread Sandeep Puri
Sorry didn't answer your question.. The error I got was "Cannot cast GraphDBService to NeoService" On Jul 28, 8:54 pm, Sandeep Puri wrote: > It's not the JPA one. It's the meta-model work-in-progress for the > neo4j project. > > It so happens I was using neo4j-1.1-snapshot with an older meta-mode

Re: newbie question casting java classes/interfaces

2010-07-28 Thread Sandeep Puri
It's not the JPA one. It's the meta-model work-in-progress for the neo4j project. It so happens I was using neo4j-1.1-snapshot with an older meta-model implementation. I pulled the meta-model-0.9 snapshot which seems to work.fine. But the above question is still valid in a generic sense.. On Ju

Re: newbie question casting java classes/interfaces

2010-07-28 Thread Chas Emerick
What error or other message do you get? Also, which MetaModelImpl is this? I assume it's not the JPA one. - Chas On Jul 27, 2010, at 2:38 PM, Sandeep Puri wrote: The snippet below works fine GraphDatabaseService neo = new EmbeddedGraphDatabase(dbpath); MetaModel model = new MetaModelImpl((

Re: Newbie question about vector performance

2010-06-11 Thread David Nolen
On Sun, May 30, 2010 at 3:49 PM, Rubén Béjar wrote: > Thanks to all of you for your interest, I will inform of any further > advance... > :-) > > Rubén Because I like sitting around optimizing Clojure code I looked into this some more: http://gist.github.com/420036 With the really great cha

Re: newbie question about sets not being countable

2010-06-01 Thread Stuart Halloway
You are counting the function: > (count toddg.spell/get-wordlist) Not the result of calling the function: (count (toddg.spell/get-wordlist)) Cheers, Stu -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Newbie question about vector performance

2010-05-31 Thread David Nolen
On Sun, May 30, 2010 at 3:49 PM, Rubén Béjar wrote: > > is not very precise with that short periods of time) and in Clojure the > 2000x2000 CA > is updated in 98 secs some times and up to 150 s. other times (the 500x500 > was 4 secs), When numbers fluctuate like that I'm pretty sure you're hitt

Re: Newbie question about vector performance

2010-05-31 Thread David Nolen
On Fri, May 28, 2010 at 12:20 PM, Rubén Béjar wrote: > Hi again, > > I have tried a few more things: > > I have done the same in Java but using an array > of Integers, instead of an array of ints. It just takes > 78 ms. (more than 16, still far less than 4 secs). > > I have also tried with an up

Re: Newbie question about vector performance

2010-05-30 Thread Rubén Béjar
Michael Gardner wrote: As a style issue I'd suggest using inc, dec, neg?, pos?, and zero? instead of the various (+ x 1), (< x 0), etc. in your code. This actually seems to improve performance a bit on my laptop, but it's nothing amazing. To get good performance you're likely going to need to

Re: Newbie question about vector performance

2010-05-29 Thread Laurent PETIT
If you change the size of your CA, is the ( java time / clojure time ratio ) roughly constant ? 2010/5/28 Rubén Béjar > Hi all, > > I am new to the list and to Clojure. I have been working in > implementing some 2D cellular automata (CA) just to have a project > to teach Clojure to myself. After

Re: Newbie question about vector performance

2010-05-29 Thread igorrumiha
On May 28, 3:47 pm, Rubén Béjar wrote: > > I would thank a lot any hint, suggestion, comment, or > whatever... :-) > Here is a version that is approx 10 times faster: http://snipt.org/Olml The code structure is basically the same but it uses integer arrays for storage, some manual inlining and lo

Re: Newbie question about vector performance

2010-05-28 Thread Luke VanderHart
I can't see your code due to the IT policies here, but I can make some generalizations - these are assuming your code is correct and you're not accidentally using an exponential algorithm (which I wouldn't preclude, 4 minutes does sound truly excessively slow, even for vectors). Vectors are signif

Re: Newbie question about vector performance

2010-05-28 Thread Michael Gardner
On May 28, 2010, at 8:47 AM, Rubén Béjar wrote: > I would thank a lot any hint, suggestion, comment, or > whatever... :-) As a style issue I'd suggest using inc, dec, neg?, pos?, and zero? instead of the various (+ x 1), (< x 0), etc. in your code. This actually seems to improve performance a b

Re: Newbie question about vector performance

2010-05-28 Thread Rubén Béjar
Hi again, I have tried a few more things: I have done the same in Java but using an array of Integers, instead of an array of ints. It just takes 78 ms. (more than 16, still far less than 4 secs). I have also tried with an update function which just returns a fixed 1. It still takes some

Re: Newbie question re. calling Java from Clojure

2010-04-05 Thread Gregg Williams
Thanks for the help! I found and corrected a few more errors. You can see the final result with documentation, at http://gist.github.com/354147 . -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

Re: Newbie question re. calling Java from Clojure

2010-04-02 Thread Michael Wood
On 2 April 2010 15:00, Kevin wrote: >> Here's my best attempt so far: >> >> -- >> (ns piccoloHello >>  (:gen-class) >>  (:import (edu.umd.cs.piccolo PCanvas PNode PLayer) >>    (edu.umd.cs.piccolo.nodes PText) >>    (edu.umd.cs.piccolox PFrame)))

RE: Newbie question re. calling Java from Clojure

2010-04-02 Thread Kevin
> Here's my best attempt so far: > > -- > (ns piccoloHello > (:gen-class) > (:import (edu.umd.cs.piccolo PCanvas PNode PLayer) >(edu.umd.cs.piccolo.nodes PText) >(edu.umd.cs.piccolox PFrame))) > > (defn create-frame > "Creates the ma

Re: Newbie question: Why does clojure prefer java.lang.Exception?

2010-03-15 Thread Brian Schlining
> > > > > > That's my impression too. Unfortunately it's inconsistent with Java > > convention. Java generally uses (extensions of) RuntimeException for > > such cases. Other extensions of Exception are reserved for cases you > > *are* expected to handle. > > How do you expect to handle an exceptio

Re: Newbie question: Why does clojure prefer java.lang.Exception?

2010-03-15 Thread CloudiDust
Thanks very much for your reply! This is to say, those exceptions are expected to be treated like Java's compilation errors. On 3月15日, 下午1时50分, ataggart wrote: > Exceptions are over/mis-used in java, particularly checked exceptions > (runtime exceptions aren't so bad).  My sense is that those pl

Re: Newbie question: Why does clojure prefer java.lang.Exception?

2010-03-15 Thread ataggart
On Mar 15, 4:44 am, B Smith-Mannschott wrote: > On Mon, Mar 15, 2010 at 06:50, ataggart wrote: > > Exceptions are over/mis-used in java, particularly checked exceptions > > (runtime exceptions aren't so bad).  My sense is that those places > > where java.lang.Exception is thrown, the exception is

Re: Newbie question: Why does clojure prefer java.lang.Exception?

2010-03-15 Thread B Smith-Mannschott
On Mon, Mar 15, 2010 at 06:50, ataggart wrote: > Exceptions are over/mis-used in java, particularly checked exceptions > (runtime exceptions aren't so bad).  My sense is that those places > where java.lang.Exception is thrown, the exception is not expected to > be handled by user code, or perhaps

Re: Newbie question: Why does clojure prefer java.lang.Exception?

2010-03-14 Thread ataggart
Exceptions are over/mis-used in java, particularly checked exceptions (runtime exceptions aren't so bad). My sense is that those places where java.lang.Exception is thrown, the exception is not expected to be handled by user code, or perhaps more accurately, a direct result of a bug fat-fingered i

  1   2   3   >