Michiel de Mare a écrit :
> I'm converting a Ruby DSL into Clojure, and I'm running into some
> problems. I keep getting errors like this one:
>
> java.lang.ClassFormatError: Invalid method Code length 91069 in class
> file ...
>
> The DSL is a simple one - basically a long list of short forms. As
On Wed, Jan 7, 2009 at 5:26 AM, Chouser wrote:
> As discovered by cmvkk in IRC:
>
> user=> (count (reduce #(cons %2 %) [0] (range 4601)))
> java.lang.StackOverflowError (NO_SOURCE_FILE:0)
>
> This is because Cons.count() is recursive via RT.count(). Presumably
> it's to allow efficient counting
It can't figure out why this is not working or was I sleeping while
trying it out.
(apply #(println %) [2 3])
And, why is it that I can't do this?
Instead of (let [{coin :coin :as snake}{...}][coin
snake])
I tried this (let [{:coin coin :as snake}{...}][coin
snak
Hello,
Why not changing defns create-apple and create-snake to defs create-apple
and snake-create.Your defns have no args that why I feel strongly that they
should def, well I may be wrong.
Emeka
--~--~-~--~~~---~--~~
You received this message because you are su
On Tue, Jan 6, 2009 at 3:07 PM, Mark Engelberg wrote:
>
> One way to approach this without mutation is as follows:
>
> Decide on a data representation that represents the entire state of
> the game world at a given instant.
>
> Write a function which can draw this state.
> Write a function which
Looking at how the #^ macro is used in core.clj confuses me even more.
For example:
user=> (def #^{:arglist '([name]) :doc "Say hello."} hello (fn hello
[name] (println (str "Hello, " name
#'user/hello
user=> (hello "ryan")
Hello, ryan
nil
I mean I kind of follow it, but not totally. Is th
On Jan 6, 11:35 pm, wubbie wrote:
> Hi,
> Here is the question on differences between with-meta and #^
> Specifically 1) and 2) are different in that 1) has meta info carried
> over
> to jumping-wubbie, while 2) has not.
> What's the rationale behind this?
>
> user=> (def wubbie {:name "Wubbie"
I'm converting a Ruby DSL into Clojure, and I'm running into some
problems. I keep getting errors like this one:
java.lang.ClassFormatError: Invalid method Code length 91069 in class
file ...
The DSL is a simple one - basically a long list of short forms. As
each forms is evaluated, it adds its
Hi,
Here is the question on differences between with-meta and #^
Specifically 1) and 2) are different in that 1) has meta info carried
over
to jumping-wubbie, while 2) has not.
What's the rationale behind this?
user=> (def wubbie {:name "Wubbie" :email "wub...@gmail.com"})
#'user/wubbie
user=>
On Tue, Jan 6, 2009 at 7:32 PM, BerlinBrown wrote:
>
> I want to build a clojure application that has config files like with
> emacs (not that complex but close). I am guessing I need to call the
> eval and load script to load a configuration file, but I was trying
> to avoid having the configu
As discovered by cmvkk in IRC:
user=> (count (reduce #(cons %2 %) [0] (range 4601)))
java.lang.StackOverflowError (NO_SOURCE_FILE:0)
This is because Cons.count() is recursive via RT.count(). Presumably
it's to allow efficient counting of heterogeneous seqs, like:
user=> (def big-vec (into [] (
I had to revisit my test stubbing/expectation code after the recent
changes to test-is. The good news is, because of the excellent change
to make "is" a multi-method, the expectation code easily fits into
test-is. The following patch adds a new assertion for is, (is
(called?))
;; creates a stub
Heh... Given my problem was with namespaces and file names, looking
under "libs" would never have occurred to me. To me, libs would be jar
files or something else similar to that. This might be an indication
that the namespace doc page should point to the lib page with a
clarification abou
Thanks Stuart,
That's a good simplification, and everything seem kosher in terms of
loading from the REPL. I would like to structure my libs (package1,
package2 in the example) such that they span multiple files. So the
main file for the namespace/lib still needs to have "load" operations
to get
Hi Greg,
I think you may be working at too low a level with "load". You should
be able to accomplish the same thing with:
(ns my-app
(:require package1 package2))
(package2/start-app)
my_app, package1, and package2 all need to be immediately under a
directory (or JAR file) on the
I want to build a clojure application that has config files like with
emacs (not that complex but close). I am guessing I need to call the
eval and load script to load a configuration file, but I was trying
to avoid having the configuration file effect the state of the main
running application.
On Jan 6, 1:35 pm, "Mark Volkmann" wrote:
> I'm tempted to say that if a function doesn't have a name that implies
> what it returns or a comment describing what it returns, then callers
> shouldn't use it.
That just means that the return value isn't defined, so you shouldn't
rely on it returnin
On Jan 6, 9:20 pm, "Stephen C. Gilardi" wrote:
> On Jan 6, 2009, at 2:27 PM, ssecorp wrote:
>
> > On Jan 6, 8:12 pm, ssecorp wrote:
> >> CREATE TABLE foo (
> >> col1 INTEGER NOT NULL,
> >> col2 VARCHAR(32) NOT NULL,
> >> col3 DATE NOT NULL,
> >> PRIMARY KEY (col1, col2)
> >> );
>
> >>
In partial answer to my own question, I found these threads helpful:
http://groups.google.com/group/clojure/browse_thread/thread/bf9672989524a1bf/1f35a50643bd6325?lnk=raot
http://groups.google.com/group/clojure/msg/58e3f8e5dfb876c9
Everything seems to work well, except compilation. I'll post any
On Jan 6, 1:07 pm, "Mark Engelberg" wrote:
> Decide on a data representation that represents the entire state of
> the game world at a given instant.
>
> Write a function which can draw this state.
> Write a function which takes the state and player keypresses as input,
> and returns a new update
On Tue, Jan 6, 2009 at 4:47 PM, Tom Ayerst wrote:
> Its not the println, nor getting a reader (duckstreams is fine, I can do
> that). Its the converting it to a seq and stepping through it printing each
> element (which should be a line). Its the loopy, steppy bit, just for a side
> effect; that
Its not the println, nor getting a reader (duckstreams is fine, I can do
that). Its the converting it to a seq and stepping through it printing each
element (which should be a line). Its the loopy, steppy bit, just for a side
effect; that I am messing up.
Cheers
Tom
2009/1/6 Mark Volkmann
>
>
On Tue, Jan 6, 2009 at 5:26 PM, Tom Ayerst wrote:
> Hi,
>
> How do I read and print a text file? I can read it, its the printing that
> is the problem, I feel it should be obvious but I keep tripping myself up.
> (The context is I need to extract data line by line, translate the line
> format an
On Tue, Jan 6, 2009 at 5:26 PM, Tom Ayerst wrote:
> Hi,
>
> How do I read and print a text file? I can read it, its the printing that
> is the problem, I feel it should be obvious but I keep tripping myself up.
> (The context is I need to extract data line by line, translate the line
> format an
Hi,
How do I read and print a text file? I can read it, its the printing that
is the problem, I feel it should be obvious but I keep tripping myself up.
(The context is I need to extract data line by line, translate the line
format and save it for a legacy app)
Thanks
Tom
--~--~-~--~--
Hi,
Am 07.01.2009 um 00:18 schrieb Tom Ayerst:
There is a bug in end-game? which means it never ends. I'm not sure
if this is the most idiomatic way to fix it but it seems to work.
(defn end-game? [{:keys [apple snake]}]
The idiomatic way is maybe using :as.
(defn end-game? [{:keys [appl
What is interesting to me (and as it should be, I guess) is that as the code
gets more 'functional', it gets easier to work with, which is nice.
Cheers
Tom
2009/1/6 Rich Hickey
>
> On Tue, Jan 6, 2009 at 2:07 PM, Stuart Halloway
> wrote:
> >
> > Hi Rich,
> >
> > Thanks for the suggestion. I h
Hi Stuart,
There is a bug in end-game? which means it never ends. I'm not sure if this
is the most idiomatic way to fix it but it seems to work.
< (defn end-game? [{:keys [apple snake]}]
< (cond
< (lose? snake) (do (reset-game) "You lose!")
< (win? snake) (do (reset-game) "You win!")))
Well, I'm guessing that the multiple methods exception is due to the
fact that the value of "null" in Java is not typed - that is to say,
there is no such thing as a "null String" versus a "null Integer" -
null is just null. If you pass a value of null to something that has
multiple implementation
On Tue, Jan 6, 2009 at 3:01 PM, Stuart Halloway
wrote:
>
> Which is better?
>
> (defn reset-game [snake apple]
> (dosync (ref-set apple (create-apple))
> (ref-set snake (create-snake
>
> --or--
>
> (defn reset-game [snake apple]
> (dosync (ref-set apple (create-apple))
>
> also, i assume doing this efficiently relies on having immutable data
> structures that are properly optimized to share whatever they need to
> rather than having needless copy operations?
Right. Clojure's data structures all designed with this in mind, and
do not do needless copying.
Stuart
Is this the snake monad? :-)
Stuart
> One way to approach this without mutation is as follows:
>
> Decide on a data representation that represents the entire state of
> the game world at a given instant.
>
> Write a function which can draw this state.
> Write a function which takes the state and
> This is an outline of the strategy employed by the "world" teachpack
> that accompanies the "How to Design Programs" curriculum that uses PLT
> Scheme. Students routinely develop the snake program as a homework
> assignment, using this approach.
+1 / word up / hear hear.
also, it is akin to u
One way to approach this without mutation is as follows:
Decide on a data representation that represents the entire state of
the game world at a given instant.
Write a function which can draw this state.
Write a function which takes the state and player keypresses as input,
and returns a new upd
Which is better?
(defn reset-game [snake apple]
(dosync (ref-set apple (create-apple))
(ref-set snake (create-snake
--or--
(defn reset-game [snake apple]
(dosync (ref-set apple (create-apple))
(ref-set snake (create-snake)))
nil)
I prefer the latt
On 06.01.2009, at 14:58, Stuart Sierra wrote:
> If you're using clojure.contrib.test-is (or even if you're not), I
> would recommend putting tests in a separate namespace like
> "clojure.contrib.mylib.tests", but keep all the files under "src",
> like "src/clojure/contrib/mylib/tests.clj". Same
On Jan 6, 2009, at 2:27 PM, ssecorp wrote:
On Jan 6, 8:12 pm, ssecorp wrote:
CREATE TABLE foo (
col1 INTEGER NOT NULL,
col2 VARCHAR(32) NOT NULL,
col3 DATE NOT NULL,
PRIMARY KEY (col1, col2)
);
how would I set primary key if it is a combination of 2 keys?
This appears to work:
(sq
On Jan 4, 6:05 pm, "Brian Doyle" wrote:
> Today I found out about the var *file*. I looked it up *file* on
> clojure.com/api and couldn't find anything.
> Is there some place where all of these vars are defined? Is there some way
> programatically I can find
> them all? Thanks.
I'm bored, a
On Jan 6, 2009, at 2:27 PM, ssecorp wrote:
On Jan 6, 8:12 pm, ssecorp wrote:
CREATE TABLE foo (
col1 INTEGER NOT NULL,
col2 VARCHAR(32) NOT NULL,
col3 DATE NOT NULL,
PRIMARY KEY (col1, col2)
);
how would I set primary key if it is a combination of 2 keys?
You specify it as you woul
On Jan 6, 9:54 am, Chouser wrote:
> On Mon, Jan 5, 2009 at 11:29 PM, rzeze...@gmail.com
> wrote:
>
> > I was just messing around with array's and produced the following
> > exception. I don't actually need this to work for any reason, but I
> > was rather surprised by the behavior. Is this
On Jan 6, 8:12 pm, ssecorp wrote:
> CREATE TABLE foo (
> col1 INTEGER NOT NULL,
> col2 VARCHAR(32) NOT NULL,
> col3 DATE NOT NULL,
> PRIMARY KEY (col1, col2)
> );
>
> how would I set primary key if it is a combination of 2 keys?
also how would I set a key to be both foreign and primar
On Tue, Jan 6, 2009 at 2:07 PM, Stuart Halloway
wrote:
>
> Hi Rich,
>
> Thanks for the suggestion. I have moved all the per-game stuff (apple,
> snake, frame, panel, and timer) into a local let inside a game
> function. Is that what you had in mind?
>
Yup.
Rich
>
>> On Jan 6, 11:54 am, Stuart
CREATE TABLE foo (
col1 INTEGER NOT NULL,
col2 VARCHAR(32) NOT NULL,
col3 DATE NOT NULL,
PRIMARY KEY (col1, col2)
);
how would I set primary key if it is a combination of 2 keys?
--~--~-~--~~~---~--~~
You received this message because you are subscribed
Hi Rich,
Thanks for the suggestion. I have moved all the per-game stuff (apple,
snake, frame, panel, and timer) into a local let inside a game
function. Is that what you had in mind?
Stuart
> On Jan 6, 11:54 am, Stuart Halloway wrote:
>>> Code like @*foo* is not something I've seen in any
On Tue, Jan 6, 2009 at 11:54 AM, Stuart Halloway
wrote:
>
>> Code like @*foo* is not something I've seen in any code Rich has
>> written, so I think Stuart is right in considering removing the
>> asterisks on *apple* and *snake*
>
> I plan to remove them. What I still wrestle with is using "snake
On Jan 6, 2009, at 1:37 PM, ssecorp wrote:
(def db {:classname "org.apache.derby.jdbc.EmbeddedDriver"
:subprotocol "derby"
:subname "C:/clojure/progs/netflix/netflix.db"
:create true})
would I add this to set username and password?
;; :user "ninja"
;; :passwo
(def db {:classname "org.apache.derby.jdbc.EmbeddedDriver"
:subprotocol "derby"
:subname "C:/clojure/progs/netflix/netflix.db"
:create true})
would I add this to set username and password?
;; :user "ninja"
;; :password "kalle"})
(defn create-reviews-table
The REPL & Main section of the website doesn't have any content... not
written yet, or accidental omission?
http://clojure.org/repl_and_main
-Greg
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To
Hi all,
I'm struggling a bit with how best to organize and bootstrap a
multiple-source file project so that it can be run either command-line
(java -cp clojure.jar:myapp.jar ...) or by running a load method from
the REPL without having to explicitly change the classpath in my
user.clj before runn
On Jan 6, 11:54 am, Stuart Halloway wrote:
> > Code like @*foo* is not something I've seen in any code Rich has
> > written, so I think Stuart is right in considering removing the
> > asterisks on *apple* and *snake*
>
> I plan to remove them. What I still wrestle with is using "snake" at
> the
On Jan 6, 2009, at 12:46 PM, Greg Harman wrote:
The REPL & Main section of the website doesn't have any content... not
written yet, or accidental omission?
http://clojure.org/repl_and_main
Not written yet. I'll be writing it soon.
--Steve
smime.p7s
Description: S/MIME cryptographic signa
On Tue, Jan 6, 2009 at 11:07 AM, wubbie wrote:
>
> But after I shutdown the agent,
> I created a new agent with the same name and also defined the
> function.
> So shutdown on earlier agent should not matter?
I think he means that once you shut it down you can't use send or
send-off for any agen
But after I shutdown the agent,
I created a new agent with the same name and also defined the
function.
So shutdown on earlier agent should not matter?
-Sun
On Jan 6, 11:46 am, Chouser wrote:
> On Tue, Jan 6, 2009 at 11:18 AM, Mark Volkmann
>
> wrote:
>
> > On Tue, Jan 6, 2009 at 10:00 AM, wub
> Code like @*foo* is not something I've seen in any code Rich has
> written, so I think Stuart is right in considering removing the
> asterisks on *apple* and *snake*
I plan to remove them. What I still wrestle with is using "snake" at
the top level as ref, and then having a bunch of pure func
On Tue, Jan 6, 2009 at 11:18 AM, Mark Volkmann
wrote:
>
> On Tue, Jan 6, 2009 at 10:00 AM, wubbie wrote:
>> user=> (shutdown-agents)
>> nil
>
[snip]
>
>> user=> (send-off my-agent sleep-and-multiply 7 1500)
>> java.util.concurrent.RejectedExecutionException (NO_SOURCE_FILE:0)
>
> I don't know wh
On Jan 6, 7:18 am, "Mark Volkmann" wrote:
> I wish there was a convention for identifying constants in Clojure,
> even if it's not enforced. I'd be fine with making their names all
> uppercase as in Java, but I'm open to other suggestions.
The naming convention in Common Lisp for constants is
+
On Tue, Jan 6, 2009 at 11:28 AM, Mark Volkmann
wrote:
>
> On Tue, Jan 6, 2009 at 9:00 AM, Stuart Halloway
> wrote:
>>
>> I like to use the *form* for names that might be dynamically rebound.
>> Thinking about removing them from snake and apple as well.
>
> Based on the reply from Chouser, I thin
On Tue, Jan 6, 2009 at 9:00 AM, Stuart Halloway
wrote:
>
>> I'm curious why you decided not to surround the names of constants
>> with asterisks. I see you did use asterisks around snake and apple.
>> I'm still confused about whether there's a convention for that.
>
> I like to use the *form* for
On Tue, Jan 6, 2009 at 10:00 AM, wubbie wrote:
>
> Hi,
>
> I tried your example and some weird sequence generates
> java.util.concurrent.RejectedExecutionException (NO_SOURCE_FILE:0)
>
>
> Here is the scenario:
> Clojure
> user=> (def counter (agent 0))
> #'user/counter
> user=> (send counter inc
Mark Volkmann a écrit :
> Why does this output 1?
>
> (def my-ref (ref {:a 1}))
> (my-ref :a)
>
> I thought I could only access data in a ref by dereferencing it, but
> this shows otherwise.
>
>
Refs (like Vars) implement IFn by delegating to their value but Rich
stated to not rely on this beh
both (my-ref :a) and (@my-ref :a) returns 1. hmmm...
On Jan 6, 11:01 am, "Mark Volkmann" wrote:
> Why does this output 1?
>
> (def my-ref (ref {:a 1}))
> (my-ref :a)
>
> I thought I could only access data in a ref by dereferencing it, but
> this shows otherwise.
>
> --
> R. Mark Volkmann
> Obje
I don't see any way to do that without appending to a list of some sort.
Based on the way this library is written, that's true of Java or Clojure,
since SVNLogClient doesn't appear to have any methods to return a
Collection, just these doList methods, which forces you into a side effect
style of p
Why does this output 1?
(def my-ref (ref {:a 1}))
(my-ref :a)
I thought I could only access data in a ref by dereferencing it, but
this shows otherwise.
--
R. Mark Volkmann
Object Computing, Inc.
--~--~-~--~~~---~--~~
You received this message because you are s
Hi,
I tried your example and some weird sequence generates
java.util.concurrent.RejectedExecutionException (NO_SOURCE_FILE:0)
Here is the scenario:
Clojure
user=> (def counter (agent 0))
#'user/counter
user=> (send counter inc)
#
user=> @counter
1
user=> (def my-agent (agent 1))
#'user/my-agent
On Tue, Jan 6, 2009 at 9:29 AM, Chouser wrote:
>
> On Tue, Jan 6, 2009 at 10:18 AM, Mark Volkmann
> wrote:
>>
>> I wish there was a convention for identifying constants in Clojure,
>> even if it's not enforced. I'd be fine with making their names all
>> uppercase as in Java, but I'm open to othe
In the code below (which uses the SVNKit Java library) I define the function
get-dir-contents, which takes a Subversion repository URL and, via the proxy
ISVNDirEntryHandler, prints each entry to the screen in the call to
handleDirEntry. I would like it to collect and return the entries instead,
b
On Tue, Jan 6, 2009 at 10:18 AM, Mark Volkmann
wrote:
>
> I wish there was a convention for identifying constants in Clojure,
> even if it's not enforced. I'd be fine with making their names all
> uppercase as in Java, but I'm open to other suggestions.
Vars are correctly used only two ways, are
Here is a quick pretty print function I wrote which requires no
additional libraries. This version takes a string and returns a
string. Since it parses the text before transforming it is probably
not the fastest but it worked fine for my needs when generating xml
and xhtml files. I hope someone fi
On Tue, Jan 6, 2009 at 8:58 AM, Stuart Sierra
wrote:
>
> If you're using clojure.contrib.test-is (or even if you're not), I
> would recommend putting tests in a separate namespace like
> "clojure.contrib.mylib.tests", but keep all the files under "src",
> like "src/clojure/contrib/mylib/tests.clj
On Tue, Jan 6, 2009 at 9:00 AM, Stuart Halloway
wrote:
>
>> I'm curious why you decided not to surround the names of constants
>> with asterisks. I see you did use asterisks around snake and apple.
>> I'm still confused about whether there's a convention for that.
>
> I like to use the *form* for
> I see you didn't override getPreferredSize in your JPanel proxy and
> instead call setSize on the JFrame. When I did that I found that the
> size included the JFrame title bar. That meant that the usable area
> wasn't as tall as what I wanted. That's why I decided to size the
> panel instead and
On Mon, Jan 5, 2009 at 11:29 PM, rzeze...@gmail.com wrote:
>
> I was just messing around with array's and produced the following
> exception. I don't actually need this to work for any reason, but I
> was rather surprised by the behavior. Is this a bug or expected
> behavior? Please note I'm us
On Jan 6, 3:25 am, Konrad Hinsen wrote:
> I just joined the clojure-contrib project and made my first
> contribution (clojure.contrib.monads). I have a small test suite for
> that module, and I wonder where that should go.
If you're using clojure.contrib.test-is (or even if you're not), I
would
Check Clojure manual, I bet 2c.
Emeka
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to
cloj
Thanks for the detailed reply ... exactly what I needed!
On Mon, Jan 5, 2009 at 9:29 PM, Chouser wrote:
>
> On Mon, Jan 5, 2009 at 10:10 PM, Mark Volkmann
> wrote:
>>
>> I think I read somewhere that the number of threads in the thread pool
>> used by agents is based on the number of processors
Hi,
I hope you don't mind, rather than comment on the code I made some changes
(many lifted from Abhishek and Mark's implementation):
add-points only creates one point and it doesn't move anything so name
should change, suggest new-point (maybe new-head as it is always used by the
snake?)
def
Hi,
Am 06.01.2009 um 04:48 schrieb Joseph Jones:
I created a little file with it's own namespace and the tried to use
items form that file in another file. I used :use to import that
namespace into the second file but was having a devil of a time
getting it to work. It took me a while to riddle
I just joined the clojure-contrib project and made my first
contribution (clojure.contrib.monads). I have a small test suite for
that module, and I wonder where that should go. At the moment all the
code is in src/clojure/contrib, but is it a good idea to put test
code there as well, consi
78 matches
Mail list logo