On Wed, Jan 7, 2009 at 8:26 AM, janus wrote:
>
> It can't figure out why this is not working or was I sleeping while
> trying it out.
>
> (apply #(println %) [2 3])
The #(println %) procedure takes only one argument (because you only
have that one % in there) and you are applying it to two, name
On Wed, Jan 7, 2009 at 9:03 AM, Christian Vest Hansen
wrote:
> You are effectively trying to do (#(println %) 1 2).
Typo. I meant to write (#(println %) 2 3).
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
--~--~-~--~~~---~--~~
You received this messa
janus a écrit :
> It can't figure out why this is not working or was I sleeping while
> trying it out.
>
> (apply #(println %) [2 3])
>
This line is equivalent to (#(println %) 2 3) which errors since
#(println %) takes only one argument.
user=> (macroexpand '#(println %))
(fn* [p1__3493] (pri
rzeze...@gmail.com a écrit :
> 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
Hi Mark,
I think the def inside a defn has to go, it looks like an accident in
waiting.
I think you are replacing globals with a "god" structure (game) which passed
to every function, I think you need to abstract more.
I'm afraid I don't like the "big let" style and I found it hard to follow
some
Chris and Chris
Thanks
On Wed, Jan 7, 2009 at 9:09 AM, Christophe Grand wrote:
>
> janus a écrit :
> > It can't figure out why this is not working or was I sleeping while
> > trying it out.
> >
> > (apply #(println %) [2 3])
> >
> This line is equivalent to (#(println %) 2 3) which errors since
Thanks Brian.
I finally nailed it with:
(use '[clojure.contrib.duck-streams :only (reader)])
(with-open [r (reader "doc.txt")]
(dorun
(for [line (line-seq r)] (do (println line)
Cheers
Tom
2009/1/6 Brian Doyle
>
> On Tue, Jan 6, 2009 at 4:47 PM, Tom Ayerst wrote:
>
>> Its not t
On Wed, Jan 7, 2009 at 2:41 AM, Christian Vest Hansen
wrote:
>
> On Wed, Jan 7, 2009 at 5:26 AM, Chouser wrote:
>> Since I couldn't find any other class that uses this kind of
>> recursion for count(), it may be impossible to build a seq that
>> would still cause Cons.count() to overflow the sta
Here's a little cleaner version using doseq:
(use 'clojure.contrib.duck-streams)
(with-open [r (reader "doc.txt")]
(doseq [line (line-seq r)] (println line)))
On Wed, Jan 7, 2009 at 7:27 AM, Tom Ayerst wrote:
> Thanks Brian.
>
> I finally nailed it with:
>
> (use '[clojure.contrib.duck-strea
Thanks Barry, I now see what I did.
I tried doseq early but it didn't print anything. I had:
(with-open [r (reader "doc.txt")]
(doseq [line (line-seq r)] println line))
so I wasn't evaluating the println.
Cheers
Tom
2009/1/7 Paul Barry
> Here's a little cleaner version using doseq:
No Problem Ayerst :) Just kidding, people call me Barry all the time, even
though my first name is Paul. That's the curse of having 2 first names I
guess.
On Wed, Jan 7, 2009 at 8:17 AM, Tom Ayerst wrote:
> Thanks Barry, I now see what I did.
>
> I tried doseq early but it didn't print anythin
Oops, sorry Paul (In your favour I expect people can probably pronounce your
surname! ;-)
Cheers
Tom
2009/1/7 Paul Barry
> No Problem Ayerst :) Just kidding, people call me Barry all the time, even
> though my first name is Paul. That's the curse of having 2 first names I
> guess.
>
>
> On W
On Wed, Jan 7, 2009 at 12:55 AM, Emeka wrote:
>
> 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.
The newest version of my code only has one defn
Is there a definitive delimiter and capitalization for the name
"clojure-contrib"? I have seen space, hyphen, and dot as a delimiter,
plus several different takes on capitalization.
Sorry to be a pedant, but copyeditors are tough opponents. :-)
Thanks,
Stuart
--~--~-~--~~-
On Wed, Jan 7, 2009 at 2:10 PM, Chouser wrote:
>
> On Wed, Jan 7, 2009 at 2:41 AM, Christian Vest Hansen
> wrote:
>>
>> On Wed, Jan 7, 2009 at 5:26 AM, Chouser wrote:
>>> Since I couldn't find any other class that uses this kind of
>>> recursion for count(), it may be impossible to build a seq
On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst wrote:
> Hi Mark,
>
> I think you are replacing globals with a "god" structure (game) which passed
> to every function, I think you need to abstract more.
That's definitely what I'm doing and I don't like it either. I just
haven't worked out a better al
On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst wrote:
> Hi Mark,
>
> I think the def inside a defn has to go, it looks like an accident in waiting.
I'm not sure about that. The value last-key-code is only set in the
keyPressed method which is invoked when Swing/AWT detects that the
user pressed a ke
Mark Volkmann a écrit :
> I'd
> really like to find a way to get rid of that global variable, but I
> haven't been able to.
You can pass an atom (locally defined in main) to create-panel, and pass
it to your step function.
Christophe
--~--~-~--~~~---~--~~
You re
On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst wrote:
> Hi Mark,
>
> I'm afraid I don't like the "big let" style and I found it hard to follow
> some of your code, that may just be a personal thing but a lot of the vars
> defined in let are only used once and could be inlined.
I agree they could be
Nevermind, with a fresh start today (and perhaps more importantly,
perhaps, a fresh environment) compiling seems to work fine.
> It works for "require" and for calling functions in the package(s),
> but the problem now is that it doesn't work for AOT from the REPL.
>
> (compile 'package1) crashes
On Wed, Jan 7, 2009 at 8:52 AM, Christophe Grand wrote:
>
> Mark Volkmann a écrit :
>> I'd
>> really like to find a way to get rid of that global variable, but I
>> haven't been able to.
> You can pass an atom (locally defined in main) to create-panel, and pass
> it to your step function.
Thanks
On Jan 7, 1:01 am, "rzeze...@gmail.com" wrote:
> 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")
> He
> 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
I ran to into some strange agent behavior today that may be a bug. An
agent apparently exhausted the JVM available memory and threw an
OutOfMemoryError -- but it didn't go anywhere. I saw the error in the
console, but I couldn't get at it from the REPL: agent-errors still
returned nil and .getQueu
Hi all,
I'm attempting to provide 2 type hints here and not working...
(defn my-fn [#^String s #^Integer i] (println format("%s %d" s i)))
(my-fn "hello" (new Integer 123))
Thanks
Sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
On Jan 7, 2:14 am, durka wrote:
> I ran to into some strange agent behavior today that may be a bug. An
> agent apparently exhausted the JVM available memory and threw an
> OutOfMemoryError -- but it didn't go anywhere. I saw the error in the
> console, but I couldn't get at it from the REPL: a
Try:
(defn my-fn [#^String s #^Integer i] (println (format"%s %d" s i)))
#'user/my-fn
user=> (my-fn 1 "foo")
java.util.IllegalFormatConversionException: d != java.lang.String
(NO_SOURCE_FILE:0)
user=> (my-fn "foo" 1)
foo 1
Stuart
>
> Hi all,
>
> I'm attempting to provide 2 type hints here a
typo...
and looks working...
should be (println (format "%s %d" s i)))
On Jan 7, 10:44 am, wubbie wrote:
> Hi all,
>
> I'm attempting to provide 2 type hints here and not working...
>
> (defn my-fn [#^String s #^Integer i] (println format("%s %d" s i)))
> (my-fn "hello" (new Integer 123))
>
> T
On Jan 5, 4:56 pm, Meikel Brandmeyer wrote:
> Dear Clojurians,
>
> This patch allows multimethods to use different hierarchies, than
> the global hierarchy for use with isa?. Currently only the global
> hierarchy is possible.
>
> The patch extends the MultiFn class to accept also a Var pointing
On Wed, Jan 7, 2009 at 9:45 AM, Stuart Halloway
wrote:
>
> Is there a definitive delimiter and capitalization for the name
> "clojure-contrib"? I have seen space, hyphen, and dot as a delimiter,
> plus several different takes on capitalization.
>
> Sorry to be a pedant, but copyeditors are tough
Hi Rich,
Am 07.01.2009 um 17:10 schrieb Rich Hickey:
Thanks Meikel. I have a couple of points:
First, making derive and underive act on vars instead of the
hierarchies directly is not good - it reduces the generality
needlessly. Good practice is to make pure fns, then do the reference
part, no
On Jan 7, 10:37 am, Rich Hickey wrote:
> On Jan 7, 1:01 am, "rzeze...@gmail.com" wrote:
>
> > 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, "
Are there any particular issues with using nested transactions ...
dosync inside a dosync ... in Clojure?
--
R. Mark Volkmann
Object Computing, Inc.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
This was going to be a question but I solved it before I finished the
post :)
Figured I might post the solution then, hopefully it will help someone
else.
(import '(java.sql Connection DriverManager ResultSet SQLException
Statement ResultSetMetaData))
(import '(org.postgresql
What is it that triggers the function passed to swap! to be retried?
Is it that some other thread has modified the atom since swap! was
invoked, but before the function passed to swap! returns?
--
R. Mark Volkmann
Object Computing, Inc.
--~--~-~--~~~---~--~~
You
On Jan 7, 12:07 pm, "Mark Volkmann" wrote:
> Are there any particular issues with using nested transactions ...
> dosync inside a dosync ... in Clojure?
>
Nope. Just note that nested transactions 'join' the enclosing
transaction - they commit with it. Essentially there is only the
outermost tr
On Jan 7, 12:11 pm, "Mark Volkmann" wrote:
> What is it that triggers the function passed to swap! to be retried?
> Is it that some other thread has modified the atom since swap! was
> invoked, but before the function passed to swap! returns?
>
> --
I think that's described pretty well here:
This is frustrating - with a fresh REPL I'm back to the compile
problem. I can't think of anything I changed that would cause it to
work intermittently, and I don't know what file it's looking for...
the source files are on the classpath (it "require"s just fine) and
the directory in *compile-path
> One solution would be to load a single file and then have that file use
> add-classpath to set the classpath, but add-classpath is unreliable;
> I've had problems getting it to work consistently and have been told in
> #clojure that I shouldn't be using it.
Possibly the cause of the compile pro
So nested transactions only keep track of nesting level similar to
that in Sybase?
Sun
On Jan 7, 12:18 pm, Rich Hickey wrote:
> On Jan 7, 12:07 pm, "Mark Volkmann" wrote:
>
> > Are there any particular issues with using nested transactions ...
> > dosync inside a dosync ... in Clojure?
>
> Nop
On Wed, Jan 7, 2009 at 12:34 PM, Greg Harman wrote:
>
> This is frustrating - with a fresh REPL I'm back to the compile
> problem. I can't think of anything I changed that would cause it to
> work intermittently, and I don't know what file it's looking for...
> the source files are on the classpa
Works for me. I am going to go with clojure-contrib if nobody pushes
strongly for something else. Maybe I'll even commit a README file. :-)
Stuart
> On Wed, Jan 7, 2009 at 9:45 AM, Stuart Halloway
> wrote:
>>
>> Is there a definitive delimiter and capitalization for the name
>> "clojure-contr
Bingo - *compile-path* was a relative dir. Defining it as the full
path did the trick.
Thanks!
> Also, make sure the directory named by *compile-path* exists on the file
> system. Compilation creates subdirs, but not *compile-path* itself.
--~--~-~--~~~---~--~~
Y
On Wed, Jan 7, 2009 at 1:45 PM, Greg Harman wrote:
>
> Bingo - *compile-path* was a relative dir. Defining it as the full
> path did the trick.
>
> Thanks!
>
> > Also, make sure the directory named by *compile-path* exists on the file
> > system. Compilation creates subdirs, but not *compile-path
I couldn't find anything in core or contrib that wrote out
bytes to a file so I wrote something to do it. Is this
functionality already implemented and I just couldn't find
it? If there isn't anything already, would this be something
good to put in contrib somewhere? Thanks.
(defn write-by
clojure.contrib.duck_streams/spit?
On Wed, Jan 7, 2009 at 2:14 PM, Brian Doyle wrote:
> I couldn't find anything in core or contrib that wrote out
> bytes to a file so I wrote something to do it. Is this
> functionality already implemented and I just couldn't find
> it? If there isn't anythi
On Jan 7, 2009, at 2:04 PM, Shawn Hoover wrote:
Clojure developers, would it be a good idea for Compiler.java or
clojure.core/compile to check if *compile-path* exists, else throw
an exception specific to that problem?
I like the idea. There is a subtle problem I don't think it will catch
Looks like spit is for printing just text.
On Wed, Jan 7, 2009 at 12:20 PM, Paul Barry wrote:
> clojure.contrib.duck_streams/spit?
>
>
> On Wed, Jan 7, 2009 at 2:14 PM, Brian Doyle wrote:
>
>> I couldn't find anything in core or contrib that wrote out
>> bytes to a file so I wrote something to
On Jan 7, 2009, at 12:11 PM, ssecorp wrote:
This was going to be a question but I solved it before I finished the
post :)
Figured I might post the solution then, hopefully it will help someone
else.
Very cool.
(ns progs.netflix.db
(:require (clojure.contrib [sql :as sql]))
(:require
On Wed, Jan 7, 2009 at 11:21 AM, Rich Hickey wrote:
>
> On Jan 7, 12:11 pm, "Mark Volkmann" wrote:
>> What is it that triggers the function passed to swap! to be retried?
>> Is it that some other thread has modified the atom since swap! was
>> invoked, but before the function passed to swap! ret
Chouser,
Do you have an example of gen-interface + proxy working together? Take
a look at the following. Proxy works fine for a Java-provided
interface, but not for the generated one (ICompileTest.class is being
generated and is in the filesystem/classpath where expected.)
(ns compiletest)
(gen-
Getting back to Phil Hagelberg's comment that maintaining a project's
classpath in both a SLIME config and shell script for each project/
application is a "Don't Repeat Yourself" violation, there is a way to
avoid that:
Don't bother with swank-clojure-extra-classpaths. Instead, include /
path/to/
On Jan 7, 7:01 am, "Mark Volkmann" wrote:
> On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst wrote:
> > Hi Mark,
>
> > I'm afraid I don't like the "big let" style and I found it hard to follow
> > some of your code, that may just be a personal thing but a lot of the vars
> > defined in let are only us
On Wed, Jan 7, 2009 at 3:18 PM, Greg Harman wrote:
>
> Do you have an example of gen-interface + proxy working together?
You're calling my bluff, eh? Well, no I don't yet. I'm doing ugly
hacky things instead, to avoid the compile step. But since you've
thrown down the gauntlet, to mix some me
Dear Clojurians,
I found an issue with (require :reload ...) and AOT compilation.
Files "load"ed in a multi-file namespace get not correctly
reloaded when AOT compiled.
user=> (compile 'foo)
foo
user=> (require :reload-all :verbose 'foo)
(clojure.core/load "/foo")
(clojure.core/load "/bar")
nil
Honestly? The second one, but I did say I didn't like the 'big let' style,
maybe that is why.
Cheers
Tom
2009/1/7 Mark Volkmann
>
> On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst wrote:
> > Hi Mark,
> >
> I agree they could be inlined, but I find that style easier to read.
> For example, these a
> You're calling my bluff, eh? Well, no I don't yet.
Although I have been known to do some bluff-calling, in this case I
was actually hoping you had done it because I need this for a project
I'm working on. :-)
> I think the problem with your example is trying to work with classes
> or namespac
On Wed, Jan 7, 2009 at 3:05 PM, Tom Ayerst wrote:
> Honestly? The second one, but I did say I didn't like the 'big let' style,
> maybe that is why.
I think I may be in the minority on this. I suspect there are more
people currently using Clojure who came to it from a Lisp background
than a Java
(defn inse []
(sql/with-connection db
(sql/transaction
(insert-rows :r [[1 2 "date '2008-12-03'" 3]])))
nil)
I have tried all kinds of variations. it works perfectly with another
table, like (int,int,int,int) and passing [1,2,3,4]
so it is the type of column 3 that is the problem.
"
The sample code for the book now includes a clojure.contrib.sql
example with date handling that may be helpful [1]. I tested with
HSQLDB, please let me know if it doesn't work with postgresql.
Cheers,
Stuart
[1]
http://github.com/stuarthalloway/programming-clojure/tree/master/examples/snipp
Craig McDaniel writes:
> Connect to your running app from emacs by using "M-x slime-connect"
> rather than "M-x slime". When you're done, use "M-x slime-
> disconnect" (or from the REPL, "," then "disconnect") to leave your
> process running. In addtion, including swank in your running
> product
I tried to use connection in internal to get resultSetMetadata but I
never succeeded with it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.
and user.clj function wasn't avilable without importing it when I try
to access them if I put a file ina namespace.
On Jan 7, 8:27 pm, "Stephen C. Gilardi" wrote:
> On Jan 7, 2009, at 12:11 PM, ssecorp wrote:
>
>
>
> > This was going to be a question but I solved it before I finished the
> > pos
I'm not understanding re-find.
(re-find #"bar" "bar") => "bar"
whereas
(re-find #"(foo)|(bar)" "foo bar") => ["foo" "foo" nil]
Why does one return a vector and one just the result directly?
Looking at the code, re-find uses re-groups which explicitly says that
it either returns a vector or a
As a complete clojure newbie (hi folks!) from a Ruby/Java background,
I kind-of don't like either - I'd pull out a named function like:
(def add-mix-and-beat [bowl, dry-ingredients wet-ingredients] ...
and then use your second example, but now it's:
(def make-cookies-2a [flower baking-soda salt
On Wednesday 07 January 2009 15:21, Jeff Foster wrote:
> I'm not understanding re-find.
>
> (re-find #"bar" "bar") => "bar"
>
> whereas
>
> (re-find #"(foo)|(bar)" "foo bar") => ["foo" "foo" nil]
>
> Why does one return a vector and one just the result directly?
The use of capturing parentheses i
On Jan 7, 2009, at 6:21 PM, Jeff Foster wrote:
Looking at the code, re-find uses re-groups which explicitly says that
it either returns a vector or a string. This is clunky to deal with -
is there any reason it doesn't always return a vector?
Whether it returns a vector or string depends on
On Jan 7, 2009, at 6:20 PM, ssecorp wrote:
I tried to use connection in internal to get resultSetMetadata but I
never succeeded with it.
In the current svn version of clojure.contrib, connection is available
without using sql.internal. Also, there's now an example of getting
connection me
I noticed strange behavior in the sort function, I was sorting key
value tuples and ran into the following:
when sorting 2 item vectors such as [1 [1 2 3]] sort works fine:
(println
(sort
(map
(fn [x] [(int (* (Math/random) 10)) x]) (for [x (range 4)]
[1 2 3]
output:
(
I am new to clojure, but it seems very interesting.
Has anyone thought about allowing "update in place"
for situations where it is safe?
Suppose you have
(def y (tripleit x))
and you know that there is only a single reference to x
at this point, then it would be safe to implement it as
"y
I'm using the latest Slime, swank-clojure and Clojure, with a fix from
Chousuke to start up the REPL properly. I have no problem setting the
namespace in the REPL, but anything I eval directly from a file (i.e.
with C-x C-e) gets evaluated in the user ns.
The ns in the *inferior-lisp* buffer rema
I'm playing around with gen-interface, and compiled the following:
(ns mypkg.compiletest)
(gen-interface :name mypkg.ICompileTest
:methods [['foo [] []]])
I then used a java .class decompiler to look at the resulting .class
file expecting to see an interface with a single method c
I wonder if the root cause might be clearer if you were to review the
documentation for the sort function and then apply what it says to a
smaller dataset, e.g. a pair of lists.
Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
On Wed, Jan 7, 2009 at 7:25 PM, Zak Wilson wrote:
>
> I'm using the latest Slime, swank-clojure and Clojure, with a fix from
> Chousuke to start up the REPL properly. I have no problem setting the
> namespace in the REPL, but anything I eval directly from a file (i.e.
> with C-x C-e) gets evaluat
> First, compile the buffer with C-c
> C-k. Then, evaluate new definitions in the same source file and they
> will be evaluated in the correct namespace (regardless of what
> namespace is active in the repl).
That's what I expected, but it doesn't work; new definitions are
evaluated in user. It s
On Wed, Jan 7, 2009 at 11:49 PM, Zak Wilson wrote:
>
>> First, compile the buffer with C-c
>> C-k. Then, evaluate new definitions in the same source file and they
>> will be evaluated in the correct namespace (regardless of what
>> namespace is active in the repl).
>
> That's what I expected, but
76 matches
Mail list logo