sessions in Ring, Sandbar, Compojure, etc...

2011-05-09 Thread Shree Mulay
For the life of me, I can't get sessions to work, immaterial of which tutorial I try and get going??? Is there any tutorial out there that explicitly explains everything for a newb like me? After several round, I did successfully get form params to work! YEAH! But now, I'd like to create a login s

Re: Ok, so code is data...

2011-05-09 Thread Justin Kramer
'read' and 'read-string' are what you're looking for. They each read a single Clojure object from an input source (PushbackReader for read, String for read-string). Alternatively, something like this can read all top-level forms from a file: (defn read-all "Reads all top-level forms from f, whi

Re: A simulation of the Monty Hall Problem

2011-05-09 Thread Ken Wesson
On Mon, May 9, 2011 at 11:26 PM, Ken Wesson wrote: > The code is idiomatic Clojure, using sequence functions in preference > to loop/recur and itself using higher order functions in what might be > described as a continuation-passing style. There is also no mutation > or impure function use except

Ok, so code is data...

2011-05-09 Thread Bill Robertson
How do I actually manipulate it? I have some complicated logic that I would like to transform into html (or maybe xml) for display purposes. I'm generating the Clojure code by parsing some nasty Java and outputting s-expressions. The Java is basic, but quite deeply nested. I want to generate wo

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Christian Schuhegger
Many thanks for all of your contributions so far! I definitely will (and already have to some extent) go through the recommended links. One additional project I came across that looks interesting is midje: https://github.com/marick/Midje/wiki I see the point of having a forum to discuss best solut

A simulation of the Monty Hall Problem

2011-05-09 Thread Ken Wesson
>From http://en.wikipedia.org/wiki/Monty_Hall_problem we have this description of the Monty Hall Problem: > Suppose you're on a game show and you're given the choice of three > doors [and will win what is behind the chosen door]. Behind one > door is a car; behind the others, goats [unwanted booby

Re: [clojure-jark-dev] Re: ANN: Jark 0.3 (using the nrepl protocol)

2011-05-09 Thread isaac praveen
> > Of course, it would be desirable to be able to not blow all the user's > computer memory ... so maybe having the ability to share JVM between > several open projects in the IDEA, while keeping isolated different > clojure environments, would be a plus. > > I had the idea of investigating what t

Re: ANN: Jark 0.3 (using the nrepl protocol)

2011-05-09 Thread isaac praveen
> Just a question. The general philosophy of clojure is to have good > base building tools, and maybe the "building blocks" of more > integrated solutions could also be based on the same philosophy. > I mean, all the points listed in b) could / should / may (?) not be > tied to nrepl-server, should

ANN: Seesaw 1.0.0 (Clojure + Swing)

2011-05-09 Thread Dave Ray
Just a quick announcement that I've pushed an initial version of Seesaw, my Clojure + Swing experiment, to Clojars. If anyone gives it a try, I'd love to hear feedback. On GitHub here: https://github.com/daveray/seesaw Cheers, Dave -- You received this message because you are subscribed to

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Ken Wesson
On Mon, May 9, 2011 at 6:43 PM, Mike Meyer wrote: > One thing that happens to such posts is they turn into threads of > "best way to solve this problem" - where "best" varies by author. I'm not sure if you intended this as a criticism of the idea, or if you are thinking the same thing I am, but I

Re: Efficient moving average

