Re: About a networked REPL...

2011-03-20 Thread blais
On Mar 20, 10:48 pm, blais wrote: > really valuable, because it is unlikely to break between versions, and > it's already good enough for a lot of users via stdin/stdout pipes > (i.e., inferior lisp). Like being able to just telnet to a running VM and type "(+ 2 2)" and see "4" printed on stdout.

Re: About a networked REPL...

2011-03-20 Thread blais
On Mar 20, 12:16 pm, Chas Emerick wrote: > Martin, > > Thank you for the pushback.  :-) I'm not pushing back, I'm really just trying to understand... > On Mar 19, 2011, at 8:30 PM, Martin Blais wrote: > >  I think this is wrong, because every single IDE client > >  will have to adapt itself to

Re: Not quite getting for (newb question)

2011-03-20 Thread Andreas Kostler
No worries, always a pleasure :) On 21/03/2011, at 12:43 PM, Brett Morgan wrote: > Ahh, got it. Thank you Andreas. > > On Sun, Mar 20, 2011 at 6:55 PM, Andreas Kostler > wrote: > Hi Brett, > A :while clause continues the evaluation ONLY while it's expression is true > > (for [x (range 10) y (r

Re: Not quite getting for (newb question)

2011-03-20 Thread Brett Morgan
Ahh, got it. Thank you Andreas. On Sun, Mar 20, 2011 at 6:55 PM, Andreas Kostler < andreas.koestler.le...@gmail.com> wrote: > Hi Brett, > A :while clause continues the evaluation ONLY while it's expression is true > > (for [x (range 10) y (range 10) :while (< x y)] [x y]) will terminate as > soon

Re: Not quite getting for (newb question)

2011-03-20 Thread Andreas Kostler
Hi Brett, A :while clause continues the evaluation ONLY while it's expression is true (for [x (range 10) y (range 10) :while (< x y)] [x y]) will terminate as soon as (< x y) is false. Since (< 0 0) is the first expr to evaluate, evaluation stops right there. What you want is (for [x (range 10

Not quite getting for (newb question)

