Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Richard Newman
I don't expect anyone to actually read, rather I was hoping some folks who know Clojure might just glance at it to get the rhythm of the math. It's the pattern, not the detail that matters. How should what is essentially a monster algebra equation be codified in Clojure? I looked at your PDF. Y

Re: "hot swapping" + swing + repl?

2010-02-17 Thread Meikel Brandmeyer
Hi, On Feb 18, 1:49 am, Raoul Duke wrote: > any pointers to learn up on how to get a nice environment for doing > swing app development w/out having to kill and restart the whole world > when i make changes to app logic? (yes i'm googling, but i'm still > confused/clueless just yet.) I used Vim

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
Absolutely. I typed up an example in Scala. class RentOrSell(val Months_To_Find_Tenant: Int, val Months_In_Lease: Int, val Lease_Cycles: Int, val Months_To_Sell: Int) { val months_in_business: Int = ((Months_To_Find_Tenant + Months_In_Lease) * Lease_Cycles) + Months_To_Sell } When I create a cl

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Richard Newman
I'm just trying to figure out what the right pattern is because the fact that I'm forced to make the derived values into thunks feels really wrong but I honestly don't know what's right in the context of Clojure. I don't think you're using the term "thunk" correctly. A thunk is (usually) a no-a

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
That's actually quite a nifty use of the fact that code/data is the same in Clojure. But how do I test things out? In other words, how do I make sure that the expression defining a# is correct? Especially when any test has to itself be in the context of all the variables? But more to the point I t

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
The reason for typing so much is maintainability. I'll have to come back to this code again and again over a period of years and there's no chance in heck I'll remember anything I did before. So I've learned that using clearer variable names, even with a little extra typing, is a price worth paying

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
I think I see what you're saying. But honestly my goal isn't to replicate the OO experience. My goal is to replicate how easy OO made this specific scenario. In other words I want to use Clojure properly and trying to paste an OO framework on Clojure has got to be a major anti-pattern. I'm just try

Re: "hot swapping" + swing + repl?

2010-02-17 Thread Sean Devlin
Netbeans has a good swing gui building tool. Good for prototyping & understanding the feel of your app. Not sure how well it plays w/ Clojure, though. On Feb 17, 7:49 pm, Raoul Duke wrote: > hi, > > any pointers to learn up on how to get a nice environment for doing > swing app development w/ou

Re: "hot swapping" + swing + repl?

2010-02-17 Thread John Cromartie
I know this isn't a direct answer to your question, but may I suggest SWT (unless you already have some investment in Swing or have a particular technical reason to use it) instead? In my experience SWT is more lightweight and responsive, especially in the repl. As for "hot swapping" of logic... t

Re: Integers can't be Objects?

