Re: Stream closed...

2011-08-12 Thread Sean Corfield
Yeah, I got the impression the OP was trying to create a new file with double the contents of the old one - the (str file-path 2) piece - but yours is certainly a slick way to double the original file! On Fri, Aug 12, 2011 at 8:47 PM, Dave Ray wrote: > Even shorter: > > (defn duplicate-file-data

Re: Stream closed...

2011-08-12 Thread Dave Ray
Even shorter: (defn duplicate-file-data [file-path] (spit file-path (slurp file-path) :append true)) Dave On Fri, Aug 12, 2011 at 11:16 PM, Sean Corfield wrote: > I think you also want to reorganize the code so you get the line-seq and > then the line-count outside the for loop. And bear in min

ANN: match 0.1.0-SNAPSHOT

2011-08-12 Thread David Nolen
Just pushed a version of match to Clojars, would love to hear feedback! Since our earlier announcement we now have: * Guard Patterns * Or Patterns * As Patterns * Java Interop All this and we've only added about ~260 lines of code which bodes well for ease of extending the library. We're sure t

Re: Stream closed...

2011-08-12 Thread Sean Corfield
I think you also want to reorganize the code so you get the line-seq and then the line-count outside the for loop. And bear in mind that (inc line-count) just returns line-count + 1 - it does not update line-count which is what I'm guessing you're expecting? Or you could just use slurp and spit:

Re: lein deps gets error

2011-08-12 Thread Ken Wesson
On Fri, Aug 12, 2011 at 6:53 PM, jayvandal wrote: > I do a lein new hello_world and I get a directory called hello_world. > I then try "lein deps". > I get several lines of errors starting with "#!" > What am I doing wrong? > = > > Microsoft Wind

Re: Stream closed...

2011-08-12 Thread Sean Corfield
(for ...) generates a lazy sequence so it isn't realized until after the value is returned from the function. You need to wrap (for ...) with (doall ...) to realize the sequence inside (with-open ...) On Fri, Aug 12, 2011 at 4:47 PM, turcio wrote: > Hi, > I'm trying to write a function which cre

Clojure on Javascript: Crockford javascript lectures

2011-08-12 Thread daly
You might want to look at some of the information on Crockford's webpage about Javascript http://javascript.crockford.com In particular, lecture 3 in his video series is about functions, classes, objects, etc in Javascript: http://www.yuiblog.com/blog/2010/02/24/video-crockonjs-3 Tim Daly d...

Stream closed...

2011-08-12 Thread turcio
Hi, I'm trying to write a function which creates file twice as big compared to the original file by simply duplicating its content. It looks like in the for loop I can't even read the first line although I'm using with-open. Can you tell me what am I doing wrong? (defn duplicate-file-data [file-p

lein deps gets error

2011-08-12 Thread jayvandal
I do a lein new hello_world and I get a directory called hello_world. I then try "lein deps". I get several lines of errors starting with "#!" What am I doing wrong? = Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation.

Re: Clojure/conj 2011 Call For Speakers Ends Soon - Aug 19th!

2011-08-12 Thread Christopher Redinger
On Friday, August 12, 2011 2:42:04 PM UTC-4, Christopher Redinger wrote: > > Speakers will receive: > * A catered speakers dinner on Thursday night. > Correction: Wednesday night. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: Stanford AI Class

2011-08-12 Thread daly
On Fri, 2011-08-12 at 21:49 -0400, Ken Wesson wrote: > (defn f [x] > (println "hello, " x)) > > (defn g [] > (eval '(defn f [x] (println "goodbye, " x > > (defn -main [] > (#'user/f "world!") > (g) > (#'user/f "cruel world.")) > > Close enough? :) You get an A. --Tim -- You re

Re: ClassCastException with contrib replace-first-str

2011-08-12 Thread Sean Corfield
Looks like replace-first-str was deprecated in 1.2: {:deprecated "1.2"} All future contrib work is focused on the new modular libraries with no maintenance planned on the old monolithic contrib, so I think I'd recommend not using replace-first-str and instead use this: (clojure.string/replace-firs

Re: Stanford AI Class

2011-08-12 Thread Ken Wesson
(defn f [x] (println "hello, " x)) (defn g [] (eval '(defn f [x] (println "goodbye, " x (defn -main [] (#'user/f "world!") (g) (#'user/f "cruel world.")) Close enough? :) -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language

Re: Stanford AI Class

2011-08-12 Thread daly
On Fri, 2011-08-12 at 16:30 -0700, pmbauer wrote: > +1 > > On Friday, August 12, 2011 3:16:15 PM UTC-7, Sergey Didenko wrote: > BTW, Is there a case when AI self-modifying program is much > more elegant than AI just-data-modifying program? > > I just can't figure

Re: Self-joins in ClojureQL

2011-08-12 Thread Zak Wilson
Update: CQL does in fact support self-joins. An example of the correct syntax is here: http://pastie.org/2356343 -- 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 mem

Re: Creating global javascript objects (like Date) in Clojurescript

2011-08-12 Thread Conrad
Ah! I didn't know about a js namespace- Thanks for figuring that out, Michael! On Aug 12, 6:15 pm, Michael Wood wrote: > On 12 August 2011 23:19, Conrad wrote: > > > Sorry if this has an obvious answer, but there is still only limited > > documentation on clojurescript native interop on the net

Re: Stanford AI Class

2011-08-12 Thread Ken Wesson
On Fri, Aug 12, 2011 at 4:25 PM, daly wrote: > Consing up a new function and using eval is certainly possible but > then you are essentially just working with an interpreter on the data. > > How does function invocation actually work in Clojure? > In Common Lisp you fetch the function slot of the

Re: Stanford AI Class

2011-08-12 Thread pmbauer
+1 On Friday, August 12, 2011 3:16:15 PM UTC-7, Sergey Didenko wrote: > > BTW, Is there a case when AI self-modifying program is much more elegant > than AI just-data-modifying program? > > I just can't figure out any example when there is a lot of sense to go the > self-modifying route. > --

Re: Silly Chat: Clojure, ClojureScript and WebSockets

2011-08-12 Thread Hubert Iwaniuk
Aleph On Aug 11, 2011, at 11:49 PM, Jimmy wrote: > Whats handling the serverside websockets connections? > > -- > 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 n

Re: Stanford AI Class

2011-08-12 Thread Sergey Didenko
BTW, Is there a case when AI self-modifying program is much more elegant than AI just-data-modifying program? I just can't figure out any example when there is a lot of sense to go the self-modifying route. -- You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: Creating global javascript objects (like Date) in Clojurescript

2011-08-12 Thread Michael Wood
On 12 August 2011 23:19, Conrad wrote: > Sorry if this has an obvious answer, but there is still only limited > documentation on clojurescript native interop on the net right now, > and none of the code I've seen of runs into this use case... > > How do I create a javascript Date object in Clojure

Creating global javascript objects (like Date) in Clojurescript

2011-08-12 Thread Conrad
Sorry if this has an obvious answer, but there is still only limited documentation on clojurescript native interop on the net right now, and none of the code I've seen of runs into this use case... How do I create a javascript Date object in Clojurescript? I've tried: (Date.) (window/Date.) (.now

Re: Why are some Google Closure library files not available in Clojurescript?

2011-08-12 Thread Conrad
When I tried that, it still didn't seem to recognize the new namespaces. My guess is that clojurescript doesn't determine closure library namespaces dynamically, but has a hardcoded list of them somewhere (but I never investigated further...) On Aug 12, 4:35 pm, Daniel Renfer wrote: > On Fri, Aug

Re: Why are some Google Closure library files not available in Clojurescript?

2011-08-12 Thread Daniel Renfer
On Fri, Aug 12, 2011 at 2:34 PM, Conrad wrote: > In case anyone wants to know what the answer is: goog.storage was > added with closure library revision 888, but the version used in > clojurescript is revision 790. This is because Google hasn't released > any pre-packaged versions of the closure l

Re: Stanford AI Class

2011-08-12 Thread daly
On Fri, 2011-08-12 at 13:08 -0400, Ken Wesson wrote: > On Fri, Aug 12, 2011 at 12:41 PM, daly wrote: > > Clojure has immutable data structures. > > Programs are data structures. > > Therefore, programs are immutable. > > > > So is it possible to create a Clojure program that modifies itself? > >

Re: Erlang/OTP in clojure

2011-08-12 Thread Ole Rixmann
Thanks, really fast feedback here :) I would like a vnode in clojure... In my opinion a lot of the erlang low-level stuff is not needed for that. The topology can be definded and shared with a gossip protocol over http or xmpp. I think i will spend some time with this, bye Ole On 12 Aug., 21:40

Re: Indexing a nested sequence

2011-08-12 Thread Matt Smith
Using the list comprehension (for) along with a helper function (index) (def y (list "#" "#...O" "#.#.#" "I.#.#" "#...#" "#")) (defn index [s] (map #(vector %1 %2) s (range))) (defn index-maze [maze-str] (reduce conj {} (for [r (index maze-str) c (index (first r)

Re: Indexing a nested sequence

2011-08-12 Thread Jan
> Hello, > > > I'm trying to find an elegant way of indexing a two-dimensional sequence > with the coordinates as keys. > If you know width and height you can generate the pattern of coordinates instead of calculating it: (map vector (for [y (range height) x (range width)] y)

ClassCastException with contrib replace-first-str

2011-08-12 Thread Marius
Hi, I found a small bug in Clojure Contrib 1.2.0. To reproduce: (require '[clojure.contrib.string :as s]) (s/replace-str "a" "b" "aa") ; "bb" as expected (s/replace-first-str "a" "b" "aa") ; java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern -- You receive

Re: Erlang/OTP in clojure

2011-08-12 Thread rzeze...@gmail.com
Ole, Glad you liked my posts on Riak. I took a quick glance at your code and it's amazing how much Clojure I've forgotten over the last year. I need to read my Joy of Clojure :) If you're looking for Erlang/OTP in Clojure land than I think an easier path might be to look at Erjang [1]. AFAICT,

Clojure/conj 2011 Call For Speakers Ends Soon - Aug 19th!

2011-08-12 Thread Christopher Redinger
Call For Speakers Clojure/conj 2011 Raleigh, NC Nov 10-12th, 2011 http://clojure-conj.org This is a reminder that the Call for Speakers for the second annual Clojure/conj is ending soon - August 19th at midnight Eastern to be exact! We would still love to receive your abstracts for this conferen

Re: Why are some Google Closure library files not available in Clojurescript?

2011-08-12 Thread Conrad
In case anyone wants to know what the answer is: goog.storage was added with closure library revision 888, but the version used in clojurescript is revision 790. This is because Google hasn't released any pre-packaged versions of the closure library since March. On Aug 12, 1:47 pm, Conrad wrote:

Erlang/OTP in clojure

2011-08-12 Thread Ole Rixmann
Hi everyone, i just read this series of posts about riak core https://github.com/rzezeski/try-try-try. I liked it (because i did a lot Erlang recently) and wanted to have a similar thing in clojure. So i started, although i know i would need years to build such a system on my own, but a gen_serv

Indexing a nested sequence

2011-08-12 Thread johanmartinsson
Hello, I'm trying to find an elegant way of indexing a two-dimensional sequence with the coordinates as keys. The input is something like. ( "#" "#...O" "#.#.#" "I.#.#" "#...#" "#") The midje test below indicates what kind of behaviour I'm looking for. I can't come up

Re: Silly Chat: Clojure, ClojureScript and WebSockets

2011-08-12 Thread Jimmy
Whats handling the serverside websockets connections? -- 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 moderated - please be patient with your first pos

trying to reach Rich Hickey

2011-08-12 Thread Shriram Krishnamurthi
I'm trying to reach Rich Hickey to invite him to a seminar. Rich, can you please reply directly to me? Thanks. Shriram -- 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 fro

Re: at-at

2011-08-12 Thread Pierre-Yves Ritschard
Shameless plug, but tron provides the same kind of functionality: https://github.com/pyr/tron Cheers, - pyr On Wed, Aug 10, 2011 at 7:58 PM, David Nolen wrote: > On Wed, Aug 10, 2011 at 1:37 PM, Sam Aaron wrote: >> >> Hi, >> >> I just wanted to announce the arrival of the newly-born at-at lib

Re: Example of a real-world ClojureScript web application

2011-08-12 Thread Raju Bitter
Thanks for sharing the code with us, Filip. I have one additional question: Which parts of ClojureScript were documented well enough for you, and where was it difficult to find enough information on how to implemented certain features? Raju On Aug 10, 11:22 pm, Scott Jaderholm wrote: > I haven't

Re: Why are some Google Closure library files not available in Clojurescript?

2011-08-12 Thread Conrad
On further inspection, the latest closure library download doesn't have this directory either, so the issue I'm having (whatever it is) is a closure issue, not related to clojurescript. Therefore, it is off- topic for this forum and I will find my answer elsewhere- Thanks! On Aug 12, 1:47 pm, Conr

Why are some Google Closure library files not available in Clojurescript?

2011-08-12 Thread Conrad
Hi everyone- I'm loving clojurescript and am trying to create a test app with it. This test app was going to use goog.storage, but for some reason this library doesn't appear to be available when I install clojurescript (unlike goog.dom, goog.events, etc. which work fine) You can see this library

Re: Stanford AI Class

2011-08-12 Thread Ken Wesson
On Fri, Aug 12, 2011 at 12:41 PM, daly wrote: > Clojure has immutable data structures. > Programs are data structures. > Therefore, programs are immutable. > > So is it possible to create a Clojure program that modifies itself? Yes, if it slaps forms together and then executes (eval `(def ~sym ~f

Re: Stanford AI Class

2011-08-12 Thread daly
Here is an interesting question to ponder... Learning involves permanent changes of behavior. In AI this is often modeled as a self-modifying program. The easiest way to see this would be a program that handles a rubics cube problem. Initially it only knows some general rules for manipulation, so

Re: Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Oh yes, of course. Why didn't I think of that? For some reason, implementing 2 interfaces never occurred to me. :P On Aug 12, 4:48 pm, David Powell wrote: > > The simplest so far seems to be to use gen-interface to create a > > subinterface of Controller with all the methods I need, or gen-class.

Re: rebind var for all threads

2011-08-12 Thread Ken Wesson
On Fri, Aug 12, 2011 at 10:17 AM, Stuart Sierra wrote: >> Yes. The compiler probably optimized away the var lookup to an >> embedded constant. You'll need to use an atom, as Baldridge suggested. > > The Clojure compiler doesn't optimize anything away. However, in a situation > like this: > >     (

Re: Nasty java interop problem -- ideas?

2011-08-12 Thread David Powell
> > > The simplest so far seems to be to use gen-interface to create a > subinterface of Controller with all the methods I need, or gen-class. > But that would require AOT compilation. Can I get away without it? > Can you use definterface to create an interface with your methods on, and then defty

Nasty java interop problem -- ideas?

2011-08-12 Thread Oskar Kvist
Hi! I have the following problem. I'm using a Java lib for making GUIs. One lays out the GUI in XML, then uses a Controller (Listener type thing) to do stuff. For example, in the XML one might have onClick="doSomething()". And then reflection is used to find the method of the controller instance.

Re: rebind var for all threads

2011-08-12 Thread Stuart Sierra
> > Yes. The compiler probably optimized away the var lookup to an > embedded constant. You'll need to use an atom, as Baldridge suggested. > The Clojure compiler doesn't optimize anything away. However, in a situation like this: (defn foo [x y] ...) (def bar (partial foo 1)) The

Re: [ANN] Lacij v.0.4.0

2011-08-12 Thread Sam Aaron
Great stuff. I need something like this to visually render the internal design of synths in Overtone. Keep up the great work, Sam --- http://sam.aaron.name On 11 Aug 2011, at 14:02, Pierre Allix wrote: > Hello, > > I'm pleased to announce the release of the version 0.4.0 of the Lacij > graph

Re: rebind var for all threads

2011-08-12 Thread Ken Wesson
On Fri, Aug 12, 2011 at 12:36 AM, Sean Corfield wrote: > On Thu, Aug 11, 2011 at 6:48 PM, Ken Wesson wrote: >> >> Eh. I now can't seem to actually find any recent post mentioning both >> it and Android. But mentioning it in connection with Google's app >> store is another matter. > > There is no

Re: Example of a real-world ClojureScript web application

2011-08-12 Thread Timothy Washington
I was able to get Jasmine tests running in the browser. You really just have to follow the pattern in Quickstart, and good.require the needed namespaces. I imagine Google Closure's testing lib

Re: rebind var for all threads

2011-08-12 Thread Michael Wood
On 12 August 2011 06:36, Sean Corfield wrote: > On Thu, Aug 11, 2011 at 6:48 PM, Ken Wesson wrote: >> >> Eh. I now can't seem to actually find any recent post mentioning both >> it and Android. But mentioning it in connection with Google's app >> store is another matter. > > There is no "Google A