2011-03-20 Thread Brett Morgan
Hey all, I'm not understanding why the following examples don't line up. In my mind they should be identical. What am i not getting? (user=> (filter (fn [[x y]] (< x y)) (for [x (range 10) y (range 10)] [x y])) ([0 1] [0 2] [0 3] [0 4] [0 5] [0 6] [0 7] [0 8] [0 9] [1 2] [1 3] [1 4] [1 5] [1 6] [

Re: About a networked REPL...

2011-03-20 Thread James Reeves
On 21 March 2011 00:18, Chas Emerick wrote: > In any case, my objective with nREPL was to get something working well that > had what I thought were the right semantics for the use cases I was concerned > with (i.e. point-to-point Clojure tooling backends).  Lifting those semantics > onto other

Re: About a networked REPL...

2011-03-20 Thread Chas Emerick
The number indicates the number of entries in the following message; and yes, you're right that a sentinel would have been sufficient to terminate each message, though I wasn't attempting to follow in other protocols' footsteps. I'm sure the protocol is lacking in a variety of ways; as I said,

Re: About a networked REPL...

2011-03-20 Thread Chas Emerick
On Mar 20, 2011, at 12:47 PM, Kevin Downey wrote: > I am no python programmer, but if you look at > http://docs.python.org/library/socket.html you see it passes in the > number of bytes you wish to receive on a call to the receiv method on > a socket. With that in mind parsing nrepl messages becom

Re: Beginning Clojure

2011-03-20 Thread Andreas Kostler
Hi, Depending on your level of Lisp expertise, I'd suggest digging into Clojure frameworks like Ring or Compojure. You might find the books on Clojure interesting ("Practical Clojure", "Programming Clojure", "The Joy of Clojure", "Clojure in Action"). The latter two are work in progress (however,

Re: Dynamic scoping issue

2011-03-20 Thread Meikel Brandmeyer
Hi, Am 20.03.2011 um 22:41 schrieb Tassilo Horn: > Oh, yes. That was the exact issue. But clearly forcing realization is > not a good solution. Is there some better way to do what I want? > Maybe my macro should expand to something like that? > > ((fn [] (binding [...as before...] body))) S

Beginning Clojure

2011-03-20 Thread Ent SaaS
Hi, I would like to learn Clojure from a practical project approach. Where can I find resources? 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 Note that posts from new memb

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Well, get-with-exception attempts to model a restriction on a relation (e.g. select in sql) so I believe a missing key indeed indicates an error. On 21/03/2011, at 9:25 AM, Daniel Werner wrote: > On 20 March 2011 22:02, Andreas Kostler > wrote: >> Would that be flow control though? I see this e

Re: Throwing an Exception with get

2011-03-20 Thread Daniel Werner
On 20 March 2011 22:02, Andreas Kostler wrote: > Would that be flow control though? I see this exception as a rather > exceptional circumstance for this application... If a missing key signifies an error, then yes, it should probably throw an exception. It seems reading your code wrongly reminde

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 5:41 PM, Tassilo Horn wrote: > Ken Wesson writes: > > Hi Ken, > Does the resolving function run on, or use, another thread? >>> >>> No, it runs in the same thread.  But some functions like `vseq' in >>> the example produce LazySeqs.  So if LazySeq-realization computat

Re: Dynamic scoping issue

2011-03-20 Thread Tassilo Horn
Ken Wesson writes: Hi Ken, >>> Does the resolving function run on, or use, another thread? >> >> No, it runs in the same thread.  But some functions like `vseq' in >> the example produce LazySeqs.  So if LazySeq-realization computations >> are run in a different thread by default, that would exp

Re: About a networked REPL...

2011-03-20 Thread Kevin Downey
My objection has nothing to do with string vs. byte. Messages used in wire protocols exist on a continuum between fixed width and variable width. The happy medium there, which almost all protocols follow is a fixed width header that also provides the bye count of the following variable width body.

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 5:17 PM, Tassilo Horn wrote: > Ken Wesson writes: > >>> the println prints {Locality localities.Locality}, which is correct. >>> However, my resolving function errors because there is no class >>> Locality.  In the error message, I also print the value of >>> *schema-impor

Re: Dynamic scoping issue

2011-03-20 Thread Tassilo Horn
Ken Wesson writes: >> the println prints {Locality localities.Locality}, which is correct. >> However, my resolving function errors because there is no class >> Locality.  In the error message, I also print the value of >> *schema-imports*, and in fact, it is {}. > > Does the resolving function r

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
>> Do you have any resources or books that help with such things? (Taking >> a problem and solving it the way you did) > > I think, my suggestions are not specific to clojure, but they apply to > any functional language. All of them have functions for filtering > sequences, applying a function t

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Would that be flow control though? I see this exception as a rather exceptional circumstance for this application... On 20/03/2011, at 10:53 PM, Daniel Werner wrote: > On Mar 20, 10:50 am, Andreas Kostler > wrote: >> I would like to throw an exception when I'm trying to retrieve a value in a >>

Re: Dynamic scoping issue

2011-03-20 Thread Ken Wesson
On Sun, Mar 20, 2011 at 4:16 PM, Tassilo Horn wrote: > the println prints {Locality localities.Locality}, which is correct. > However, my resolving function errors because there is no class > Locality.  In the error message, I also print the value of > *schema-imports*, and in fact, it is {}. Doe

Dynamic scoping issue

2011-03-20 Thread Tassilo Horn
Hi all, I have a problem with a var that I want to be dynamically scoped. In my DSL, I state types using symbols like 'localities.Locality, and at some point some function resolves these types in some Java lib. For convenience, I wanted to add a macro that binds simple names to qualified names,

Re: About a networked REPL...

2011-03-20 Thread Stuart Sierra
Yes, as a heavy Emacs/SLIME user who does not work with Common Lisp any more, I'd rather have a Clojure-specific Emacs environment, especially something that can do more introspection of the JVM, e.g., look up JavaDocs and examine classes through reflection. In my not-terribly-well-informed opi

Re: How to Sum a Sequence?

2011-03-20 Thread Tassilo Horn
Christian writes: Hi Christian, > I would like to thank you for this suggestion and the way you > translated the problem statement into code! Thanks for the compliment. :-) > Do you have any resources or books that help with such things? (Taking > a problem and solving it the way you did) I t

Re: How to Sum a Sequence?

2011-03-20 Thread Michael Wood
Hi On 20 March 2011 17:47, Christian wrote: > Hello Tassilo! > > I've tested your code and looked at the Clojure Documentation for > 'for'. Given that, I have written > > (reduce +(filter even? (for [fib (fib-seq) :while (< fib 400)] > fib))) Or using Daniel's suggestion: (reduce + (filter

Re: About a networked REPL...

2011-03-20 Thread Kevin Downey
I am no python programmer, but if you look at http://docs.python.org/library/socket.html you see it passes in the number of bytes you wish to receive on a call to the receiv method on a socket. With that in mind parsing nrepl messages becomes a huge pain. At no time when parsing a nrepl message do

Re: About a networked REPL...

2011-03-20 Thread Chas Emerick
On Mar 20, 2011, at 3:13 AM, Kevin Downey wrote: > nrepl's protocol is also very line reader centric, which is a drag, > and the "integer" that prefixes messages is really just a variable > length string and is not useful for allocating buffers to receive data > in a client because it is a lines

Re: clojure.string/replace-first return nil when not matched

2011-03-20 Thread Takahiro Hozumi
Hi, Please bump up my JIRA membership level to make edits and I will fix this bug. I have an account named Takahiro Hozumi on dev.clojure.org already. CA is also already sent. Thanks. On 3月11日, 午後10:55, Stuart Sierra wrote: > > (require '[clojure.string :as str]) > > (str/replace-first "abc def"

Re: About a networked REPL...

2011-03-20 Thread Chas Emerick
Martin, Thank you for the pushback. :-) On Mar 19, 2011, at 8:30 PM, Martin Blais wrote: > Hi, > > After Rich's suggestion at the recent NYC meetup, I had a > detailed look at inferior-lisp vs. Slime, and nREPL, read > Chas' document, wrote a bit of code, tried to figure out the > issues for m

Re: How to Sum a Sequence?

2011-03-20 Thread Christian
Hello Tassilo! I've tested your code and looked at the Clojure Documentation for 'for'. Given that, I have written (reduce +(filter even? (for [fib (fib-seq) :while (< fib 400)] fib))) This gives me the error 'clojure.lang.LazySeq cannot be cast to clojure.lang.IFn'. I think this is because

Re: How to Sum a Sequence?

2011-03-20 Thread Daniel Werner
On Mar 20, 10:22 am, Christian wrote: > valued fibonacci terms under four million. (I did not know how to > specify a predicate depending on the value of (fib-seq) to check if > the value is under 4 million.) For this there is #'take-while: (take-while #(< % 400) ...) Daniel -- You receiv

Re: clj-ldap - Clojure LDAP client

2011-03-20 Thread Paul Dorman
Thanks for the latest changes, Saul. Your implementation is a little different from mine: (defn bind-connection "Change the identity of an existing connection." [connection bind-dn password] (let [bind-result (.bind connection (bind-request {:bind-dn bind- dn :password password}))] (if (

Re: Throwing an Exception with get

2011-03-20 Thread Daniel Werner
On Mar 20, 10:50 am, Andreas Kostler wrote: > I would like to throw an exception when I'm trying to retrieve a value in a > map for a key that doesn't exist. Another concise solution (thanks, Conj Labs): (defn get-o­r-exc [map key] (if-l­et [[_ v] (find­ map key)]­ v (thro­w (Exce­pti

Re: Throwing an Exception with get

2011-03-20 Thread Ambrose Bonnaire-Sergeant
Maybe something along these lines: (def ^{:private true} EMPTY (reify)) (defn get-with-empty-check [map key] (get map key EMPTY)) (defn key-exists? [value] (not= EMPTY value)) => (def res (get-with-empty-check {:asdf 1} :ss)) EMPTY => (key-exists? res) false The basic idea being that it's

Re: Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Hi Ambrose, No java interop. I do a selection based on map keys. Suppose I have a set of maps: (def rel #{{:a "a" :b "b"}{:a "c" :b "d"}{:a "e" :b "f"}}) And I do a select-like query (select rel [[:a :eq "a"]]) => #{{:a "a" :b "b"}} Now, I want to distinguish between a value that doesn't match an

Re: Throwing an Exception with get

2011-03-20 Thread Ambrose Bonnaire-Sergeant
This is slower but is a bit clearer. (defn get-with-exception [map key] (if (contains? map key) (get map key) (throw (Exception. "oops" Curious, why do you want to do this? Are you working with Java interop? Ambrose On Sun, Mar 20, 2011 at 5:50 PM, Andreas Kostler < andreas.koestl

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
On 20/03/2011, at 8:25 PM, Christian wrote: > Hello Andreas! > > Thanks for your swift reply. I'll try to explain the reasoning behind > my code. > > In the Clojure Reference I found the function into, which is described > like so: > > Usage: (into to from) > "Returns a new coll consisting of

Re: clj-ldap - Clojure LDAP client

2011-03-20 Thread Saul Hazledine
On Mar 16, 9:30 am, Ray Miller wrote: > On 15 March 2011 08:46, Saul Hazledine wrote: > > > On Mar 15, 1:30 am, Paul Dorman wrote: > > One thought though is that it may be quicker simply do a lookup on the > > directory server, obtain the password and then do a compare. In > > OpenLDAP, posixUse

Re: How to Sum a Sequence?

2011-03-20 Thread Christian
Hello Andreas! Thanks for your swift reply. I'll try to explain the reasoning behind my code. In the Clojure Reference I found the function into, which is described like so: Usage: (into to from) "Returns a new coll consisting of to-coll with all of the items of from-coll conjoined." I'm curren

Re: How to Sum a Sequence?

2011-03-20 Thread Tassilo Horn
Christian writes: Hi Christian, > For those unfamiliar, Project Euler Problem 2 states: > find the sum of all Sounds like (reduce + ...). > even-valued fibonacci terms Sounds like (filter even? ...) > that are less than four million. Hm, that's a bit more challenging. I think, you could go

Throwing an Exception with get

2011-03-20 Thread Andreas Kostler
Hi all, I would like to throw an exception when I'm trying to retrieve a value in a map for a key that doesn't exist. The obvious first shot was: (get {:foo "bar"} :foo (throw (new Exception "Oh no!"))) However, this doesn't work because the exception always throws since get apparently eagerly e

Re: How to Sum a Sequence?

2011-03-20 Thread Andreas Kostler
Hi Christian, What you're trying to do is to build up a vector with the last element of the vector being the answer to your problem: (last answer) => 4613732 You're trying to use cons (conj) to build up that list. Now, your function below never terminates because you're: a) Not actually buildin

How to Sum a Sequence?

2011-03-20 Thread Christian
I've tried Project Euler 2 now. For those unfamiliar, Project Euler Problem 2 states: find the sum of all even-valued fibonacci terms that are less than four million. Let's assume that I have the code to fill the vector: (def fib-seq ((fn rfib [a b] (lazy-seq (cons a (rfib b (+ a b)

Re: About a networked REPL...

2011-03-20 Thread Kevin Downey
nrepl's protocol is also very line reader centric, which is a drag, and the "integer" that prefixes messages is really just a variable length string and is not useful for allocating buffers to receive data in a client because it is a lines / 2 instead of a byte count. this makes writing a client th

Re: About a networked REPL...

2011-03-20 Thread Gary Schiltz
On Mar 19, 7:30 pm, Martin Blais wrote: > (*) Please note: I am aware that only Emacs supports the >     Swank protocol right now but I don't see why other IDEs >     couldn't support it too--it's just made up of LISP forms >     after all; in other words, if someone wants to replace >     the