2010-02-17 Thread John Cromartie
This also means that the source code for clojure.core/format is a good study on how to make use of Java vararg methods: (defn format "Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax" {:tag String} [fmt & args] (String/format fm

jmx with auth

2010-02-17 Thread Drz
I am just starting to play around with clojure. I was trying to use the clojure.contrib.jmx library to connect to remote java vms that require auth (-Dcom.sun.management.jmxremote.password.file=blah - Dcom.sun.management.jmxremote.access.file=blah). Looking at the java docs, I need to add "jmx.re

Re: clojure-contrib on Windows

2010-02-17 Thread kkw
Hi Ram, If you all you want is the latest .jar file, and don't feel the need to compile, consider bypassing the compilation and grab the latest successfully compiled .jar from build.clojure.org. This is what I now do. Kev On Feb 17, 9:51 am, Ram wrote: > I'm having an issue compiling clojur

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Michał Marczyk
I must say that I find Richard's suggestions to be very reasonable, but I'd like to add my own take... This is meant as a step-by-step account of my thinking process, so it starts out with a statement of the basics. Skim & skip if you prefer. The problem to be solved is basically a huge calculatio

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread liebke
Fantastic feature, thanks Tom! David > However, I have good news: the autodoc robot now supports > documentation in multiple branches. > Multi-branch versions of clojure-contrib and incanter coming up RSN. > > Tom -- You received this message because you are subscribed to the Google Groups "C

"hot swapping" + swing + repl?

2010-02-17 Thread Raoul Duke
hi, any pointers to learn up on how to get a nice environment for doing swing app development w/out having to kill and restart the whole world when i make changes to app logic? (yes i'm googling, but i'm still confused/clueless just yet.) many thanks. -- You received this message because you ar

issue #259 - TestCase to reproduce the issue

2010-02-17 Thread jpraher
Hi all, just to make the ticket complete (somehow I can create tickets but cannot annotate them as a watcher in assembla - but maybe I am doing something wrong). Below you see a simple TestCase. * This source code below compiles using javac 1.6.0.15 (MacOSX 10.6) * The identity method can be suc

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Laurent PETIT
Hello, 2010/2/17 Yaron : > I actually started off doing exactly what you suggested. The original > version of my program used a map for the arguments and then used > explicit arguments when the number of arguments fell to a reasonable > level. > > For example, I started off with: > > (defn months_

Re: since a list of chars is not a string...

2010-02-17 Thread Laurent PETIT
2010/2/17 Wolfgang Meyer : > To convert a string to a char sequence, you can use: > > (seq (.toCharArray "abc")) > Clojure strings are Java strings, in case you didn't know. > Wolfgang Not so hard. In the general case you have nothing to do: basic collection handling functions from core call (se

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread alux
Hello Sean, yes, thats a help too. Its is just, for me as a beginner, that finding a function is sometimes difficult, so I go back to read the funny manual ;-) Thanks & read you. On 17 Feb., 17:21, Sean Devlin wrote: > Alux, > That's what the doc macro is for.  Here's an example. > > user=> (do

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread David Nolen
(defn months_in_business "The total number of months we will be in the business of renting out our home" [:keys [Months_To_Find_Tenant Months_In_Lease Lease_Cycles Months_To_Sell]] (-> (+ Months_To_Find_Tenant Months_In_Lease) (* Lease_Cycles) (+ Months_To_Sell))) -> I have n

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Tom Faulhaber
You can combine let and binding like this to make this slightly more elegant: (let [a# 'expr involving *A* *B* and *C*'' b# 'expr involving *A* *B* and *C*'' c# 'expr involving *A* *B* and *C*''] (binding [*A* a# *B* b# *C* c#] ...)) Note the x# fo

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread CuppoJava
I think it will help you get used to Clojure by spending some time to "program in the most straight-forward way possible". Sometimes it's really helpful to just learn from a blank-slate instead of trying to find analogies to Java. -Patrick -- You received this message because you are subscri

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread CuppoJava
Hi Yaron, You've slightly misunderstood my suggestion. I hope this will shed some reasoning on it: In OO, what you are effectively doing is this: The Object represents the "environment" under which you do your calculations. The "environment" object is created by your constructor. Once this "envi

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
I actually started off doing exactly what you suggested. The original version of my program used a map for the arguments and then used explicit arguments when the number of arguments fell to a reasonable level. For example, I started off with: (defn months_in_business "The total number of

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
I actually started off doing exactly what you suggested. The original version of my program used a map for the arguments and then used explicit arguments when the number of arguments fell to a reasonable level. For example, I started off with: (defn months_in_business "The total number of

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Yaron
I did but it requires two levels of macro and that made me nervous. The problem is derived values. When defining a binding, near as I can tell, the values in the binding cannot see other values in the binding. In other words: (def *A* 10) (binding [*A* 3 B (+ foo 1)] B) Returns 11, not 4. So to

Re: Integers can't be Objects?

2010-02-17 Thread Kevin Downey
the [ in front means an array. the String.format takes java varargs, which the compiler de-sugars as an array. easier to use clojure's own format function. which calls String's format method in the end, but you don't have to create the array manually. On Wed, Feb 17, 2010 at 9:21 AM, Phil wrote:

Re: since a list of chars is not a string...

2010-02-17 Thread Wolfgang Meyer
To convert a string to a char sequence, you can use: (seq (.toCharArray "abc")) Clojure strings are Java strings, in case you didn't know. Wolfgang On Wed, Feb 17, 2010 at 12:10 PM, metaperl wrote: > The reference manual example implies that a list of chars is not a > string: > > (let [[a b

Integers can't be Objects?

2010-02-17 Thread Phil
Sorry for the newbie question, but this seems a strange error message. Either it is saying that a java.lang.Integer cannot be cast to an Object, or it is saying that it can't be cast to a particular object. Some enlightenment would be appreciated. user=> (. String format "%d" 28) java.lang.Class

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Tom, I was just throwing an idea out there, not very high on my to-do list either. I agree with your prioritization. If I come across a project, I'll let you know. Sean On Feb 17, 11:59 am, Tom Faulhaber wrote: > Sean, > > Maybe, but it's not very high on my current priority list. Things like

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Tom Faulhaber
Sean, Maybe, but it's not very high on my current priority list. Things like automated github pages and better searching and formatting are higher on the list (as well as a bunch of work on pretty print). Do you know of a project that is using autodoc that needs this? That would be a powerful imp

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread CuppoJava
Hi Yaron, Have you considered my example yet? It seems to fulfill your requirements. One of the primary use-cases of (binding) is to avoid bloating the parameter list of a group of functions. If my example does not satisfy your needs, then I think we may have all misunderstood what it is you're lo

Re: REST library

2010-02-17 Thread Roman Roelofsen
Shantanu Kumar wrote: > On Feb 17, 3:05 pm, Roman Roelofsen > wrote: > >> Hi, >> >> does someone knows a good Clojure REST framework? It should help with >> URL destructuring and maybe creating JSON return data etc. >> > > You can take a look at Taimen (in Alpha now) - > http://code.googl

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread alux
Well, ehm, yes, okay, thank you Meikel. Regards, alux On 17 Feb., 17:22, Meikel Brandmeyer wrote: > Hi, > > On Feb 17, 5:17 pm, alux wrote: > > > But another beginners question: Is there any prossibility to download > > the API doc? I'm offline a lot, and can't always look at the site. > > From

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Meikel Brandmeyer
Hi, On Feb 17, 5:17 pm, alux wrote: > But another beginners question: Is there any prossibility to download > the API doc? I'm offline a lot, and can't always look at the site. >From the link given by Tom: "If you wish to have a version for off-line use you can use the download button on t

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Alux, That's what the doc macro is for. Here's an example. user=> (doc +) - clojure.core/+ ([] [x] [x y] [x y & more]) Returns the sum of nums. (+) returns 0. On Feb 17, 11:17 am, alux wrote: > Very nice! > > But another beginners question: Is there any prossibility t

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread alux
Very nice! But another beginners question: Is there any prossibility to download the API doc? I'm offline a lot, and can't always look at the site. Thank you, alux On 17 Feb., 14:53, Rich Hickey wrote: > On Wed, Feb 17, 2010 at 3:27 AM, Tom Faulhaber wrote: > > The autodoc robot that builds th

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Rich Hickey
On Wed, Feb 17, 2010 at 3:27 AM, Tom Faulhaber wrote: > The autodoc robot that builds the API docs choked sometime after the > merge of the new branch into master and the clojure and  clojure- > contrib API documents haven't been updating for the past 6 weeks or > so. This has been unfortunate bec

Re: clojure-contrib on Windows

2010-02-17 Thread Chris Perkins
On Feb 16, 5:51 pm, Ram wrote: > I'm having an issue compiling clojure-contrib on Windows. > > I downloaded the code from the git repository and when I run Maven, > after compilation it runs through the test suite fails in test-io: > > FAIL in (test-as-url) (run-test5405918110152723544.clj:47) > e

Re: Very strange swank-clojure error

2010-02-17 Thread George .
Nevermind that, sorry. 1.1 is working. 1.2 might not work because of a lein issue, perhaps? On Wed, Feb 17, 2010 at 10:26 PM, George . wrote: > If I toss clojure.jar and swank-clojure.jar into the swank classpath (for > instance ~/.clojure), it works beautifully. But as soon as I put > clojur

Very strange swank-clojure error

2010-02-17 Thread George .
If I toss clojure.jar and swank-clojure.jar into the swank classpath (for instance ~/.clojure), it works beautifully. But as soon as I put clojure-contrib.jar in there, it explodes: Clojure 1.2.0-master-SNAPSHOTojure 1.2.0-master-SNAPSHOT user=> java.lang.NoSuchMethodError: clojure.lang.RestFn.(I

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Is the long term plan to include this multi-branch behavior in the lein pluggin too? Sean On Feb 17, 3:27 am, Tom Faulhaber wrote: > The autodoc robot that builds the API docs choked sometime after the > merge of the new branch into master and the clojure and  clojure- > contrib API documents ha

Re: since a list of chars is not a string...

2010-02-17 Thread Sean Devlin
Also, you might want to check out clojure contrib for some string stuff. str-utils2 if you're running 1.1, string if you're on edge. Sean On Feb 17, 6:10 am, metaperl wrote: > The reference manual example implies that a list of chars is not a > string: > > (let [[a b & c :as str] "asdjhhfdas"]

Re: #

2010-02-17 Thread Michał Marczyk
On 17 February 2010 12:49, Terrence Brannon wrote: > The reference manual REPL transcript > makes it look like it is being used to retrieve the metadata: > > user=> ^#'mymax > ->{:name mymax, >:user/comment "this is the best fn ever!", >:doc "mymax [xs+]

Re: #

2010-02-17 Thread Terrence Brannon
On Wed, Feb 17, 2010 at 6:49 AM, Terrence Brannon wrote: > > > Also, I'm not clear on why I cant get the metadata for this variable x I > just defined even though meta() takes an object as argument < > http://clojure.org/metadata> > Because I passed the value of the variable x, not the object...

Re: #

2010-02-17 Thread Meikel Brandmeyer
Hi, On Feb 17, 12:49 pm, Terrence Brannon wrote: > On Wed, Feb 17, 2010 at 5:51 AM, Meikel Brandmeyer wrote: > > > #^ attaches metadata to the following thing read. > > The reference manual REPL transcript > makes it look like it is being used to retrieve the

Re: #

2010-02-17 Thread Terrence Brannon
On Wed, Feb 17, 2010 at 5:51 AM, Meikel Brandmeyer wrote: > > > #^ attaches metadata to the following thing read. > The reference manual REPL transcript makes it look like it is being used to retrieve the metadata: user=> ^#'mymax ->{:name mymax, :user/comme

Re: :strs and :syms directives

2010-02-17 Thread Timothy Pratley
On 17 February 2010 22:24, metaperl wrote: > Hi, the ref manual introduces :keys > which I understand. It then says: > > """There are similar :strs and :syms directives for matching string > and symbol keys.""" > > but no example is given. Could someone supply an

Re: can the :test metadata be used to constrain the range of a variable?

2010-02-17 Thread Timothy Pratley
On 17 February 2010 21:53, metaperl wrote: > > I tried to use :test to constrain the range of a variable, but it > didnt seem to work. Am I misunderstanding the purpose of this keyword? What you want is set-validator! :test can be used to store a unit test (typically for a function) but you shou

:strs and :syms directives

2010-02-17 Thread metaperl
Hi, the ref manual introduces :keys which I understand. It then says: """There are similar :strs and :syms directives for matching string and symbol keys.""" but no example is given. Could someone supply an example for each of these directives please? I simply a

Re: since a list of chars is not a string...

2010-02-17 Thread Timothy Pratley
On 17 February 2010 22:10, metaperl wrote: > So what functions exist for conversion from chars to string and vice > versa? > Strings can be passed to any function expecting a collection like map, reduce, etc. To convert chars to a string you can use (str). Most of the string/character support is

Re: Code Review: how can I make this socket code more functional?

2010-02-17 Thread Matt Culbreth
Thanks Wilson. I'm actually not using the Java Servlet classes, and am instead going down to the socket and streams level. On Feb 16, 5:00 pm, Wilson MacGyver wrote: > assuming you are doing this using java servlet. > > you may want to look at how compojure does this. > > http://github.com/weave

Re: Code Review: how can I make this socket code more functional?

2010-02-17 Thread Matt Culbreth
Cool, just what I needed Alan. Thanks for the help. On Feb 16, 4:30 pm, Alan Dipert wrote: > Hi Matt, > I think what you're looking for is > line-seq:http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co... > > In your code, if you pass *in* to line-seq, you'll get back a seq o

since a list of chars is not a string...

2010-02-17 Thread metaperl
The reference manual example implies that a list of chars is not a string: (let [[a b & c :as str] "asdjhhfdas"] [a b c str]) ->[\a \s (\d \j \h \h \f \d \a \s) "asdjhhfdas"] So what functions exist for conversion from chars to string and vice versa? Also how should I have been able to use th

Re: REST library

2010-02-17 Thread Shantanu Kumar
On Feb 17, 3:05 pm, Roman Roelofsen wrote: > Hi, > > does someone knows a good Clojure REST framework? It should help with > URL destructuring and maybe creating JSON return data etc. You can take a look at Taimen (in Alpha now) - http://code.google.com/p/bitumenframework/ Taimen doesn't do s

can the :test metadata be used to constrain the range of a variable?

2010-02-17 Thread metaperl
I tried to use :test to constrain the range of a variable, but it didnt seem to work. Am I misunderstanding the purpose of this keyword? user=> (def #^{ :doc "Integer between -5 and 5" :test (fn [] (assert (and (> x -5) (< x 5} x 12) #'user/x user=> user/x 12 I had hoped this would throw an e

Re: #

2010-02-17 Thread Meikel Brandmeyer
Hi, On Feb 17, 11:44 am, metaperl wrote: > I was able to successfully define and use the mymax function, but when > I try to examine the metadata, I get the error above. Source code and > REPL transcript follow: > > > > user=> (com.new-ns/

Can I make this faster?

2010-02-17 Thread aria42
Hi all, I was playing with the defprotocol/deftype/reify stuff in 1.2, and I wanted to test how a common abstraction I use would look if I did with java data structures vs. clojure ones. I've pasted the code below. I'll wait for you to take a lookSo on my test, I have the Clojure version about

#

2010-02-17 Thread metaperl
Hello, I'm trying to study this page using NetBeans Enclojure. I was able to successfully define and use the mymax function, but when I try to examine the metadata, I get the error above. Source code and REPL transcript follow: =

Re: REST library

2010-02-17 Thread Alex Ott
Hello Roman Roelofsen at "Wed, 17 Feb 2010 11:05:27 +0100" wrote: RR> Hi, RR> does someone knows a good Clojure REST framework? It should help with RR> URL destructuring and maybe creating JSON return data etc. I built web-services using compojure + clojure.json - all works fine -- With be

Re: Leaning about VM's, JVM in particular

2010-02-17 Thread Jeff Rose
I found this book to be a pretty nice as a full introduction to virtual machines. It was readable, and it has detailed sections on the JVM and the CLR. http://www.amazon.com/gp/product/1558609105/ref=wms_ohs_product Beyond that, one really fun way to get your hands dirty with a virtual machine i

REST library

2010-02-17 Thread Roman Roelofsen
Hi, does someone knows a good Clojure REST framework? It should help with URL destructuring and maybe creating JSON return data etc. Cheers, Roman -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Tom Faulhaber
The autodoc robot that builds the API docs choked sometime after the merge of the new branch into master and the clojure and clojure- contrib API documents haven't been updating for the past 6 weeks or so. This has been unfortunate because it's been a time of momentous change (deftype and defproto