2011-05-09 Thread Ken Wesson
On Mon, May 9, 2011 at 6:55 PM, Andy Fingerhut wrote: > (ns movavg >  (:gen-class)) > > (set! *warn-on-reflection* true) > > > (defn sliding-window-moving-average [window lst] >  (let [w (int window) >        w-1 (int (dec w))] >    (loop [rolling-sum (apply + (take w lst)) >           last-w (obj

Re: ANN: Jark 0.3 (using the nrepl protocol)

2011-05-09 Thread Laurent PETIT
Sooo, my question was *that* silly ? :'-( 2011/5/7 Laurent PETIT : > Maybe a silly question, but anyway ... > > for CCW, there is this idea of having it maintain, for each open > project (probably depending on a flag, but that's out of topic), in > the background (totally transparently for the use

Re: Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
On Mon, May 9, 2011 at 17:50, Chris Perkins wrote: > On May 9, 8:00 am, Simon Katz wrote: > > I'm trying to implement a function similar to new, but where > > the type is not known at compile time -- so I want to evaluate > > the first argument. > > > > With the help of Google, I found the approa

Re: Efficient moving average

2011-05-09 Thread Andy Fingerhut
On May 9, 2011, at 6:45 AM, Andreas Kostler wrote: > Hi all, > I'm trying to calculate the moving average of a certain window size. > One straight forward approach is: > (defn lazy-avg [coll] > (let [[sum cnt] (reduce > (fn [[v c] val] [(+ val v) (inc c)]) > [

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Cool. I look forward to having approved 1.0.0 releases of contrib libraries. On May 9, 3:28 pm, Sean Corfield wrote: > On Mon, May 9, 2011 at 2:38 PM, Armando Blancas > > wrote: > > Having no clue what to make of 0.0.1 precisely w.r.t. its previous > > versions numbers, I gathered it's because y

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Mike Meyer
On Mon, 9 May 2011 03:24:44 -0700 (PDT) Chris Perkins wrote: > I have been thinking for while that it would be great to have > something equivalent to book clubs for reading code. A group could > meet weekly, all having read the same moderate-sized project, and > discuss. I wonder if this could be

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Sean Corfield
On Mon, May 9, 2011 at 2:38 PM, Armando Blancas wrote: > Having no clue what to make of 0.0.1 precisely w.r.t. its previous > versions numbers, I gathered it's because you can't make out anybody's > modules anyway, in which I agree. Well, the previous modules didn't really have version numbers in

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Ken Wesson
On Mon, May 9, 2011 at 6:06 PM, Paul deGrandis wrote: > I really like the code in Stuart Sierra's lazytest: > https://github.com/stuartsierra/lazytest/tree/master/modules/lazytest/src/main/clojure/lazytest > > The code in Enlive is also a really great read: > https://github.com/cgrand/enlive > > I

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Paul deGrandis
I really like the code in Stuart Sierra's lazytest: https://github.com/stuartsierra/lazytest/tree/master/modules/lazytest/src/main/clojure/lazytest The code in Enlive is also a really great read: https://github.com/cgrand/enlive I also would recommend going through compojure. Pau On May 9, 10:4

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Having no clue what to make of 0.0.1 precisely w.r.t. its previous versions numbers, I gathered it's because you can't make out anybody's modules anyway, in which I agree. On May 9, 11:34 am, Sean Corfield wrote: > On Mon, May 9, 2011 at 8:22 AM, Armando Blancas > > wrote: > > Yeap. Release numb

Re: CfP: IEEE Software Special Issue: Algorithms and Today’s Practitioner

2011-05-09 Thread Ken Wesson
On Mon, May 9, 2011 at 11:38 AM, Cesare wrote: > Manuscripts must not exceed 4,700 words including figures and tables, > which count for 200 words each. Damn, it's not just the real estate market that's crashed. I remember when a picture was worth five times that many words! -- You received thi

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Sean Corfield
On Mon, May 9, 2011 at 8:22 AM, Armando Blancas wrote: > Yeap. Release numbers have become meaningless; your point is well > taken. Not sure what you mean by that? The "new contrib" libraries can be seen here, with their current, evolving version numbers: https://oss.sonatype.org/index.html#nex

Re: Creating instances of types not known at compile time

2011-05-09 Thread Chris Perkins
On May 9, 1:49 pm, Alan wrote: > On May 9, 9:50 am, Chris Perkins wrote: > > A mild gripe: we're in a language that doesn't make us use ugly names > like klass and clazz. Some will disagree with me for sure, but I think > it's more readable to simply use the symbol "class" when you're > talking a

Re: ANN: A Clojure library for the Facebook Graph API - clj-facebook-graph

2011-05-09 Thread Bojan Jovičić
Hi Max, I have started investigating this, and it works very nice. I am a noob in Clojure/Java and I have a question about posting to FB using your library. I tried something like this: *(def auth-token (facebook-auth-by-name)) (def auth-name (first (keys auth-token))) (with-facebook-auth-by-na

Re: Creating instances of types not known at compile time

2011-05-09 Thread Alan
On May 9, 9:50 am, Chris Perkins wrote: > On May 9, 8:00 am, Simon Katz wrote: > > I'm trying to implement a function similar to new, but where > > the type is not known at compile time -- so I want to evaluate > > the first argument. > > > With the help of Google, I found the approach used in ne

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Stuart Sierra
The code is somewhat out-of-date by now (pre-1.0 Clojure) but I wrote much of AltLaw.org in Clojure: https://github.com/stuartsierra/altlaw-template https://github.com/stuartsierra/altlaw-clojure-restlet https://github.com/stuartsierra/altlaw-crawler https://github.com/stuartsierra/altlaw-backend

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread gaz jones
compojure is often put forward as an example of good idiomatic clojure code: https://github.com/weavejester/compojure On Mon, May 9, 2011 at 10:55 AM, Meikel Brandmeyer wrote: > Hi, > > Am 09.05.2011 um 17:36 schrieb Jonathan Fischer Friberg: > >> I'm interested! >> >> The clojure source code is

Re: Creating instances of types not known at compile time

2011-05-09 Thread Chris Perkins
On May 9, 8:00 am, Simon Katz wrote: > I'm trying to implement a function similar to new, but where > the type is not known at compile time -- so I want to evaluate > the first argument. > > With the help of Google, I found the approach used in new* > below: > >     (ns dynamic-new) > >     (defn

Re: Creating instances of types not known at compile time

2011-05-09 Thread Jonathan Fischer Friberg
Well, that's sort of wanting to eat the cake and have it. It's impossible to resolve a symbol where it isn't known where it came from, if any resolving is to take place, it must assume to be in the current namespace. So yes, you're right; syntax-quote would work best here. Jonathan On Mon, May

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Meikel Brandmeyer
Hi, Am 09.05.2011 um 17:36 schrieb Jonathan Fischer Friberg: > I'm interested! > > The clojure source code is a pretty good read, hehe > > Jonathan > > https://github.com/clojure/clojure/tree/master/src/clj/clojure Although the code in the preamble of core there is explicitly *not* recommende

Re: Creating instances of types not known at compile time

2011-05-09 Thread Shantanu Kumar
Have you considered factory functions and macros? Macros might suit better if you are dealing with various records. (defmacro instance ([^Class c] `(new ~c)) ([^Class c & more] `(new ~c ~@more))) Since macros are expanded, qualified vs unqualified issue will be taken care of automatic

Re: Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
On Mon, May 9, 2011 at 16:21, Jonathan Fischer Friberg wrote: > Q1 This macro captures the correct namespace: > > (defmacro new* [type-name-as-symbol & args] > `(clojure.lang.Reflector/invokeConstructor > (ns-resolve ~*ns* ~type-name-as-symbol) > (to-array '~args))) > Unfortunately th

Re: CfP: IEEE Software Special Issue: Algorithms and Today’s Practitioner

2011-05-09 Thread Cesare
Please disregard the previous version as this is the one containing full submission information: Call for Submissions IEEE Software - Special Issue on Algorithms for Today's Practitioner Submissions due: 1st June 2011 Publication date: January/February 2012 IEEE Software seeks submissions for

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Jonathan Fischer Friberg
I'm interested! The clojure source code is a pretty good read, hehe Jonathan https://github.com/clojure/clojure/tree/master/src/clj/clojure On Mon, May 9, 2011 at 12:24 PM, Chris Perkins wrote: > On May 9, 2:21 am, Christian Schuhegger > wrote: > > Hello list, > > > > I have a question that p

Re: Creating instances of types not known at compile time

2011-05-09 Thread Jonathan Fischer Friberg
Never mind Q2, I didn't understand the question correctly. Jonathan On Mon, May 9, 2011 at 5:21 PM, Jonathan Fischer Friberg < odysso...@gmail.com> wrote: > Q1 This macro captures the correct namespace: > > (defmacro new* [type-name-as-symbol & args] > `(clojure.lang.Reflector/invokeConstructo

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Yeap. Release numbers have become meaningless; your point is well taken. On May 8, 7:11 pm, Sean Corfield wrote: > The library formerly known as clojure.contrib.sql has had it's first > non-snapshot release. > > Features added: > * returns generated keys for single record inserts > * supports nam

Re: Creating instances of types not known at compile time

2011-05-09 Thread Jonathan Fischer Friberg
Q1 This macro captures the correct namespace: (defmacro new* [type-name-as-symbol & args] `(clojure.lang.Reflector/invokeConstructor (ns-resolve ~*ns* ~type-name-as-symbol) (to-array '~args))) Q2 Backquote ` is unnecessary for symbols, use standard quote ' Q3 Answer to 1 fixes this

CfP: IEEE Software Special Issue: Algorithms and Today’s Practitioner

2011-05-09 Thread Cesare
~~ IEEE Software Special Issue Algorithms and Today’s Practitioner Call for Papers ~~ IEEE Software seeks submissions for a special issue on the topic of Algorith

Re: ANN: Jark 0.3 (using the nrepl protocol)

2011-05-09 Thread isaac praveen
> Yes, that would explain that.  In any case, all contributors to jark will > need to have CA's lodged before it (or parts of it) can be brought into > Clojure contrib. > http://clojure.org/contributing > - Chas Thanks Chas. Ambrose and myself will send the CA across. -- isaac -- You received

Re: Hi, simple problem from a newbie

2011-05-09 Thread Jonathan Fischer Friberg
I recommend reading a book about lisp. I liked land of lisp: http://landoflisp.com/ Practical common lisp should be good as well: http://www.gigamonkeys.com/book/ Some more: http://www.cliki.net/Lisp%20books When you have an understanding of lisp, you can move on to clojure. Practical clojure wo

Efficient moving average

2011-05-09 Thread Andreas Kostler
Hi all, I'm trying to calculate the moving average of a certain window size. One straight forward approach is: (defn lazy-avg [coll] (let [[sum cnt] (reduce (fn [[v c] val] [(+ val v) (inc c)]) [0 0] coll)] (if (zero? cnt) 0 (/ sum cnt)

Creating instances of types not known at compile time

2011-05-09 Thread Simon Katz
I'm trying to implement a function similar to new, but where the type is not known at compile time -- so I want to evaluate the first argument. With the help of Google, I found the approach used in new* below: (ns dynamic-new) (defn new* [type-name-as-symbol & args] (clojure.lang.R

Re: ANN: Jark 0.3 (using the nrepl protocol)

2011-05-09 Thread Chas Emerick
On May 7, 2011, at 1:31 PM, David Nolen wrote: > On Sat, May 7, 2011 at 12:50 PM, isaac praveen wrote: > Sure. We need very powerful clojure development and deployment tools. > My request for subscription to clojure-dev got declined :( > > Send in a CA! :) Yes, that would explain that. In any

Re: Order a sequence of maps with {:type :before [types]}

2011-05-09 Thread msappler
Hello Thanks for your answer. Yes it should throw an exception - there should be no cyclic orders. I want to use this for the initialisation functions of the game I am developing (http://resatori.com/cyber-dungeon-quest-alpha-1) There is a number of those functions and some need to come after so

Re: Reading clojure code of larger domain specific projects

2011-05-09 Thread Chris Perkins
On May 9, 2:21 am, Christian Schuhegger wrote: > Hello list, > > I have a question that perhaps may be relevant for more people. I > strongly believe that reading code of other people is an undervalued > discipline of all developers. Typically it just happens as a side > effect of working in a pro