[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, 201
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
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 "bar"
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
and loosely
coupled, increases your flexibility in the future.
My Not So Humble Opinion: Not only is it correct, it's also beautiful.
Keep using it this way.
On Tue, Apr 10, 2012 at 7:44 AM, tmountain tinymount...@gmail.com wrote:
I'm working on a behavior simulation demo in Clojure, and I've
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
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 the
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
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
(extend Farmer
Inspectable
(merge base-behavior {:get-entity (get-entity-by-key)})
Survive survival-behavior)
On Dec 6, 3:08 pm, tmountain tinymount...@gmail.com wrote:
Hi, I'm playing around with protocols and records and trying to
implement some ad-hoc type composition. I have
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
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 michael.ja...@googlemail.com wrote:
Hi!
Is there any support from Clojure for communication between
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
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
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 compare
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
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 tinymount...@gmail.com 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
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
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 like
:
On Wed, Sep 2, 2009 at 1:02 PM, tmountain tinymount...@gmail.com 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 have
lazy-seq
some? I'm still a bit fuzzy on implementing my own lazy functions.
Thanks,
Travis
On Sep 3, 2:08 am, Krukow karl.kru...@gmail.com wrote:
On Sep 2, 7:02 pm, tmountain tinymount...@gmail.com wrote:
(defn generate-chain [source]
(loop [the-list (map #(list (first (split-at 2
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
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
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
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 icem...@gmail.com wrote:
On Aug 25, 4:50 pm, tmountain tinymount...@gmail.com wrote:
I'm pretty sure
Travis
On Aug 18, 7:08 pm, tmountain tinymount...@gmail.com 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 generate an infinite lazy sequence
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 patrickli_2...@hotmail.com wrote:
repeatedly is the function that you're looking for in the first
question.
And = should work I think:
(=
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
Yes, Clojure can be just as fast as Java. There's an example on the
Clojure website that illustrates this.
snip
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
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 fft1...@gmail.com wrote:
On Aug 11, 1:09 pm, tmountain tinymount...@gmail.com wrote:
Yes, Clojure
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 tremer...@gmail.com wrote:
Hello Clojurians,
I want to process
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 richhic...@gmail.com wrote:
I've been doing some work on Transient Data
maps support transients.
Everyone please try them out (where appropriate :).
On Aug 7, 10:07 am, tmountain tinymount...@gmail.com 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 get
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
Groups
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
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 steve.ta...@googlemail.com wrote:
Hello everyone,
while looking around for a modern lisp, I discovered Clojure and was
instantly
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
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 target,
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
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
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 chou...@gmail.com wrote:
On Fri, Jun 19, 2009 at 11:40 AM, tmountaintinymount...@gmail.com wrote:
It looks like
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
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
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
. 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 tinymount...@gmail.com wrote:
I've been playing around with rewriting some Java code in Clojure and
did some simple benchmarking in the process. In this case
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
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
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 tinymount...@gmail.com wrote:
Completely omitting work-buckets
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,
, tmountain tinymount...@gmail.com wrote:
java.lang.IllegalArgumentException: No matching method found:
setCharAt for class java.lang.StringBuilder (NO_SOURCE_FILE:0)
user= (type (char \a))
java.lang.Character
; should be char?
You could try: (.charValue \a)
- James
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 method
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 shawn.hoo...@gmail.com wrote:
On Tue, Jun 2, 2009 at 9:52 AM, Michael Reid kid.me...@gmail.com wrote:
On Fri, May 29, 2009
.
Regards,
Tim.
On Jun 1, 1:02 pm, tmountain tinymount...@gmail.com wrote:
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
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
are reading the right amount of
data. So I'm thinking (connection-write) doesn't call flush?
On Jun 1, 11:30 pm, tmountain tinymount...@gmail.com wrote:
You're correct. Debugging with print statements shows that the
otherwise clause is never being reached. That being said, simply
inserting
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 michael.messini...@invista.com wrote:
I don't know if this is part of
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
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 tinymount...@gmail.com wrote:
Code pasted like crap for some reason. You can see it
here:http://pastebin.com/f736205f2
On Jun 1, 10:05 pm, tmountain tinymount
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
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
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
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
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'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
in 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 tinymount...@gmail.com wrote
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
Ahh, should've looked at the docs. Thanks for the helpful response.
Travis
On May 8, 11:09 pm, Stephen C. Gilardi squee...@mac.com 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 having an issue with certain
mikiohok...@gmail.com 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 tinymount...@gmail.com:
Congrats! I'm loving Clojure more
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 richhic...@gmail.com wrote:
After a sustained period of API stability and minimal bugs reports,
I'm happy to announce the release of
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 thisissant...@gmail.com wrote:
Hi Everybody,
I wanted to compile a .clj clojure file into a
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
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
, 8:47 am, tmountain tinymount...@gmail.com wrote:
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
...?
fn? returns true for just functions
On Sat, Apr 18, 2009 at 9:37 PM, tmountain tinymount...@gmail.com 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 the
keyword documentation, and Google has yet
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
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]
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 konrad.hin...@laposte.net wrote:
On Apr 17, 2009, at 18:20, tmountain wrote:
Hi, I'm trying to build clojure
81 matches
Mail list logo