Can't Build clojure-contrib

2009-04-17 Thread tmountain
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

How's This Macro?

2009-04-17 Thread tmountain
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

Re: Can't Build clojure-contrib

2009-04-17 Thread tmountain
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

Re: How's This Macro?

2009-04-17 Thread tmountain
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 &

IFn?

2009-04-18 Thread tmountain
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

Re: IFn?

2009-04-19 Thread tmountain
> 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

Clojure Poetry

2009-04-24 Thread tmountain
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

Re: Clojure Poetry

2009-04-24 Thread tmountain
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: > >

Re: more vimclojure

2009-04-28 Thread tmountain
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

Re: how do I create a runnable clojure program

2009-04-29 Thread tmountain
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

Re: Example Server in Clojure

2009-04-29 Thread tmountain
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

Re: Clojure 1.0

2009-05-04 Thread tmountain
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://

Re: Clojure 1.0

2009-05-05 Thread tmountain
: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

Byte Overflow

2009-05-08 Thread tmountain
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

Re: Byte Overflow

2009-05-08 Thread tmountain
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 >

Help with Type Hint

2009-05-14 Thread tmountain
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

Re: Help with Type Hint

2009-05-14 Thread tmountain
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: >

Re: Help with Type Hint

2009-05-14 Thread tmountain
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

Re: Help with Type Hint

2009-05-14 Thread tmountain
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

Re: new Clojure presentation

2009-05-15 Thread tmountain
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

Re: list vs vector

2009-05-15 Thread tmountain
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,

Re: Clojure at JavaOne

2009-05-19 Thread tmountain
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

Re: Clojure for high-end game development

2009-05-24 Thread tmountain
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

Weird Issue Reading Socket

2009-05-31 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: Weird Issue Reading Socket

2009-06-01 Thread tmountain
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

Re: You know you've been writing too much Clojure when...

2009-06-02 Thread 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

Primitive char Type

2009-06-13 Thread tmountain
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

Performance Penalty Converting from Java Code

2009-06-14 Thread tmountain
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",

Re: Primitive char Type

2009-06-14 Thread tmountain
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

Re: Primitive char Type

2009-06-15 Thread tmountain
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

Re: Performance Penalty Converting from Java Code

2009-06-15 Thread tmountain
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

multiple agents yielding flat performance

2009-06-15 Thread tmountain
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

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
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

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
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

Re: multiple agents yielding flat performance

2009-06-15 Thread tmountain
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

Re: will clojure evolve to be able to do systems programming?

2009-06-16 Thread tmountain
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,

A Gentle Introduction to Agents

2009-06-18 Thread tmountain
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

Re: A Gentle Introduction to Agents

2009-06-19 Thread tmountain
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

Re: Type hints on primities

2009-06-19 Thread tmountain
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

Re: Type hints on primities

2009-06-19 Thread tmountain
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

Re: Clojure cheat sheet

2009-07-09 Thread tmountain
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

Clojure in Clojure?

2009-07-09 Thread tmountain
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

Re: Clojure in Clojure?

2009-07-09 Thread tmountain
> 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

Sweeping Networks with Clojure

2009-07-22 Thread tmountain
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

Re: Sweeping Networks with Clojure

2009-07-23 Thread tmountain
> 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

Re: Question about pmap

2009-08-03 Thread tmountain
> 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

Re: Transient Data Structures

2009-08-07 Thread tmountain
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

Re: Transient Data Structures

2009-08-07 Thread tmountain
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

Re: Processing elements in a lazy seq in parallel

2009-08-10 Thread tmountain
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

Re: Can Clojure be as fast as Java?

2009-08-11 Thread tmountain
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; }

Re: Can Clojure be as fast as Java?

2009-08-11 Thread tmountain
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

Re: Can Clojure be as fast as Java?

2009-08-12 Thread 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

Infinite Sequence of Coin Flips

2009-08-18 Thread tmountain
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.

Re: Infinite Sequence of Coin Flips

2009-08-18 Thread tmountain
> 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])

Re: Infinite Sequence of Coin Flips

2009-08-20 Thread tmountain
.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

Re: read txt file

2009-08-21 Thread tmountain
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

Re: Newbie - the method I cannot call

2009-08-25 Thread tmountain
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

Re: Newbie - the method I cannot call

2009-08-25 Thread tmountain
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

Re: Clojure for game programming?

2009-09-01 Thread tmountain
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

Filter Causing StackOverflowError?

2009-09-02 Thread tmountain
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

Re: A better flatten

2009-09-02 Thread tmountain
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

Re: Filter Causing StackOverflowError?

2009-09-03 Thread tmountain
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

Re: Filter Causing StackOverflowError?

2009-09-03 Thread tmountain
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

Re: Lazy binding

2009-09-03 Thread tmountain
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

Re: Fixing production systems on-the-fly

2009-09-04 Thread tmountain
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

Re: Fixing production systems on-the-fly

2009-09-04 Thread tmountain
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

refer from inside of ns macro?

2009-09-08 Thread tmountain
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 --~--~-~--~~~---

Re: refer from inside of ns macro?

2009-09-08 Thread tmountain
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

Re: "Schema" for data structures

2009-09-24 Thread tmountain
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

Re: Can anyone here give a comparison between Clojure and Erlang on concurrent programming?

2009-09-24 Thread tmountain
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

Re: Clojure is two!

2009-10-16 Thread tmountain
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 

Re: sequence manipulation question

2009-10-21 Thread tmountain
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

Re: Communication in a distributed system

2009-11-11 Thread tmountain
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?

Data Transformation Question

2016-10-12 Thread tmountain
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

Re: Data Transformation Question

2016-10-12 Thread tmountain
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

Defrecord Conflict

2017-03-17 Thread tmountain
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

Re: Defrecord Conflict

2017-03-18 Thread tmountain
[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

Protocol Usage

2012-04-10 Thread tmountain
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

Re: Protocol Usage

2012-04-11 Thread tmountain
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,

Re: Clojure v1.4 - what is new, changed and in development

2011-09-27 Thread tmountain
> 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

Defrecord Composition Problem

2011-12-06 Thread tmountain
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

Re: Defrecord Composition Problem

2011-12-06 Thread tmountain
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

Map/Reduce Performance Question

2012-01-13 Thread tmountain
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

Re: Map/Reduce Performance Question

2012-01-13 Thread tmountain
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

Re: Map/Reduce Performance Question

2012-01-13 Thread tmountain
> 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