Re: introspecting types and records

2010-06-07 Thread ataggart
The field names and order in the constructor will always match the values specified in deftype (excepting certain character issues, such as turning a dash into an underscore). Introspecting is easy enough: user=> (deftype foo [bar baz]) user.foo user=> (map #(.getName %) (.getDeclaredFields foo))

Using Apache Camel with Clojure

2010-06-07 Thread jwhitlark
I wrote up a quick post on my experience with using Apache Camel from Clojure. For anyone who's interested, you can find it at http://codeabout.blogspot.com/2010/06/using-apache-camel-from-clojure.html Thanks, ~J -- You received this message because you are subscribed to the Google Groups "Clo

introspecting types and records

2010-06-07 Thread Chris Kent
Hi Is there a way to introspect types defined with deftype and defrecord? I'd just like to know the field names and their order in the constructor. Java reflection works fine but requires some fiddling around to filter the static fields and __meta and __extmap. It feels like something that someo

Re: Lein deps failure

2010-06-07 Thread Meikel Brandmeyer
Hi, Am 07.06.2010 um 21:20 schrieb Brian Troutwine: > Why does this work? >> change [org.clojure/swank-clojure "1.2.1"] => [swank-clojure "1.2.1"] Each dependency has a group and an artifact name. org.clojure/swank-clojure means group "org.clojure" and artifact "swank-clojure". swank-clojure is

Re: Complex type in clojure

2010-06-07 Thread Travis Hoffman
Personally, I thinks it would be much more elegant to have a direct notation. It could be argued that the Ratio type could also be implemented without a special Ratio type, but where's the fun in that? Consider: (* 3.4+7i 15i) vs (complex-multiply (construct-complex 3.4 7) (construct-complex 0

Re: Lein deps failure

2010-06-07 Thread Brian Troutwine
Interesting, that works perfectly. Thanks! Why does this work? On Mon, Jun 7, 2010 at 12:16 PM, patrik karlin wrote: > Hey Brian > > change [org.clojure/swank-clojure "1.2.1"] => [swank-clojure "1.2.1"] > > > 2010/6/7 Brian Troutwine : >> Hello all, >> >> I have the following in project.clj in m

Re: Lein deps failure

2010-06-07 Thread patrik karlin
Hey Brian change [org.clojure/swank-clojure "1.2.1"] => [swank-clojure "1.2.1"] 2010/6/7 Brian Troutwine : > Hello all, > > I have the following in project.clj in my newly lein generated project: > > > (defproject void "1.0.0" >  :description "A toy." >  :dependencies [[org.clojure/clojure "1.1.

Lein deps failure

2010-06-07 Thread Brian Troutwine
Hello all, I have the following in project.clj in my newly lein generated project: (defproject void "1.0.0" :description "A toy." :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"]] :dev-dependencies [[org.clojure/swank-clojure "1.2.1"]]) R

Re: problem with Character/isLetter

2010-06-07 Thread Michael Wood
On 7 June 2010 16:50, .Bill Smith wrote: > To complete the thought, > > user=> (Character/isLetter \x) > true > user=> (Character/isLetter (.charAt "x" 0)) > true or: user=> (first "x") \x user=> (Character/isLetter (first "x")) true > On Jun 7, 6:17 am, Moritz Ulrich wrote: >> isLetter accept

Re: Complex type in clojure

2010-06-07 Thread Mark Engelberg
Yes, but in (some versions of) Scheme, (sqrt -1) yields i. Representing complex numbers and just doing math between two complex numbers is not the problem. Retrofitting Clojure math so that all operations work on the entire numeric tower, allowing you to seamlessly manipulate complex and non-comp

Re: API in Clojure for Java folklore

2010-06-07 Thread Jason Smith
I think the right place for this is Maven, Ant, Leiningen, and command line. It's a generic thing for any build system. :-) Generating correct stubs is the common part, and then there is an integration into each system. I'm most interested in having this for Maven, but there's really not much t

Re: studying core.clj, questions on read-lines, lazy-seq, and if-let

2010-06-07 Thread Joost
On Jun 7, 6:37 am, toddg wrote: > I'm attempting to read and understand core.clj, and I'm walking > through methods as I run into them, trying to understand them, line by > line. I' mostly understand read-lines (w/ the exception of the last > line), but I do not follow lazy-seq or if-let. Could so

Re: SLIME REPL clojure completion

2010-06-07 Thread Rick Moynihan
On 7 June 2010 16:35, Phil Hagelberg wrote: > On Mon, Jun 7, 2010 at 5:41 AM, Rick Moynihan wrote: >> I've just updated slime to 20100404 in ELPA, and I've noticed that tab >> completion in the REPL buffer has stopped working. >> >> Pressing TAB to complete a symbol prints "No dynamic expansion f

Re: SLIME REPL clojure completion

2010-06-07 Thread Phil Hagelberg
On Mon, Jun 7, 2010 at 5:41 AM, Rick Moynihan wrote: > I've just updated slime to 20100404 in ELPA, and I've noticed that tab > completion in the REPL buffer has stopped working. > > Pressing TAB to complete a symbol prints "No dynamic expansion for > `user> foo' found.  Any ideas how to get this

Re: Loop and Recur

2010-06-07 Thread Bruce Durling
Melkel, On Mon, Jun 7, 2010 at 15:55, Meikel Brandmeyer wrote: > Hi, > > On Jun 7, 4:25 pm, Bruce Durling wrote: > >> I have no problem with calling seq, I just don't understand why I need to. > > Because the initial collections might be empty. > > (my-zipmap [] []) => {} I see, where as the ve

Re: Loop and Recur

2010-06-07 Thread Joost
On Jun 7, 1:49 pm, Bruce Durling wrote: > Steve and Jon, > > On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote: > > Empty seqs are logically true, so your "if" condition is always true. > > I was looking at that today too. I did (> 0 (count my-list)) in my if > statement to fix it. Be aware that

Re: Loop and Recur

2010-06-07 Thread Meikel Brandmeyer
Hi, On Jun 7, 4:25 pm, Bruce Durling wrote: > I have no problem with calling seq, I just don't understand why I need to. Because the initial collections might be empty. (my-zipmap [] []) => {} Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clo

Re: problem with Character/isLetter

2010-06-07 Thread .Bill Smith
To complete the thought, user=> (Character/isLetter \x) true user=> (Character/isLetter (.charAt "x" 0)) true On Jun 7, 6:17 am, Moritz Ulrich wrote: > isLetter accepts single characters, you gave it a string with a length of one. > The error is caused by reflection when clojure searches for a f

Re: Loop and Recur

2010-06-07 Thread Bruce Durling
Patrik, On Mon, Jun 7, 2010 at 13:00, patrik karlin wrote: > calling rest dosent give you nil it gives you an empty seq > so the if statment never fails > > try > > (defn my-zipmap [keys vals] >  (loop [my-map {} >        [kf & kr] (seq keys) >        [vf & vr] (seq vals)] >   (if (and kf vf) >  

ILC 2010

2010-06-07 Thread aml
With the usual apologies to those who receive multiple copies of this... ~~~ International Lisp Conference 2010 October 19-21, 2010 John Ascuaga's Nugget (Casino)

SLIME REPL clojure completion

2010-06-07 Thread Rick Moynihan
I've just updated slime to 20100404 in ELPA, and I've noticed that tab completion in the REPL buffer has stopped working. Pressing TAB to complete a symbol prints "No dynamic expansion for `user> foo' found. Any ideas how to get this working again? R. -- You received this message because you a

Re: Loop and Recur

2010-06-07 Thread Bruce Durling
Stu, On Mon, Jun 7, 2010 at 13:08, Stuart Halloway wrote: > That doc page used pre-1.0 Clojure code, which, as you saw, doesn't work. > Thanks for the catch, I have fixed the docs on the site. Thanks. I think my mistake was mixing up rest (which always returns a sequence even if empty) and next

Re: Loop and Recur

2010-06-07 Thread Stuart Halloway
Hi Bruce, That doc page used pre-1.0 Clojure code, which, as you saw, doesn't work. Thanks for the catch, I have fixed the docs on the site. Stu > Steve and Jon, > > On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote: >> Empty seqs are logically true, so your "if" condition is always true. >>

Re: Loop and Recur

2010-06-07 Thread patrik karlin
So its the calling of first that gives you nil here is some example code user=> (rest '(2)) () user=> (rest '()) () user=> (first '()) nil 2010/6/7 patrik karlin : > calling rest dosent give you nil it gives you an empty seq > so the if statment never fails > > try > > (defn my-zipmap [keys val

Re: Loop and Recur

2010-06-07 Thread patrik karlin
calling rest dosent give you nil it gives you an empty seq so the if statment never fails try (defn my-zipmap [keys vals] (loop [my-map {} [kf & kr] (seq keys) [vf & vr] (seq vals)] (if (and kf vf) (recur (assoc my-map kf vf) kr vr) my-map))) 2010/6/6 Jon Seltzer

Re: Loop and Recur

2010-06-07 Thread Bruce Durling
Steve, On Mon, Jun 7, 2010 at 12:48, Steve Purcell wrote: > On 7 Jun 2010, at 12:43, Steve Purcell wrote: > >> Empty seqs are logically true, so your "if" condition is always true. > > > Apologies; I'm talking rubbish: > > user=> (if '() (println "truthy")) > truthy > nil > user=> (if (seq '()) (

Re: Loop and Recur

2010-06-07 Thread Bruce Durling
Steve and Jon, On Mon, Jun 7, 2010 at 12:43, Steve Purcell wrote: > Empty seqs are logically true, so your "if" condition is always true. > I was looking at that today too. I did (> 0 (count my-list)) in my if statement to fix it. Is the Recursive Looping example on http://clojure.org/function

Re: Loop and Recur

2010-06-07 Thread Steve Purcell
On 7 Jun 2010, at 12:43, Steve Purcell wrote: > Empty seqs are logically true, so your "if" condition is always true. Apologies; I'm talking rubbish: user=> (if '() (println "truthy")) truthy nil user=> (if (seq '()) (println "truthy")) nil -- You received this message because you are subscr

Re: Loop and Recur

2010-06-07 Thread Steve Purcell
On 6 Jun 2010, at 15:30, Jon Seltzer wrote: > I'm still learning Clojure and doing so by reading everything on > clojure.org. I ran across this example in the Functional Programming > section: > > (defn my-zipmap [keys vals] > (loop [my-map {} > my-keys (seq keys) > my-vals (seq

Re: problem with Character/isLetter

2010-06-07 Thread Moritz Ulrich
isLetter accepts single characters, you gave it a string with a length of one. The error is caused by reflection when clojure searches for a function with the signature isLetter(String) On Monday, June 7, 2010, AJ Sterman wrote: >  (Character/isLetter "x") > # method found: isLetter (NO_SOURCE_FI

studying core.clj, questions on read-lines, lazy-seq, and if-let

2010-06-07 Thread toddg
I'm attempting to read and understand core.clj, and I'm walking through methods as I run into them, trying to understand them, line by line. I' mostly understand read-lines (w/ the exception of the last line), but I do not follow lazy-seq or if-let. Could someone check my deconstruction of read-lin

problem with Character/isLetter

2010-06-07 Thread AJ Sterman
(Character/isLetter "x") # i tried a few "use ' " and there was no avail Thank you for trying to help -- 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

Loop and Recur

2010-06-07 Thread Jon Seltzer
I'm still learning Clojure and doing so by reading everything on clojure.org. I ran across this example in the Functional Programming section: (defn my-zipmap [keys vals] (loop [my-map {} my-keys (seq keys) my-vals (seq vals)] (if (and my-keys my-vals) (recur (assoc

A simple distribution service

2010-06-07 Thread schani
Hi everybody, I've implemented a very simple job distribution service: http://github.com/schani/clj-simple-dist It's based on RMI, so it requires Clojure 1.2 to serialize Clojure data. It's (supposed to be) fault-tolerant, very simple to set up and even has a little web interface that reports

Re: numerator fn

2010-06-07 Thread Dave Pawson
On 7 June 2010 07:58, Steve Purcell wrote: > On 7 Jun 2010, at 04:28, Dave Pawson wrote: > >> On 6 June 2010 13:35, Moritz Ulrich wrote: >>> Note the "Added in Clojure version 1.2" in the documentation of numerator >>> ;-) >> >> >> Not until I'd blown up the text. >> Don't expect text that size

Re: Complex type in clojure

2010-06-07 Thread Steven Devijver
For what it's worth, I found that working with complex numbers in clojure doesn't require specialist types or notation at all: (defn complex-times [[a_re a_im] [b_re b_im]] [(- (* a_re b_re) (* a_im b_im)) (+ (* a_re b_im) (* a_im b_re))]) (defn complex-plus [[a_re a_im] [b_re b_im]] [(+ a_re b_r