Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread Konrad Hinsen
On 12.01.2009, at 01:01, samppi wrote: > The problem is that even though "some" and "filter" are lazy, "alt" is > still not, so calling "(alt (sub-function1 c) ...)" in the meta-meta- > function still evaluates (sub-function1 c), etc. It could be shown in > the REPL: How about changing the inter

Re: How to create and read from a stream of random characters?

2009-01-12 Thread GS
> (defn seq-of-rand-strings [maxlength] >   (repeatedly (fn [] >     (apply str (take (rand-int maxlength) >                      (repeatedly #(char (+ (int \a) (rand-int 26) > > user=> (take 3 (seq-of-rand-strings 10)) > ("kae" "xwuwyp" "xa") Thanks Chouser. I learned some useful and i

Re: when performance matters

2009-01-12 Thread Konrad Hinsen
On 12.01.2009, at 06:41, Mark P wrote: > 1. Some of the algorithms I use have the potential > to be parallelized. I am hoping that as the number > of cores in PCs increase, at some point Clojure's > performance will beat C++'s due to Clojure's > superior utilization of multiple cores. (Any idea

YACS - Yes another one (Snake that is)

2009-01-12 Thread Tom Ayerst
Hi, Following in a growing tradition I have written YACS (Yet Another Clojure Snake); this one uses an Agent to hold the state and has separate GUI and model threads using invokeLater to update the GUI from the model in a thread safe way. At least that was the plan. My specific aims were to prac

Re: when performance matters

2009-01-12 Thread Christian Vest Hansen
On Mon, Jan 12, 2009 at 6:41 AM, Mark P wrote: > 1. Some of the algorithms I use have the potential > to be parallelized. I am hoping that as the number > of cores in PCs increase, at some point Clojure's > performance will beat C++'s due to Clojure's > superior utilization of multiple cores. (

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread Tom Ayerst
For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it works without it). Tom 2009/1/12 Tom Ayerst > Hi, > > Following in a growing tradition I have written YACS (Yet Another Clojure > Snake); this one uses an Agent to hold the state and has separate GUI and > model threads u

How can I be useful to Clojure?

2009-01-12 Thread HB
Hey, I would like to contribute to Clojure but I'm not a language designer, neither familiar with LISP :( How can I be useful to Clojure project? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" grou

What is a LISP dialect?

2009-01-12 Thread HB
Hey, Clojure is described as a modern dialect of LISP. What is a "LISP dialect"? Thanks. --~--~-~--~~~---~--~~ 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

Re: What is a LISP dialect?

2009-01-12 Thread Jeff Rose
Lisp languages stem from the general concept of representing a program as a data structure made up of lists. Hence, LISt Processing. There are a lot of variations in how things can work though, for example how variables are scoped and bound, how variables and functions are referenced, the bu

Re: when performance matters

2009-01-12 Thread bOR_
This might help: java libraries for fast computing. I guess they will be usable from within clojure as well. http://acs.lbl.gov/~hoschek/colt/ Welcome to the Colt Project. Colt provides a set of Open Source Libraries for High Performance Scientific and Technical Computing in Java. Scientific an

Re: How can I be useful to Clojure?

2009-01-12 Thread Tom Ayerst
1Learn Clojure 2Use it to solve real problems 3Help other people learn it 4Give feedback to Rich about issues so he can improve the implementation 5Maybe submit some useful generic pieces to Clojure Contrib 6Develop the first Killer App (Personally I'm still on 1 / 2) Chee

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread HB
What is (Yet Another Clojure Snake)? Something like YACC? On Jan 12, 1:15 pm, "Tom Ayerst" wrote: > For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it > works without it). > > Tom > > 2009/1/12 Tom Ayerst > > > Hi, > > > Following in a growing tradition I have written YAC

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread Tom Ayerst
I just knew someone would say that ;-) (Your acronymic options shrink once you start with Yet Another... ) If you haven't been following, search for Clojure Snake earlier in the list (or run the code). Cheers Tom 2009/1/12 HB > > What is (Yet Another Clojure Snake)? > Something like YACC? >

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread MikeM
Not a macro, but does what you want: (defn alt [& functions] (fn [tokens] (some #((force %) tokens) functions))) ;define sub-functions the same way (defn a-meta-meta-function [c] (alt (delay (sub-function1 c)) (delay (sub-function2 c)) (delay (sub- function3 c --~--~-~--~-

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread Mark Volkmann
On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote: > For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it > works without it). Right. dosync starts a transaction. Agents and Atoms aren't affected by transactions. You only need dosync when working with Refs. > 2009/1/12 Tom

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread Chouser
On Mon, Jan 12, 2009 at 9:01 AM, Mark Volkmann wrote: > > On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote: >> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it >> works without it). > > Right. dosync starts a transaction. Agents and Atoms aren't affected > by transactio

Re: newbie question on binding

2009-01-12 Thread Michael Wood
On Tue, Jan 6, 2009 at 12:00 AM, wubbie wrote: > > Hi, > Why are there multiple "Logging str" output. Because str calls itself recursively. > Also in (apply str-orig args), I don't see any args passed at all! I'm not sure what you mean here. The "args" in (apply str-orig args) is the list o

Re: YACS - Yes another one (Snake that is)

2009-01-12 Thread Mark Volkmann
On Mon, Jan 12, 2009 at 8:27 AM, Chouser wrote: > > On Mon, Jan 12, 2009 at 9:01 AM, Mark Volkmann > wrote: >> >> On Mon, Jan 12, 2009 at 5:15 AM, Tom Ayerst wrote: >>> For example, I am pretty sure I don't need to wrap 'send' in 'dosync' (it >>> works without it). >> >> Right. dosync starts a

sending off 1,10,100,1000,10k,100k agents to do fib is fine, but 1M agents not

2009-01-12 Thread bOR_
Hi All. While familiarizing myself with different ways of making my models concurrent, I ran into something that might be a bug. given this code, and a 4core machine: (defn fib [n] (if (<= n 1) 1 (+ (fib (- n 1)) (fib (- n 2) (defn pow "from the tiny math library" [

Re: when performance matters

2009-01-12 Thread Stuart Sierra
Okay, I'm one of Clojure's biggest fans, and probably one of a very few using it regularly at work. But let me attempt to inject some reality into the discussion. The big advantages of Clojure are succinctness and expressiveness within a Java environment. If you have highly-optimized, custom-desig

Re: Why aren't lists callable?

2009-01-12 Thread Stuart Sierra
On Jan 12, 12:11 am, Mark Fredrickson wrote: > I can't imagine this idea will be met warmly, but I have a suggestion.   > It requires ending maps and vectors as functions of keys. Instead,   > make the first argument to a collection be a function which is mapped   > to across the collection. Any

Re: Why aren't lists callable?

2009-01-12 Thread Rich Hickey
On Jan 12, 10:31 am, Stuart Sierra wrote: > On Jan 12, 12:11 am, Mark Fredrickson > wrote: > > > I can't imagine this idea will be met warmly, but I have a suggestion. > > It requires ending maps and vectors as functions of keys. Instead, > > make the first argument to a collection be a functi

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread samppi
Awesome—thanks for everyone's answers; I think I'll go with delay/ force. What I'm a little worried about is the caching. After a calling of "alt" finishes, what happens to all those Delay objects and their cached values? Are they garbage-collected, or will they remain indefinitely? Should I worry

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread Konrad Hinsen
On Jan 12, 2009, at 17:11, samppi wrote: > Awesome—thanks for everyone's answers; I think I'll go with delay/ > force. What I'm a little worried about is the caching. After a calling > of "alt" finishes, what happens to all those Delay objects and their > cached values? Are they garbage-collected

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread MikeM
> After a calling > of "alt" finishes, what happens to all those Delay objects and their > cached values? Are they garbage-collected, or will they remain > indefinitely? Should I worry? > I believe the references to the delays will be dropped as alt executes, so they'll be eligible for grabage c

Re: what does -> mean?

2009-01-12 Thread Michael Reid
On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs wrote: > > I've also found this useful for accessing members in nested maps. For > example: > > (let [me {:person {:name {:first "Mark" >:last "Triggs"} > :email "mark.h.tri...@gmail.com"}}] >(-> me

Re: How can I be useful to Clojure?

2009-01-12 Thread Vincent Foley
If you have a blog, you may certainly write about your experience, the difficulties you encountered learning the language, etc. This can provide valuable help to other new users as well as give an indication of what the documentation should cover. On Jan 12, 4:21 am, HB wrote: > Hey, > I would

Re: newbie question on binding

2009-01-12 Thread Meikel Brandmeyer
Hi, I'm sorry. I wanted to answer you but it somehow got lost. Am 05.01.2009 um 23:00 schrieb wubbie: Why are there multiple "Logging str" output. As Michael already said, it's because the originial str calls itself recursively. Here is a thread, which explains this in more detail. http:/

Re: non recursive impl in presence of persistence?

2009-01-12 Thread James Reeves
On Jan 12, 5:24 am, e wrote: > It's funny, whenever I tried to be all safe like this and take the time to > make stuff safe in C++, coworkers would say, "we are grown-ups.  At some > point you gotta stop being a paranoid programmer. Given that software bugs are a very common occurrence, I'd say

Re: what does -> mean?

2009-01-12 Thread Mark Volkmann
On Mon, Jan 12, 2009 at 11:15 AM, Michael Reid wrote: > > On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs wrote: >> >> I've also found this useful for accessing members in nested maps. For >> example: >> >> (let [me {:person {:name {:first "Mark" >>:last "Triggs"} >>

Re: How to create and read from a stream of random characters?

2009-01-12 Thread Brian Doyle
Chouser's solution works well, but I found that you can end up with an empty string sometimes or never getting the maxlength that you passed in. 1:2 user=> (take 3 (seq-of-rand-strings 10)) ("ngene" "" "dwlbzndqx") I added an inc before calling the take and that clears things up. (defn seq-of-ra

Re: what does -> mean?

2009-01-12 Thread kkw
Yeah, doto is a handy complement to ->. I forgot about doto, and there's a place some code which I'll use now. Thanks Mark! Kev On Jan 13, 6:38 am, "Mark Volkmann" wrote: > On Mon, Jan 12, 2009 at 11:15 AM, Michael Reid wrote: > > > On Sun, Jan 11, 2009 at 9:12 PM, Mark Triggs > > wrote: > >

Re: Parameterized query with clojure.contrib.sql

2009-01-12 Thread Greg Harman
I couldn't figure out how to do this with the included functions/ macros in clojure.contrib.sql so I massaged with-results and do- prepared together to get this macro (with supporting fn), which seems to work. Useful addition for contrib.sql? ;; query-with-results should work just like with-resul

Example Java oriented SWT GUI application in Clojure

2009-01-12 Thread BerlinBrown
Here is an example SWT application. It is a 'search' tool. Open a file and the search term is highlighted. It has a java oriented approach because I copied the java code verbatim. This might be useful if you are still used to imperative programming. Main source: http://jvmnotebook.googlecode.

Re: Strange 'new' constructor error

2009-01-12 Thread BerlinBrown
Just a bug in my code, sorry. On Jan 9, 6:49 pm, BerlinBrown wrote: > Does anyone see what I am doing here. I am creating someSWTcode. > > > > (import '(org.eclipse.swt.widgets Display Shell Text Widget)) > (import '(org.eclipse.swt.widgets Label Menu MenuItem Control)) > (import '(org.ecl

Re: Why aren't lists callable?

2009-01-12 Thread Jason Wolfe
For mapping across maps I often find the following utility helpful: (defn map-map "Like map, but expects f to produce pairs that are combined to produce a map output." [f & maps] (reduce #(conj %1 %2) {} (apply map f maps))) 1:1 user=> (map-map (fn [[k v]] [k (str v " Mark")]) {:greet "hello"

Re: sending off 1,10,100,1000,10k,100k agents to do fib is fine, but 1M agents not

2009-01-12 Thread Timothy Pratley
Hi Boris > (something goes wrong when sending off a million agents, and for a > while I am only using 1 of the four CPU's.) > (using send or send-off doesn't seem to make a difference here, > performance or crash-wise) Your issue is not agent specific, consider this code which for me blows up wi

Utilities for clojure.contrib?

2009-01-12 Thread Jason Wolfe
Hi all, I've got lots of utilities that I think people might find useful, and might fit well in clojure.contrib (just sent in my contrib agreement last week). I don't know how the process works to get code in there, but I figured I'd go ahead and post them all here so people can chime in about wh

Re: Why aren't lists callable?

2009-01-12 Thread Ethan Herdrick
Then why are sets callable? Not that I'm complaining - I found it handy, then came to wonder why lists aren't. -Ethan > I'd just like to add to this discussion that maps and vectors are > functions not just because it's neat or possible, with the > implementation one of many possibilities, but

java.lang.IncompatibleClassChangeError: [class] and [inner class] disagree on InnerClasses attribute

2009-01-12 Thread Mark Triggs
Hi all, I've just been fiddling with Lucene indexing from Clojure, and wanted to access a static field of this inner class: http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexWriter.MaxFieldLength.html I'm importing IndexWriter$MaxFieldLength with no problems, but attempts

Re: Why aren't lists callable?

2009-01-12 Thread Chouser
On Mon, Jan 12, 2009 at 5:56 PM, Jason Wolfe wrote: > > For mapping across maps I often find the following utility helpful: > > (defn map-map "Like map, but expects f to produce pairs that are > combined to produce a map output." > [f & maps] (reduce #(conj %1 %2) {} (apply map f maps))) > > 1:

Something's possibly wrong with backquote expansion.

2009-01-12 Thread Rock
After a fair amount of macro writing in CL, I think I got the backquote expansion mechanism pretty much nailed down (after all, it is quite clear in the HyperSpec). Now, I thought I understood the Clojure algorithm just as well. It looked very similar (concat instead of append and so on). Apart fr

Re: java.nio.channels.FileChannel.MapMode

2009-01-12 Thread Attila Babo
user=> (import '(java.nio.channels FileChannel)) nil user=> java.nio.channels.FileChannel$MapMode/READ_ONLY # Sorry for the noise! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

java.nio.channels.FileChannel.MapMode

2009-01-12 Thread Attila Babo
To achieve high speed IO I've tried to used mapped FileChannel but failed to specify MapMode. user=> (import '(java.nio.channels.FileChannel MapMode)) java.lang.ClassNotFoundException: java.nio.channels.FileChannel.MapMode (NO_SOURCE_FILE:0) while user=> (import '(java.nio ByteOrder)) nil user

Re: Why aren't lists callable?

2009-01-12 Thread Stuart Sierra
A set is, in a sense, a function mapping from arbitrary objects to Boolean values. If the object is in the set, it returns true. A list, in the Lisp world at least, only has two elements, first and rest (car and cdr in older Lisps). A list object isn't really a "complete" collection the way vector

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
I give up.I don't know what's wrong and I don't want to just punt and go on to a totally different implementation. Can while loops have more that one statement in the body? Maybe it's something dumb. I'm not turning my back on what people say about loop/recur or functional programming. I'm

Re: Something's possibly wrong with backquote expansion.

2009-01-12 Thread Rich Hickey
On Jan 12, 6:49 pm, Rock wrote: > After a fair amount of macro writing in CL, I think I got the > backquote expansion mechanism pretty much nailed down (after all, it > is quite clear in the HyperSpec). Now, I thought I understood the > Clojure algorithm just as well. It looked very similar (co

Re: Something's possibly wrong with backquote expansion.

2009-01-12 Thread Rock
OK. Perfect. Thanks. I was worried there for a moment. Next time I'll read the docs more carefully. My fault. On Jan 13, 3:29 am, Rich Hickey wrote: > On Jan 12, 6:49 pm, Rock wrote: > > > > > After a fair amount of macro writing in CL, I think I got the > > backquote expansion mechanism prett

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
i forgot about the wiki. why is this maintained in a totally different page from clojure.org? I should be looking at these examples: http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples On Mon, Jan 12, 2009 at 9:15 PM, e wrote: > I give up.I don't know what's wrong and I

Re: Example Java oriented SWT GUI application in Clojure

2009-01-12 Thread e
what is "set!"? I don't see that in the api On Mon, Jan 12, 2009 at 5:24 PM, BerlinBrown wrote: > > Here is an example SWT application. It is a 'search' tool. Open a > file and the search term is highlighted. It has a java oriented > approach because I copied the java code verbatim. This mi

command-line in clojure.contrib suggestions

2009-01-12 Thread aria42
Hi, I've got some suggestions for improving command-line.clj... It would be great if you could provide a function to be called with the value of the option and the result of that function binds to the variable. This would take care of the annoying stuff like calling (Integer/parseInt intAsStr)

Re: Example Java oriented SWT GUI application in Clojure

2009-01-12 Thread Matt Revelle
http://clojure.org/vars#toc1 On Jan 12, 2009, at 9:42 PM, e wrote: > what is "set!"? I don't see that in the api > > On Mon, Jan 12, 2009 at 5:24 PM, BerlinBrown > wrote: > > Here is an example SWT application. It is a 'search' tool. Open a > file and the search term is highlighted. It has

Re: Example Java oriented SWT GUI application in Clojure

2009-01-12 Thread e
thanks. I think this will be useful, but I have to figure out how to get it to build in enclojure. Right now I get, "Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name octane_main, locale en_US (octane_main.clj:136)" On Mon, Jan 12, 2009 at 5:24 PM, Be

Re: non recursive impl in presence of persistence?

2009-01-12 Thread Timothy Pratley
> I just want to get this out of my system, but I'm getting some class cast > exception and no useful line number. In situations like these I find that looking at the entire stack trace provides clues. The REPL by default does not print the entire stack though I'm sure there is a way to achieve t

typo near http://clojure.org/API#toc248

2009-01-12 Thread .Bill Smith
The gen-class documentation at http://clojure.org/API#toc248 has a minor typo: the description of the :state keyword begins at the end of the :factory paragraph instead of beginning a new paragraph. Not a big deal but it makes the :state description harder to find. --~--~-~--~~---

Re: command-line in clojure.contrib suggestions

2009-01-12 Thread Chouser
On Mon, Jan 12, 2009 at 9:44 PM, aria42 wrote: > > Currently, you'd need to do something like this, where you might re- > def the var > > (with-command-line *command-line-args* > "my-program" > [[picture "Path to Picture" "/default/path"]] > (def picture (load-picture picture)) > (blah)) I u

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
o! all the stuff from listmerge ended up in my-list directly. so then when listmerge was called on these elements it rightly complained! Awesome. Lots of good lessons coming out of this. I need to learn how to run closure code as a script then. I seem to remember something about this w

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
by the way, Tim, I've seen NB before as comments in J. What's it stand for? On Mon, Jan 12, 2009 at 10:39 PM, e wrote: > o! all the stuff from listmerge ended up in my-list directly. so > then when listmerge was called on these elements it rightly complained! > Awesome. Lots of good

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
o #2 . . . and I totally lost site of what I was doing with l1 and l2 ! they were already lists because my-list was a list of lists. I new that when I started, like on Friday. On Mon, Jan 12, 2009 at 10:39 PM, e wrote: > o! all the stuff from listmerge ended up in my-list d

Re: command-line in clojure.contrib suggestions

2009-01-12 Thread aria42
Couldn't it have access to the other bindings so far like let? And then just have the order of options reflect the partial order induced by dependency? So is this possible... (with-command-line *command-line-args* "my-program" [[size "The size of something" #(if % (Integer/parseInt %) 99)]

Re: non recursive impl in presence of persistence?

2009-01-12 Thread Timothy Pratley
> by the way, Tim, I've seen NB before as comments in J.  What's it stand for? An abbreviation for nota bene, a Latin expression meaning "note well". > I need to learn how to run closure code as a script then. http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started first section shows

Re: Utilities for clojure.contrib?

2009-01-12 Thread Chouser
On Mon, Jan 12, 2009 at 6:48 PM, Jason Wolfe wrote: > > (defn map-when "Like map but discards logically false entries" > [fn & seqs] > (filter identity (apply map fn seqs))) I'd use map-when. > (defn iterate-while [f x] > (take-while identity (iterate f x))) This one too. It raises a quest

Re: when performance matters

2009-01-12 Thread Mark P
> It all depends on your algorithms and your code. Clojure has lots of   > support (data structures and algorithms) for concurrent programming,   > but you have to choose and combine them yourself to get efficient   > parallelization. I know that there are other functional approaches where the co

[ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Mark McGranaghan
Hi All, I'm happy to announce the alpha release of 'Ring', a library inspired by Python's WSGI and Ruby's Rack for developing web applications in Clojure. I've made it as easy as humanly possible for you to try it out: git clone git://github.com/mmcgrana/ring.git cd ring java -Djava

Re: [ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Matt Revelle
Mark, This looks great! Thanks for writing and sharing. -Matt On Jan 12, 2009, at 11:45 PM, Mark McGranaghan wrote: > > Hi All, > > I'm happy to announce the alpha release of 'Ring', a library inspired > by Python's WSGI and Ruby's Rack for developing web applications in > Clojure. > > I've m

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
my unsafe version works now, thanks to a LOT of help. (defn msort [toSort] (with-local-vars [my-list (for [x toSort] [x])] (while (rest @my-list) (let [[l1 l2 & my-list-rest] @my-list] (var-set my-list (conj my-list-rest (listmerge l1 l2))) )) (first @my-list))) now I'm try

Re: [ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Dan Larkin
I'm incredibly impressed! Have only looked at the code briefly but I read the whole post and I'm really excited for where this is going. On Jan 12, 2009, at 11:45 PM, Mark McGranaghan wrote: > > Hi All, > > I'm happy to announce the alpha release of 'Ring', a library inspired > by Python's W

Re: when performance matters

2009-01-12 Thread Mark P
> JNA might be an alternative to JNI:https://jna.dev.java.net/ > But I wouldn't know; haven't used either. Thanks for this info. It sounds like JNA may be worth looking into. Cheers, Mark. --~--~-~--~~~---~--~~ You received this message because you are subscrib

Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread CuppoJava
Hi, I'm still getting used to the primitive support in Clojure, and I want to confirm my understanding. As far as I know, primitive support is only supported in local let bindings, right? So in designing a vector math library, To translate from Java, one would write a class with primitive field

Re: non recursive impl in presence of persistence?

2009-01-12 Thread Timothy Pratley
>    (if (l2) The problem is on this line. (l2) is a function call. Replace with (if l2 and it works fine :) java.lang.IllegalArgumentException: Wrong number of args passed to: LazilyPersistentVector (NO_SOURCE_FILE:0) The error message bears a little explaining: vectors are functions, user=> (

Re: [ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Paul Barry
What's does the req object that is passed into the function have in it? On Mon, Jan 12, 2009 at 11:45 PM, Mark McGranaghan wrote: > > Hi All, > > I'm happy to announce the alpha release of 'Ring', a library inspired > by Python's WSGI and Ruby's Rack for developing web applications in > Clojure.

Re: [ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Paul Barry
To answer my own question: [#^HttpServletRequest request] {:server-port (.getServerPort request) :server-name (.getServerName request) :remote-addr (.getRemoteAddr request) :uri (.getRequestURI request) :query-string (.getQueryString request) :scheme (keyword (.getScheme request)

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
seriously? Wow! Interesting. On Tue, Jan 13, 2009 at 12:53 AM, Timothy Pratley wrote: > > >(if (l2) > > The problem is on this line. (l2) is a function call. > Replace with (if l2 > and it works fine :) > > java.lang.IllegalArgumentException: Wrong number of args passed to: > LazilyPersiste

Re: Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread e
I hear about boxing a lot. What is it? Thanks. On Tue, Jan 13, 2009 at 12:49 AM, CuppoJava wrote: > > Hi, > I'm still getting used to the primitive support in Clojure, and I want > to confirm my understanding. > > As far as I know, primitive support is only supported in local let > bindings, ri

Can't lookup java.lang.Long keys in a map using int literal

2009-01-12 Thread Allen Rohner
Keys in a map that are of type long can't be looked up in a map using int literal syntax: user=> (def my_map { (java.lang.Long. "42") "foo"}) #'user/my_map user=> my_map {42 "foo"} user=> (my_map 42) nil user=> (my_map (long 42)) "foo" user=> (= 42 (java.lang.Long. "42")) true I found this b

Re: when performance matters

2009-01-12 Thread Mark P
On Jan 13, 1:21 am, Stuart Sierra wrote: > If you have > highly-optimized, custom-designed numerical algorithms written in a > low-level language like C++, you will never be able to write a version > that is equally fast in a dynamic, virtual-machine language. I think you are essentially right (

Re: Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread CuppoJava
Do you know Java? It'll be easier to explain if you do. In Java, everything is an Object. Object's are treated as references to a specific memory location which holds the actual data. So when you pass an Object to a method, you're only passing the method the memory location of that Object. For p

Re: when performance matters

2009-01-12 Thread e
There's a study someone did that compared C++, Java, and Lisp implementations of various problems. It could be urban legend, but how I remember it: The best C++ implementation was the fastest for each problem. But the average lisp implementation was faster then the average java or C++ implementat

Re: Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread Timothy Pratley
> {:x 0 :y 0 :z 0} > I think a map would have too much overhead to retrieve and set keys. > Is that correct? Although this is the most straight-forward > conversion. How about a structmap? http://clojure.org/data_structures "StructMaps Often many map instances have the same base set of keys, for

Re: non recursive impl in presence of persistence?

2009-01-12 Thread e
Instead of that being an error, why not overload the vector function so that no args calls the version that returns the list. That seems like a good idea! I wonder if people will object. On Tue, Jan 13, 2009 at 1:23 AM, e wrote: > seriously? Wow! Interesting. > > > On Tue, Jan 13, 2009 at 12

Re: [ANN] Ring: A Web application library for Clojure.

2009-01-12 Thread Mark McGranaghan
>> What's does the req object that is passed into the function have in it? The contents of the incoming Ring request (and outgoing Ring response) are described in the SPEC document. I should make this a little clearer in the docs. Good for you for checking the source though! > Which by the way i

Re: Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread e
ah great explanation. That will help a lot. I found that annoying in Java. On Tue, Jan 13, 2009 at 1:38 AM, CuppoJava wrote: > > Do you know Java? It'll be easier to explain if you do. > > In Java, everything is an Object. Object's are treated as references > to a specific memory location w

Re: non recursive impl in presence of persistence?

2009-01-12 Thread Timothy Pratley
On Jan 13, 5:57 pm, e wrote: > Instead of that being an error, why not overload the vector function so that > no args calls the version that returns the list.  That seems like a good > idea!  I wonder if people will object. Actually in your case that would not work, because l2 can also be nil.

Re: Designing a Performance Vector Math library in Clojure.

2009-01-12 Thread Timothy Pratley
BTW Rich, The documentation http://clojure.org/data_structures hints that accessors are faster than regular map lookups and provides the following example: (reduce (fn [n y] (+ n (:fred y))) 0 x) -> 45 (reduce (fn [n y] (+ n (fred y))) 0 x) -> 45 However I think it would be cle

Re: when performance matters

2009-01-12 Thread Zak Wilson
Lisps are not inherently slow. SBCL, Clojure and several Schemes are all much faster than most popular high-level languages (e.g. Python, Perl, Ruby...) while being at least as high-level. Optimized code in SBCL may only be marginally slower than C when type declarations are used properly. The co

Re: when performance matters

2009-01-12 Thread Zak Wilson
You're probably thinking of this: http://www.flownet.com/gat/papers/lisp-java.pdf There's also the (in)famous language benchmark site: http://shootout.alioth.debian.org/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

How much Clojure source code is complicated?

2009-01-12 Thread HB
Hey, How much Clojure source code is complicated? I'm not a programming Godfather but I would like to study Clojure source code. Could an intermediate programmer like me grasp the source code? Thanks. --~--~-~--~~~---~--~~ You received this message because you are s