Hi, I'm trying to build clojure-contrib and running into an issue. I
checked out clojure-contrib as follows and attempted to build it on my
machine. I get a compiler error when I run ant.
svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ clojure-
contrib-read-only
[java] java.la
Hi guys. I'm in the process of learning Clojure and loving it so far.
I've been dabbling in Common Lisp for years, but Clojure has so many
nice features that it's rapidly becoming my language of choice.
Recently, I've been trying to get my head wrapped around macros and
that an `or macro' would be
Problem solved! As you suggested I had an out of date version of
Clojure. I downloaded the 2008 revision on accident. Thank you for the
help.
Travis
On Apr 17, 1:30 pm, Konrad Hinsen wrote:
> On Apr 17, 2009, at 18:20, tmountain wrote:
>
> > Hi, I'm trying to build clojure-co
Thanks for the very informative reply!
On Apr 17, 1:40 pm, Christophe Grand wrote:
> tmountain a écrit :
>
>
>
> > Hi guys. I'm in the process of learning Clojure and loving it so far.
> > I've been dabbling in Common Lisp for years, but Clojure has so many
&
Sorry for the newbie question, but can someone tell me what IFn means
exactly? I keep running into it in the docs particularly in the
keyword documentation, and Google has yet to expain.
Thanks,
Travis
--~--~-~--~~~---~--~~
You received this message because you are
> symbols
> ...?
>
> fn? returns true for just functions
>
> On Sat, Apr 18, 2009 at 9:37 PM, tmountain wrote:
>
> > Sorry for the newbie question, but can someone tell me what IFn means
> > exactly? I keep running into it in the docs particularly in th
In an effort to learn more about Clojure, I decided to port a markov
text generator which a friend wrote in Python. After getting through a
few snags, I completed the program and decided to have some fun
feeding in some e-books downloaded from the Gutenberg project as
input. In this case, I chose
udy group, here:
>
> http://groups.google.com/group/clojure-study-dc/browse_thread/thread/...
>
> It looks like yours is more succinct... I'll definitely have to take
> some time and compare our approaches.
>
> -Luke
>
> On Apr 24, 8:47 am, tmountain wrote:
>
>
I just wanted to chime in and say I'm also a fan of vimclojure. I find
it to be one of the more enjoyable dev environments I've worked in and
the ability to send arbitrary expressions to the REPL is really
convenient. I have found a few issues with it though, and I'm
wondering what the appropriate
There was a very recent thread on the list related to the same
question:
http://groups.google.com/group/clojure/browse_thread/thread/750e5795141cff35#
HTH,
Travis
On Apr 29, 7:04 am, Santanu wrote:
> Hi Everybody,
>
> I wanted to compile a .clj clojure file into a .jar/.class file so
> that I
I'm new to Clojure as well and am also writing a server. Side effects
are hard to avoid when doing things like I/O, so I wouldn't feel too
bad about it. From the looks of your code, you've done a nice job
separating things like network communication from the business logic
of your chat server. I h
Congrats! I'm loving Clojure more all the time. Thank you for making
the Lisp I've been waiting for all these years.
Travis
On May 4, 8:58 am, Rich Hickey wrote:
> After a sustained period of API stability and minimal bugs reports,
> I'm happy to announce the release of Clojure 1.0!
>
> http://
:56 pm, Mikio Hokari wrote:
> Congratulations!
> I'm loving and enjoying Clojure programming.
> Clojure is the most beautiful, practical and fun language I've ever seen.
> Thank you very much for your great work!
>
> Mikio
>
> 2009/5/5 tmountain :
>
>
>
&g
I'm working on a project that makes use of a lot of byte arrays, and
I'm having an issue with certain bytes overflowing to negative values.
I know they're being stored properly because I'm also generating hex
dumps from time to time which indicate the real value is there. Can
someone tell me how t
Ahh, should've looked at the docs. Thanks for the helpful response.
Travis
On May 8, 11:09 pm, "Stephen C. Gilardi" wrote:
> On May 8, 2009, at 10:42 PM, tmountain wrote:
>
>
>
> > I'm working on a project that makes use of a lot of byte arrays, and
>
I'm trying to optimize some code I've written, and I have set warn on
reflection as advised. I'm having a hard time getting a simple
statement to avoid reflection.
user=> (== (byte 0x1) (byte 0x1))
Reflection warning, line: 33 - call to equiv can't be resolved.
Can you use type hints on primitiv
If that's the case, would I even get a performance increase, or would
the cast overhead cost more than the implicit reflection?
On May 14, 11:32 am, David Nolen wrote:
> This baffled me as well. You need to cast to int.
>
> On Thu, May 14, 2009 at 11:22 AM, tmountain wrote:
>
a byte array for a given value"
(loop [i 0]
(if (< i (count coll))
(if (== (int (byte key)) (int (byte (aget coll i
true
(recur (inc i))
Travis
On May 14, 11:40 am, tmountain wrote:
> If that's the case, would I even get a performance increase, or
your byte-array-contains? If you're going
> to be doing this a lot in your code I'd recommend making a helper class in
> Java. loop/recur is fast, but for absolute speed, you just can't beat
> putting your tight loops in Java.
>
> On Thu, May 14, 2009 at 12:00 PM, tmountain w
I thumbed through the slideshow. I'm going to keep a copy on hand as
it's a very nice reference for things I tend to look up. The
collection summary was especially helpful. I didn't know about
efficiency considerations regarding inserting items into lists and
vectors, and I'll be making use of tha
I'm no expert, but I think this explain some:
Clojure's conj function is like Lisp's cons, but "does the right
thing", depending on the data type. It is fast to add something to
the front of the list, and slower to add something to the end.
Vectors are the opposite, you can add to the end fast,
I agree with some of the previous suggestions that something including
Java interop would be a good idea. That should give Java programmers
warm fuzzy feelings and at least pique their curiosity enough to give
Clojure a more detailed look later. Four minutes is such an extremely
short amount of ti
This is true, but there are a few projects that are branching beyond
the industry standard and seeing big wins as a result. Eve Online is
one example. It's a MMO space exploration and colonization game, and a
big chunk of the code is written in Stackless Python. I believe
similar benefits could be
Hi all - I'm in the process of writing a proxy for MySQL in Clojure,
and until now everything has been going smoothly. My project has
reached the point where it can shuffle data up and down the wire
between client and server with accurate results, but I'm running into
a strange issue. I've noticed
s handled if
> all the bytes aren't ready to be read.
>
> I've had to make some assumptions about what you are doing so forgive
> me if no relevant.
>
> Regards,
> Tim.
>
> On Jun 1, 1:02 pm, tmountain wrote:
>
> > Hi all - I'm in the process of writi
You're correct. Debugging with print statements shows that the
otherwise clause is never being reached. That being said, simply
inserting a Thread.sleep(0) before the data is returned makes the
program behave properly. If I remove that sleep, the client gives back
a malformed packet response. It s
right amount of
> data. So I'm thinking (connection-write) doesn't call flush?
>
> On Jun 1, 11:30 pm, tmountain wrote:
>
> > You're correct. Debugging with print statements shows that the
> > otherwise clause is never being reached. That being said, simpl
I'm not sure if that's related to the problem either, but it may very
well improve performance. Thanks for the suggestion. I will try
opening the streams ahead of time and see where that takes me.
On Jun 1, 10:20 am, MikeM wrote:
> I don't know if this is part of the problem, but you appear to b
I took your advice and pulled my streams up front. This did seem to
offer a small performance benefit, but the issue persists. I've
greatly simplified the reader function to ensure that there's nothing
stupid going on there causing the erratic behavior.
(defn connection-read [#^DataInputStream
co
Code pasted like crap for some reason. You can see it here:
http://pastebin.com/f736205f2
On Jun 1, 10:05 pm, tmountain wrote:
> I took your advice and pulled my streams up front. This did seem to
> offer a small performance benefit, but the issue persists. I've
> greatly simplif
oject ready for an initial release. If there are any serious
bugs, I suppose that's what bug reports are for ;-).
On Jun 1, 10:09 pm, tmountain wrote:
> Code pasted like crap for some reason. You can see it
> here:http://pastebin.com/f736205f2
>
> On Jun 1, 10:05 pm, tmountain
Same here with the commas. Since I've been neck deep in Clojure, I've
been pathologically forgetting to add them with other languages.
On Jun 2, 10:06 am, Shawn Hoover wrote:
> On Tue, Jun 2, 2009 at 9:52 AM, Michael Reid wrote:
>
> > On Fri, May 29, 2009 at 2:51 PM, Paul Stadig wrote:
> > > Y
I'm writing some simple code, and I believe I'm running into trouble
getting a primitive char.
user=> (def s (new StringBuilder "aaa"))
#'user/s
; Java method signature is setCharAt(int index, char ch)
user=> (. s setCharAt (int 0) (char \a))
java.lang.IllegalArgumentException: No matching meth
I've been playing around with rewriting some Java code in Clojure and
did some simple benchmarking in the process. In this case, there's a
huge disparity in the performance numbers between the two languages,
and I'm wondering what the cause may be. The program rotates a string
from "", "aaab",
That doesn't work either. It appears this isn't an issue with Java 6,
but that doesn't help me on my PPC powerbook, which is apparently
stuck with the Java 5 JRE for the foreseeable future.
Thanks,
Travis
On Jun 14, 10:44 am, James Reeves wrote:
> On Jun 14, 3:28 am
Wow, you really got to the bottom of this. Reading your post, it all
makes sense, but it leads me to wonder why StringBuilder was designed
in such a fashion and why the docs would go so far as to lie about it.
Either way, thanks for taking the time to help me out. This community
is a big part of w
workload is parallelized. It's really
simple stuff but good for a concurrency beginner like me to explore
with.
Thanks,
Travis
On Jun 14, 10:00 am, tmountain wrote:
> I've been playing around with rewriting some Java code in Clojure and
> did some simple benchmarking in th
Having learned about agents recently, I've created a pretty contrived
program, which I believed would easily lend itself to parallel
processing. The program takes a list of MD5 sums and then does brute
force comparison the find the corresponding four character strings
they were generated from. The
I've tried this in lieu of the way I was generating the work units.
(def work-units (for [x (range 100)]
"88148433eeb5d372c0e352e38ac39aca"))
I know that for is still lazy, so I did this after the binding of work-
buckets:
(println work-buckets) ; yielded expected result
((88148433eeb5d372c0e35
Completely omitting work-buckets and spawn-agents, I've replaced with
the following, but the CPU still sits at 100% usage, and the run time
is still ~15 seconds.
(def work-units (doall (for [x (range 15)]
"88148433eeb5d372c0e352e38ac39aca")))
(def agents [(agent work-units)
(agent wo
processing. After the change, it
runs in 5 seconds on four cores as opposed to 15 seconds on a single
core. Thank you for taking the time to help me with this. It's been a
learning experience.
Travis
On Jun 15, 8:22 pm, tmountain wrote:
> Completely omitting work-buckets and spawn-agen
Due to the startup cost of the JVM, Clojure and Java probably aren't
the best choices for tiny five to ten line utility scripts. That being
said, Clojure works well for level stuff like bit twiddling, I/O, and
socket programming. If you're in an environment where Java is
available on your servers,
Hi all,
I've recently completed an introductory blog article on agents. It
starts off with a very basic introduction and segues into a highly
contrived hypothetical scenario. The scenario is a product of my semi-
bizarre sense of humor, but I hope it's entertaining. It basically
involves a situati
Hi Tim,
Thanks for the feedback and for taking the time to read the article. I
realized that pmap was probably a better solution as I was writing the
code, but pmap doesn't make for much of an agent demo, so I carried on
with my original plan. The point you make about bucketing is very
interesting
Taken from http://en.wikibooks.org/wiki/Learning_Clojure:
Java includes wrapper reference types for its primitive number types,
e.g. java.lang.Integer "boxes" (wraps) the primitive int type. Because
every Clojure function is a JVM method expecting Object arguments,
Java primitives are usually box
I had a feeling I might have been wrong on the primitive hint part.
Your explanation makes a lot of sense. Thanks for the clear
explanation.
Travis
On Jun 19, 12:15 pm, Chouser wrote:
> On Fri, Jun 19, 2009 at 11:40 AM, tmountain wrote:
>
> > It looks like Clojure auto-boxes from
This is very cool. I will definitely be keeping a copy on my laptop as
a quick reference. Thanks for putting it together.
Travis
On Jul 8, 5:04 am, Steve Tayon wrote:
> Hello everyone,
>
> while looking around for a modern lisp, I discovered Clojure and was
> instantly infected by the new possi
I just finished watching the Bay Area Clojure Meetup video, and Rich
spent a few minutes talking about the possibility of Clojure in
Clojure. The prospect of having Clojure self-hosted is incredibly
cool, but it brought a few questions to mind. For one, Rich mentions
that it would potentially open
> To be safe one often retains a
> stub compiler for some subset of the language written in another
> language, and then implements the rest of the language in the stub
> version.
This makes a lot of sense. So basically, a subset of Clojure could be
ported to whatever language you'd want to targe
I've written a short blog post on using Clojure to search for
available ssh servers on my companies VPN. It starts with a single-
threaded example and then adds concurrency. The performance difference
in this case was pretty extreme. Sweeping 254 hosts in a serial single-
threaded fashion took twe
> pmap will only use 1 thread per
> CPU/core, and therefore is only useful for computationally intensive
> functions.
> send-off definitely sounds like the right solution for this type of problem.
Cool, thanks for the info!
--~--~-~--~~~---~--~~
You received this
> However, the CPU usage indicated by "top" is ~690%. What does the CPU do?
100% per core. So with dual quad-core processors, it'd mean roughly 7
cores were being pegged.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Group
This is awesome. I'm curious if support for maps is planned in
addition to vectors? A lot of my code makes heavy use of maps, and it
would be great to get a performance boost.
Travis
On Aug 3, 5:25 pm, Rich Hickey wrote:
> I've been doing some work on Transient Data Structures. You can read
> a
hash maps support transients.
Everyone please try them out (where appropriate :). "
On Aug 7, 10:07 am, tmountain wrote:
> This is awesome. I'm curious if support for maps is planned in
> addition to vectors? A lot of my code makes heavy use of maps, and it
> would be great to
You can use agents in combination with the send function which will
operate on a fixed size thread pool. I'm sure there are other ways as
well, but I've found agents very easy to work with.
Travis
On Aug 10, 2:18 pm, Tom Emerson wrote:
> Hello Clojurians,
>
> I want to process approximately 74K
Yes, Clojure can be just as fast as Java. There's an example on the
Clojure website that illustrates this.
http://clojure.org/java_interop
Rather than write this Java:
static public float asum(float[] xs){
float ret = 0;
for(int i = 0; i < xs.length; i++)
ret += xs[i];
return ret;
}
ugh to replace Java for things such as
acting as a network proxy and database programming. That being said,
the language is still evolving all the time, and I'm certain
performance will continue to improve.
-Travis
On Aug 11, 4:26 pm, fft1976 wrote:
> On Aug 11, 1:09 pm, tmountain
Primitives can only be stored inside a local (i.e., a let binding).
Primitives are auto-boxed everywhere else. A type hint implies an
object (not a primitive). See this post for more info.
http://groups.google.com/group/clojure/msg/1e0d52ae931c730d
Travis
On Aug 12, 5:54 am, Tayssir John Gabbou
Hi, I was wondering if there's a more idiomatic way to do the
following:
(defn flip-coin []
(int (rand 2)))
(let [coin-flips (for [x (repeat true)] (flip-coin))]
Basically I want to generate an infinite lazy sequence based on the
output of a given function with zero or more arguments.
> And = should work I think:
> (= [1 2 3] [1 2 3]) returns true.
Oh man... now I feel stupid. Thanks for the help!
Travis
On Aug 18, 7:17 pm, CuppoJava wrote:
> "repeatedly" is the function that you're looking for in the first
> question.
>
> And = should work I think:
> (= [1 2 3] [1 2 3])
.html
Travis
On Aug 18, 7:08 pm, tmountain wrote:
> Hi, I was wondering if there's a more idiomatic way to do the
> following:
>
> (defn flip-coin []
> (int (rand 2)))
>
> (let [coin-flips (for [x (repeat true)] (flip-coin))]
>
>
> Basically I want to generat
Just an FYI, you can also use the builtin slurp function, which will
return the contents of a given file.
(slurp "file.txt")
Regards,
Travis
On Aug 21, 4:11 am, DemAS wrote:
> Hi all,
>
> I have created the function that read a txt file. I have a very
> little experience in clojure and I w
I'm pretty sure your issue is that format is a function inside
clojure.core, so it's causing a conflict. I renamed it, and the code
seems to work on my machine.
(import '(javax.sound.sampled AudioSystem
AudioFormat
DataLine
Clojure 1.1.0-alpha-SNAPSHOT
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
On Aug 25, 11:10 am, icemaze wrote:
> On Aug 25, 4:50 pm, tmountain wrote:
>
> > I'm pretty sure you
I've been casually interested in game development for a while. I
haven't done anything exciting, but I've been researching available
libraries and surveying the landscape. I haven't checked out JOGL, so
I'm not sure how it compares, but from what I've seen JMonkey looks
like a pretty nice game eng
Hi all - I've recently encouraged a friend to start learning Clojure,
and he has written some basic Markov chaining code as a learning
exercise. His code works fine with small sets of input data, but
larger inputs have been causing a StackOverflowError.
I've taken a look at the code and suspect t
I believe the flatten in contrib is defined as follows. I can't
remember which module I found it in.
(defn flatten
"Takes any nested combination of sequential things (lists, vectors,
etc.) and returns their contents as a single, flat sequence.
(flatten nil) returns nil."
[x]
(filter (co
009 at 1:02 PM, tmountain wrote:
>
> > Hi all - I've recently encouraged a friend to start learning Clojure,
> > and he has written some basic Markov chaining code as a learning
> > exercise. His code works fine with small sets of input data, but
> > larger inputs hav
own")}
As you said, there are definitely more efficient ways of doing this.
Basically, this is my friends first stab at Clojure, and I was mainly
trying to get to the bottom of why the overflow exception was
happening. Could you elaborate on your suggestion of using lazy-seq
some? I'm still a
I believe the way this works in rails has to do with the order in
which variables are resolved. In this case, @name is an instance
variable that's already been assigned elsewhere (your controller).
Rails loads the view after the controller class has been instantiated.
For this to work, the view is
Erlang allows two versions of a module to be stored in memory at any
given time. This allows you to do hot code swapping at runtime without
taking down the running server. Clojure can obviously do the same
thing, but Erlang offers a convenient builtin mechanism for shelling
into the running Erlang
I just put together some example code to demonstrate "hot updates"
with Clojure.
http://paste.lisp.org/display/86576
It allows you to connect to a REPL via port 12345 and dynamically
update things as necessary. To address the issue of updating multiple
definitions at once, you'd do something lik
Is it possible to refer from inside of the ns macro rather than doing
it after the fact? I've browsed the docs and don't see an obvious way
to do this. Right now I'm doing something like the following.
(ns foo
(:require [bar]))
(refer 'bar)
-Travis
--~--~-~--~~~---
Nevermind... stupidly simple solution:
(ns foo
(:use bar))
-Travis
On Sep 8, 8:11 am, tmountain wrote:
> Is it possible to refer from inside of the ns macro rather than doing
> it after the fact? I've browsed the docs and don't see an obvious way
> to do this. Right now
You might be looking for the instance? function. It can be used to
determine if something is an instance of a particular class.
user=> (instance? java.lang.Integer 5)
true
user=> (instance? java.lang.Integer "5")
false
To apply that to a data structure, you'd need to walk your structure
and comp
Clojure and Haskell both include STM systems for controlled access to
shared resources. There's a Haskell distribution known as Glasgow
Distributed Haskell (GdH), which provides facilities for small-scale
distributed programming. Clojure can achieve the same effect through
the use of third-party l
Wow, congrats! I have to say that for only being two, Clojure has made
a helluva stir as an up and comer. I think it's the most exciting
language in serious development right now, and I'm thrilled to be a
part of this community. Thanks to everyone for all the hard work!
-Travis
On Oct 16, 12:12
One other small thing, you can find out the exact type returned from a
function by calling class.
user=> (class (concat [1 2] [3 4]))
clojure.lang.LazySeq
There are functions that return lazy sequences all over the place, so
keep an eye out ;-).
On Oct 20, 12:56 am, Dmitri wrote:
> I notice th
Check out this post for some suggestions on working with Clojure in a
distributed fashion.
http://groups.google.com/group/clojure/msg/4a7a866c45dc2101
-Travis
On Nov 9, 2:09 pm, Michael Jaaka wrote:
> Hi!
>
> Is there any support from Clojure for communication between procesess
> by sockets?
Hi, I'm trying to transform a sequence of data to a map, and I'm using the
following pattern.
(def data [ {:id 1, :name "foo"}, {:id 2, :name "bar"}])
(zipmap (map #(:id %) data) data)
; result: {1 {:id 1, :name "foo"}, 2 {:id 2, :name "bar"}}
Is this the most idiomatic way to accomplish this
Thanks all. Much appreciated!
On Wednesday, October 12, 2016 at 11:26:09 AM UTC-4, tmountain wrote:
>
> Hi, I'm trying to transform a sequence of data to a map, and I'm using the
> following pattern.
>
> (def data [ {:id 1, :name "foo"}, {:id 2, :name &quo
Say that I have the following:
-- ns1.clj --
(ns multi.ns1)
(defrecord Animal [name])
-- ns2.clj --
(ns multi.ns2)
(defrecord Animal [name])
-- core.clj --
(ns multi.core
(:require [multi.ns1]
[multi.ns2])
(import [multi.ns1 Animal]
[multi.ns2 Animal]))
My intent is
[multi.ns2])
> (:import [multi.ns1.Animal]
>[multi.ns2.Animal]))
>
> (multi.ns1.Animal. "hi")
>
> (But remember to use the keyword :import, not the symbol. This will be
> tightened up in the future.)
>
>
> On Friday, March 17, 2017 at
I'm working on a behavior simulation demo in Clojure, and I've opted to use
protocols as a mechanism for composing entity capabilities. This snippit of
code demonstrates what I'm doing:
https://gist.github.com/2351790
Everything is working so far, but I'm wondering if this is an idiomatic
usa
nt? Is location really a
> function of Movement, or a first class piece achieved via movement?
>
> Ideally Protocols should be small. Perhaps you have another Protocol that
> extends Movement? Perhaps you have a Watcher Protocol that asks questions
> about destination? An Organism,
> Is there a
> way to do this in a single HTML file, and include all of the tooltips in
> that file?
Yes, there is. There are a lot of options out there, but I've found
qTip to be pretty simple.
http://craigsworks.com/projects/qtip/demos/content/basic
If you don't want to use any third-party lib
Hi, I'm playing around with protocols and records and trying to
implement some ad-hoc type composition. I have a solution that works,
but I want to make it more readable. Specifically, if you look at the
code below, I'd like to come up with a macro or some other solution to
eliminate all the calls
ood base-survive
})
; farmer
(extend Farmer
Inspectable
(merge base-behavior {:get-entity (get-entity-by-key)})
Survive survival-behavior)
On Dec 6, 3:08 pm, tmountain wrote:
> Hi, I'm playing around with protocols and records and trying to
> i
I'm playing around with a basic map/reduce pattern with the following
code:
(ns read-lines.core
(:gen-class)
(:use [clojure.java.io :only (reader)]))
(defn -main [& args]
(with-open [rdr (reader "/tmp/mydata.txt")]
(let [file-handle (line-seq rdr)]
(println (reduce (fn [m x] (inc
Wow, just by changing pmap to map, the same code runs to completion in
1 minute 35 seconds. I'm guessing this means that context switching
caused a huge performance penalty in this case since the "work" being
executed was so miniscule?
--
You received this message because you are subscribed to th
> pmap creates a future for every
> element of the sequence you give it, and that is significantly more
> computation work (allocating, initializing, and invoking future objects)
> than your function that simply returns 1 regardless of the value of its
> argument.
Makes perfect sense. Thanks for c
91 matches
Mail list logo