Re: generator in Clojure

2010-10-15 Thread Konrad Hinsen
On 14 Oct 2010, at 21:52, clwham...@gmail.com wrote: I need a function that produces the 'next' value from a lazy-seq -- something like a Python generator. I imagine it would have to be some sort of closure like: (def next-sine (let [sines (atom (cycle (map sin (range 0 6.28 0.01]

Re: Java Source Indentation

2010-10-15 Thread Laurent PETIT
2010/10/15 B Smith-Mannschott bsmith.o...@gmail.com On Fri, Oct 15, 2010 at 04:13, David Jacobs develo...@allthingsprogress.com wrote: I've just started learning Clojure and I'm excited about what I see. The combination of power and sophistication in the language is refreshing, and I've

Re: resultset-seq

2010-10-15 Thread David Powell
On Thu 14/10/10 20:58 , Mark Engelberg mark.engelb...@gmail.com sent: Since no one chimed in with support or reasoning for resultset-seq's current lower-casing behavior, can we discuss changing it to case-maintaining behavior, or at least make it something you can set with an optional flag?

Re: Java Source Indentation

2010-10-15 Thread David Jacobs
I get that. However, broken can describe code on several different levels, not just on the level of compilation or execution. I would say that for a young aspiring language like Clojure, having readable, presentable source code is key, and that not having these things amounts to being broken,

Re: Help to optimize palindrome search from input file

2010-10-15 Thread siddarth shankar
i could get it down to around 1.6/1.7 seconds s...@sid-:~$ time clojure dummy.clj woohoo palindrome: eve woohoo palindrome: ranynar real0m1.739s user0m2.088s sys 0m0.124s made a couple of changes - only call 'palindrome?' for substrings between identical characters(between

Re: Java Source Indentation

2010-10-15 Thread Stuart Halloway
It's all about priorities. At this point the goal is to write Clojure in Clojure, so the useful lifecycle of Java indentation fixes is hopefully modest. If you are looking to spend time on Clojure, there are many tickets that need patches. :-)

Re: Test-driven development in Clojure

2010-10-15 Thread Felix H. Dahlke
Ah, I see, thank you. Multimethods take a while getting used to I guess :) Definitely better for my problem than defprotocol though. On 14/10/10 22:13, Armando Blancas wrote: Maybe something like this. Those calls polymorphic on the returrn value of the anynimous function, so this is more

clojure clr and jmv - portability and compatibility?

2010-10-15 Thread urza urza
Hello, I am new to clojure, so sorry if this is a stupid question, but: How portable are clojure programs between clojure clr and clojure jvm? For example, can i use clojure contrib in clr? How about Enlive or other libraries? Can I write one clj program that will run both in jvm and clr? Or is

(ab)using STM for longish calculations, network I/O

2010-10-15 Thread hobnob
Hi, I'm just starting to get my head wrapped around STM just by reading about it so I can make a decision on whether to port a Java project to Clojure. a) can STM transactions contain calculations that take a 'long' time, let's say computing the cryptographic hash of a plaintext. I'd 'ensure'

Re: (ab)using STM for longish calculations, network I/O

2010-10-15 Thread Timothy Baldridge
I can't answer most of these, but I'll take a crack at a) From my understanding of the clojure code, the answer to long running transactions will depend on your application. If you have one writer, and 100 readers, you'll be fine. The readers will read the old value while the writer is updating

Re: clojure clr and jmv - portability and compatibility?

2010-10-15 Thread Timothy Baldridge
From what I've been seeing of both clojure and clojure-clr...they aren't very portable at all. Pure clojure code should be fine. But since clojure likes to use the underlying VM for almost everything it can, you'll have issues. FileStream in CLR may not be the same as FileStream in Java. As a CLR

Re: (ab)using STM for longish calculations, network I/O

2010-10-15 Thread Nicolas Oury
dosync is a way of ensuring whole stateful operation is done atomically. (ie as if everything was happening in one step.) That contradicts b). During a whole dosync, you can only see one state of the world. If you do not need atomicity, do multiple dosync. You should create another abstraction

Best practices for protocols

2010-10-15 Thread K.
Hello, I'm a developping a Swing GUI in Clojure and follow the MVC patterns. The view implements a protocol for displaying data, and another one to register Swing listeners. Callbacks registered with the second protocol only access the UI through the view protocol. Each of this protocol has ~50

Newbie: Multiple String Operations

2010-10-15 Thread Paul
Hi all, I need to perform string replacement a number of times and currently achieve this using: (.replace (.replace (.replace (.replace string old new... Is there a more succinct and 'clojurish' way to do this? Thanks, P. -- You received this message because you are subscribed to the

Re: Newbie: Multiple String Operations

2010-10-15 Thread Meikel Brandmeyer
Hi, On 15 Okt., 16:25, Paul paul_bow...@yahoo.com wrote: (.replace (.replace (.replace (.replace string old new... Is there a more succinct and 'clojurish' way to do this? (- string (.replace old1 new1) (.replace old1 new1) ... (.replace oldN newN)) Sincerely Meikel -- You

Re: Best practices for protocols

2010-10-15 Thread Shantanu Kumar
From my experience, protocols are essentially contracts between various modules of the code base - the fewer they are (in number) the better my peace of mind! IMHO if you just need to pass around function implementations, consider using defrecord. (defrecord OrderProcessingView [fn1 fn2 fn3...])

Re: Newbie: Multiple String Operations

2010-10-15 Thread B Smith-Mannschott
On Fri, Oct 15, 2010 at 16:25, Paul paul_bow...@yahoo.com wrote: Hi all, I need to perform string replacement a number of times and currently achieve this using: (.replace (.replace (.replace (.replace string old new... Is there a more succinct and 'clojurish' way to do this? Instead of

Re: Newbie: Multiple String Operations

2010-10-15 Thread Laurent PETIT
user= (reduce (fn [s [old new]] (.replace s old new)) abcd [[a b] [b c] [c d]]) user= 2010/10/15 Paul paul_bow...@yahoo.com Hi all, I need to perform string replacement a number of times and currently achieve this using: (.replace (.replace (.replace (.replace string old new... Is

Re: Newbie: Multiple String Operations

2010-10-15 Thread Paul
Ooooh, lovely! P. On Oct 15, 3:31 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 15 Okt., 16:25, Paul paul_bow...@yahoo.com wrote: (.replace (.replace (.replace (.replace string old new... Is there a more succinct and 'clojurish' way to do this? (- string   (.replace old1 new1)  

Re: Best practices for protocols

2010-10-15 Thread Laurent PETIT
2010/10/15 K. kotot...@gmail.com Hello, I'm a developping a Swing GUI in Clojure and follow the MVC patterns. The view implements a protocol for displaying data, Stop!. When I read this, my mind cries Alert! potential java-in-clojure code here !. clojure promotes a generic approach to data

Re: (ab)using STM for longish calculations, network I/O

2010-10-15 Thread hobnob
Thanks Tim that with the readers and writers is what I figured. On Oct 16, 12:12 am, Timothy Baldridge tbaldri...@gmail.com wrote: I can't answer most of these, but I'll take a crack at a) From my understanding of the clojure code, the answer to long running transactions will depend on your

Newbie: Exceptions and map

2010-10-15 Thread bleibmoritztreu
Hi group, I'm playing around with Clojure for a few weeks now and quite like it. Today however I noticed one thing which puzzles me a lot, and maybe points at something very basic I've misunderstood, so I wanted to ask here: Why doesn't (do (map #(throw (Exception. %)) '(a)) true) throw any

Re: Best practices for protocols

2010-10-15 Thread K.
Stop!. When I read this, my mind cries Alert! potential java-in-clojure code here !. Sorry I didn't want to frighten you with the words MVC and Clojure in the same sentence :-). However, I think it's just the right approach to separate the presentation from the logic. I may be wrong and then

Re: Best practices for protocols

2010-10-15 Thread Laurent PETIT
2010/10/15 K. kotot...@gmail.com Stop!. When I read this, my mind cries Alert! potential java-in-clojure code here !. Sorry I didn't want to frighten you with the words MVC and Clojure in the same sentence :-). However, I think it's just the right approach to separate the presentation

when-first

2010-10-15 Thread Sunil S Nandihalli
Hello everybody, The evaluation of (when-first [[x y z] [1 2 3 4 5]] (+ x y z)) is returning nil I was expecting it to return 6 .. am I missing something ? Thanks, Sunil. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: when-first

2010-10-15 Thread Baishampayan Ghose
Hello everybody,  The evaluation of (when-first [[x y z] [1 2 3 4 5]] (+ x y z)) is returning nil I was expecting it to return 6 .. am I missing something ? when-first is a macro which will, in the above example get expanded to - (when (seq [1 2 3 4 5]) (let [[x y z] (first [1 2 3 4

Re: when-first

2010-10-15 Thread Sunil S Nandihalli
sorry ... the expression should have been .. the expression should have been (when-first [x [1 2 3 4 5]] (+ x 1 2)) and it works fine... Thanks .. :) Sunil. On Fri, Oct 15, 2010 at 9:38 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, The evaluation of

Re: Newbie: Exceptions and map

2010-10-15 Thread Mark Nutter
Map returns a lazy seq (which I suspect you already knew). Try it with doall instead of do. The do only wraps the map expression, it doesn't actually realize the seq. On Fri, Oct 15, 2010 at 11:39 AM, bleibmoritztreu jlewa...@uos.de wrote: Hi group, I'm playing around with Clojure for a few

Newbie : Java Interop question

2010-10-15 Thread oak
Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION I can import like this in Clojure =(import `(com.essbase.api.session IEssbase))` I can

Re: resultset-seq

2010-10-15 Thread Mark Engelberg
On Fri, Oct 15, 2010 at 1:49 AM, David Powell djpow...@djpowell.net wrote: I'm in favour of down-casing - at least by default.  Some processing is going to happen anyway, as column names might contain spaces, which wouldn't be allowed in keywords. -- Dave One of the more significant

Re: Best practices for protocols

2010-10-15 Thread Paul deGrandis
In this case I would most certainly use multimethods. This is the perfect use case for them. If you want your views themselves to have certain forms, you may consider applying protocols there. Paul On Oct 15, 8:57 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/10/15 K.

Re: Newbie : Java Interop question

2010-10-15 Thread .Bill Smith
Try using IEssbase/JAPI_VERSION instead (replace dot with slash). On Oct 15, 11:32 am, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class   (I) IEssbase       (C, s f) Home              (M, s) create(String) IEssbase              

Re: The vsClojure Project

2010-10-15 Thread Will Kennedy
Very cool! I've been working on something similar. Will check it out! On Oct 3, 4:49 pm, jmis jmis@gmail.com wrote: It's very encouraging to see others interested in the project.  I've added the licensing information to the grammar file.  There's a few other attributions I need to take

Is this bug in Google AppEngine, appengine-clj or Clojure itself?

2010-10-15 Thread Darren Clarke
I've been using Clojure 1.2 and appengine-clj for a project on AppEngine and two days ago it stopped working after the Google team released some newly refactored code to production. Short discussion of this problem on the AppEngine-Java discussion group is here:

Re: Best practices for protocols

2010-10-15 Thread K.
If your protocol functions generally look like : display that data on this view, then why not leverage multimethods and double dispatch ? I think I choose a misleading example, sorry about that. I'm working mainly with one kind of data, but there a lot of functions. For instance one function

Re: resultset-seq

2010-10-15 Thread Laurent PETIT
2010/10/15 Mark Engelberg mark.engelb...@gmail.com On Fri, Oct 15, 2010 at 1:49 AM, David Powell djpow...@djpowell.net wrote: I'm in favour of down-casing - at least by default. Some processing is going to happen anyway, as column names might contain spaces, which wouldn't be allowed in

Re: (ab)using STM for longish calculations, network I/O

2010-10-15 Thread peter veentjer
On Oct 15, 2:51 pm, hobnob hob...@ml1.net wrote: Hi, I'm just starting to get my head wrapped around STM just by reading about it so I can make a decision on whether to port a Java project to Clojure. a) can STM transactions contain calculations that take a 'long' time, let's say

Re: (ab)using STM for longish calculations, network I/O

2010-10-15 Thread Alyssa Kwan
On Oct 15, 7:57 pm, peter veentjer alarmnum...@gmail.com wrote: On Oct 15, 2:51 pm, hobnob hob...@ml1.net wrote: Hi, I'm just starting to get my head wrapped around STM just by reading about it so I can make a decision on whether to port a Java project to Clojure. a) can STM

Re: Newbie : Java Interop question

2010-10-15 Thread Randy Hudson
Nested classes require the syntax AClass$NestedClass -- this being the real name of the class in the JVM. Static members of classes are referenced as AClass/member -- essentially treating the class as a namespace of its static members. So this should do it: (IEssbase$Home/create

Re: Newbie : Java Interop question

2010-10-15 Thread Michael Ossareh
On Fri, Oct 15, 2010 at 09:32, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION Out of interest

Re: ANN: Emacs auto-complete plugin for slime users

2010-10-15 Thread Jarl Haggerty
Should autocomplete work in the swank repl? It works perfectly in a clj buffer but nothing happens in the repl. On Aug 19, 7:46 am, Phil Hagelberg p...@hagelb.org wrote: On Thu, Aug 19, 2010 at 6:21 AM, Steve Purcell st...@sanityinc.com wrote: I guess Phil's very busy, but if he can apply

Re: ANN: Emacs auto-complete plugin for slime users

2010-10-15 Thread Scott Jaderholm
Works for me in repl. I have too much slime/clojure customization code, not really sure what does what :) Maybe this: (defun slime-clojure-repl-setup () (when (string-equal clojure (slime-connection-name)) (message Setting up repl for clojure) (when (slime-inferior-process)