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: What are people using Clojure for?

2009-06-18 Thread Vagif Verdi
On Jun 18, 8:39 am, Howard Lewis Ship wrote: > I am having fun learning it by creating a simple web framework. Howard, that's interesting to hear from a Tapestry creator. I'm in a process of preparing to write a web application with clojure web framework compojure. But if you have something usa

Re: Which map access is more idiomatic

2009-06-18 Thread CuppoJava
I always use (map key), because it's the most likely to fail if "map" is not what I think it is. This helps avoid some particularly hard to find bugs. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure

Re: Which map access is more idiomatic

2009-06-18 Thread Mark Volkmann
On Thu, Jun 18, 2009 at 6:30 PM, Howard Lewis Ship wrote: > I have code that gets passed a map (actually a struct-map), should I > > (my-map :my-key) > or > (:my-key my-map) > > I'm beginning to gravitate towards the latter, as it is more tolerant of > the map being nil. > I prefer the (map key)

Re: Which map access is more idiomatic

2009-06-18 Thread Sean Devlin
I like the map-key pattern, especially inside a function. (fn [my-var] ({"A" 1 :b "one"} my-var)) In this example, the my-var works properly when passed a string. (fn [my-var] (my-var {"A" 1 :b "one"})) The second example breaks when passed a string. On Jun 18, 8:37 pm, kkw wrote: > (my

Re: Which map access is more idiomatic

2009-06-18 Thread kkw
(my-map :my-key) has felt more natural to me, and I suspect it's because it feels more OO to me (for better or worse). I hadn't considered nil-map tolerance/robustness before, so I'd be quite happy to change my mind on new work I write with maps. Kev On Jun 19, 10:13 am, "J. McConnell" wrote: >

seq? vs. sequential?

2009-06-18 Thread Howard Lewis Ship
I had some code that adapted to functions that returned either a map or a seq of maps. I was using (seq?) and (map?) to analyze the return value. It then blew up when a function returned a clojure.lang.IPersistentVector. Fortunately, (sequential?) is a super-set of (seq?) and matched this proper

Re: Which map access is more idiomatic

2009-06-18 Thread J. McConnell
On Thu, Jun 18, 2009 at 7:30 PM, Howard Lewis Ship wrote: > > I have code that gets passed a map (actually a struct-map), should I > > (my-map :my-key) > or > (:my-key my-map) > > I'm beginning to gravitate towards the latter, as it is more tolerant of the > map being nil. I tend to prefer the

Re: Yet another web framework for Clojure.

2009-06-18 Thread James Reeves
On Jun 18, 10:11 pm, Matt wrote: > I've also added a simple hello world tutorial which demonstrates most > of the features of Conjure so far: I like the name. Have you considered making it compatible with Ring, Clojure's Rack equivalent? - James --~--~-~--~~~---~--~-

Which map access is more idiomatic

2009-06-18 Thread Howard Lewis Ship
I have code that gets passed a map (actually a struct-map), should I (my-map :my-key) or (:my-key my-map) I'm beginning to gravitate towards the latter, as it is more tolerant of the map being nil. -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos

Re: What's the difference between `ref-set` and `alter`?

2009-06-18 Thread Rich Hickey
On Jun 18, 5:23 pm, "Stephen C. Gilardi" wrote: > On Jun 18, 2009, at 1:25 PM, Adam Blinkinsop wrote: > > > Does ref-set not set the "in-transaction-value"?  It looks like the   > > only difference is the signature, and that can't be right. > > Both set the in-transaction value. ref-set sets a

Yet another web framework for Clojure.

2009-06-18 Thread Matt
Hi all, I was recently introduced to Clojure by a coworker, and have been loving it ever since. I jumped in head first writing a Rails like web framework with it before I realized how many other basic web frameworks are out there. Anyways, it's a fun project and I'm pretty happy with the state it

Re: What's the difference between `ref-set` and `alter`?

2009-06-18 Thread Four of Seventeen
On Jun 18, 1:25 pm, Adam Blinkinsop wrote: > I'm looking through the primitives that Clojure has for STM with refs, and > it seems nice and minimal, except for these two functions, which I can't > tease apart.  From the documentation, > >  *(ref-set ref val)* > > Must be called in a transaction.

Re: What are people using Clojure for?

2009-06-18 Thread kkw
I've used Clojure to partially re-implement Java-based tools we have at our shop written to interface with TIBCO. Clojure has also been used to write a tool to extract electricity+gas metering data from an Oracle DB. In summary, I've used Clojure to write and partially re- implement tools that I n

Re: What are people using Clojure for?

2009-06-18 Thread Howard Lewis Ship
Yes I see ... right up to date with Tapestry 5.1.0.5. On Thu, Jun 18, 2009 at 2:18 PM, Toralf Wittner wrote: > > On Thu, 2009-06-18 at 09:39 -0700, Howard Lewis Ship wrote: > > I've been doing a number of presentations on Clojure lately > > (TheServerSide, Portland Code Camp, Open Source Bridge),

Re: Runtime Compilation of Clojure from Android

2009-06-18 Thread George Jahad
On Jun 18, 7:05 am, Marklar wrote: > I tried the second apk and it works perfectly. Nice job! > Cool, thanks. > My phone is a retail G1 with the JesusFreak 1.51 image. The menu I was > referring to was the menu of the terminal application from which I was > using telnet. You mean you are usin

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Brett Morgan
Silly question of the week, clojure+terracotta be used to do scientific cluster computing? On Fri, Jun 19, 2009 at 2:48 AM, Konrad Hinsen wrote: > > On 18.06.2009, at 16:47, psf wrote: > > > That is funny... I put a little Clojure plug into the article entitled > > "Trailblazing with Roadrunner"

Re: contrib proposal: apropos

2009-06-18 Thread Michel Salim
On Jun 18, 3:45 pm, Richard Newman wrote: > > (defn substring? [str1 str2] > >  (let [c1 (count str1) > >    c2 (count str2)] > >  (and (<= c1 c2) > >       (or (= str1 (subs str2 0 c1)) > >       (substring? str1 > >                   (subs str2 1 c2)) > > This should be a little faster: >

Re: What's the difference between `ref-set` and `alter`?

2009-06-18 Thread Stephen C. Gilardi
On Jun 18, 2009, at 1:25 PM, Adam Blinkinsop wrote: Does ref-set not set the "in-transaction-value"? It looks like the only difference is the signature, and that can't be right. Both set the in-transaction value. ref-set sets a specific value. alter runs a function to transform the previ

Re: What are people using Clojure for?

2009-06-18 Thread Toralf Wittner
On Thu, 2009-06-18 at 09:39 -0700, Howard Lewis Ship wrote: > I've been doing a number of presentations on Clojure lately > (TheServerSide, Portland Code Camp, Open Source Bridge), and I'm > getting some interest in Clojure and functional programming. > > A question that keeps coming up is: where

What's the difference between `ref-set` and `alter`?

2009-06-18 Thread Adam Blinkinsop
I'm looking through the primitives that Clojure has for STM with refs, and it seems nice and minimal, except for these two functions, which I can't tease apart. From the documentation, *(ref-set ref val)* Must be called in a transaction. Sets the value of ref. Returns val. *(alter ref fun &

Re: Google Code issues

2009-06-18 Thread Rich Hickey
On Jun 17, 11:39 pm, Richard Newman wrote: > > Chas Emerick and Jarkko Oranen have copied the Google Code issues into > > Assembla. > > I notice the contrib issues have not yet been moved over. > > Will anything screw up if I create issues in Assembla before the move   > has occurred? In other

Re: contrib proposal: apropos

2009-06-18 Thread Richard Newman
> > (defn substring? [str1 str2] > (let [c1 (count str1) > c2 (count str2)] > (and (<= c1 c2) > (or (= str1 (subs str2 0 c1)) > (substring? str1 > (subs str2 1 c2)) This should be a little faster: (defn substring? [#^String s1 #^String s2] (not

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Anand Patil
On Thu, Jun 18, 2009 at 5:48 PM, Konrad Hinsen wrote: > > On 18.06.2009, at 16:47, psf wrote: > > > That is funny... I put a little Clojure plug into the article entitled > > "Trailblazing with Roadrunner" in the very same issue of CiSE. > > Great minds think alike ;-) > > > On 18.06.2009, at 18:1

Re: Exception trying to use a macro within proxy

2009-06-18 Thread Jeff Dik
On Thu, Jun 18, 2009 at 11:33:54AM -0700, hoeck wrote: > > Hi, > > proxy is a macro, where you supply the method definitions according to > its docstring in the following format: > > user> (doc proxy) > ... > f => (name [params*] body) or > (name ([params*] body) ([params+] body) ...) >

Re: generating java classes at runtime

2009-06-18 Thread hoeck
Hi, if your generated classes implement a varying but finite set of interfaces, or extend a given class, then using the proxy macro would be the easiest way to generate them at runtime: http://clojure.org/java_interop#toc26 or type (doc proxy) at the commandline. If your generated classes exten

Re: What are people using Clojure for?

2009-06-18 Thread Greg Harman
I've been using Clojure for a great deal of what I code for the last 6 months or so, both professionally and personally. (And plan to make an appropriate donation through my company once we've monetized the Clojure-based product). In particular, we've created a data integration tool coded in Cloj

Re: Exception trying to use a macro within proxy

2009-06-18 Thread hoeck
Hi, proxy is a macro, where you supply the method definitions according to its docstring in the following format: user> (doc proxy) ... f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) ... so it expects: a list of name vector body* > Unfortunately, I get an ex

Re: What are people using Clojure for?

2009-06-18 Thread Sean Devlin
I'm the "report guy", which means a lot of speadsheet/database/erp/ html scraping/mind reading type work. I use Clojure for a lot of ad- hoc data processing. The following things make my job a lot easier: * Quick feedback from the REPL * Abstracting everything to a hash-map * map/filter/remo

Re: What are people using Clojure for?

2009-06-18 Thread Luc Prefontaine
We have an HL7 message bus in production since January 2009 mostly written in Clojure. It links an Hospital Management System to services like radiology, labs, ... It runs in a distributed environment on clusters of several nodes. Using Clojure we see key things that eases the pain significant

contrib proposal: apropos

2009-06-18 Thread Michel Salim
Would anyone be interested in this? It takes either a string or a symbol, and examines all namespaces for identifiers that match the given input. (defn substring? [str1 str2] (let [c1 (count str1) c2 (count str2)] (and (<= c1 c2) (or (= str1 (subs str2 0 c1)) (substr

Exception trying to use a macro within proxy

2009-06-18 Thread Jeff Dik
Hi, I'm trying to look at events thrown by COM automation objects using com4j and clojure and am trying to use macros to clean up my code. Here is a small script that works without macros: (use 'clojure.contrib.str-utils) (def ie (SHDocVw.ClassFactory/createInternetExplorer)) (.visib

Re: Apply a function to some values in a map

2009-06-18 Thread Rowdy Rednose
You are absolutely right about the names. Unfortunately all the good ones are already taken by Rich. ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: What are people using Clojure for?

2009-06-18 Thread Richard Newman
> I've been doing a number of presentations on Clojure lately > (TheServerSide, Portland Code Camp, Open Source Bridge), and I'm > getting some interest in Clojure and functional programming. > > A question that keeps coming up is: where would you use Clojure and/ > or functional? I've been

generating java classes at runtime

2009-06-18 Thread Ratandeep Ratti
Hi all, I had a bit of requirement, which necessitate generation of java classes at runtime by reading some xml data and adding them to the classpath . Since I was learing clojure, I thought this could help. Can you guys provide me with some pointers as to how to go about it. regards, rdsr

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Konrad Hinsen
On 18.06.2009, at 16:47, psf wrote: > That is funny... I put a little Clojure plug into the article entitled > "Trailblazing with Roadrunner" in the very same issue of CiSE. Great minds think alike ;-) On 18.06.2009, at 18:16, Michel Salim wrote: > Really neat -- hopefully there will be a fol

What are people using Clojure for?

2009-06-18 Thread Howard Lewis Ship
I've been doing a number of presentations on Clojure lately (TheServerSide, Portland Code Camp, Open Source Bridge), and I'm getting some interest in Clojure and functional programming. A question that keeps coming up is: where would you use Clojure and/or functional? I've had to cite Rich's back

generating java classes at runtime

2009-06-18 Thread rdsr
Hi all, I had a bit of requirement, which necessitate generation of java classes at runtime by reading some xml data and adding them to the classpath . Since I was learing clojure, I thought this could help. Can you guys provide me with some pointers as to how to go about it. regards, rdsr

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Michel Salim
On Jun 18, 2:00 am, Konrad Hinsen wrote: > The July/August issue of the IEEE magazine "Computing in Science and   > Engineering" has an introduction to functional programming for   > scientists that uses Clojure for the examples. It is already   > available (a bit in advance of the paper issue)

Re: Apply a function to some values in a map

2009-06-18 Thread Sean Devlin
Yeah, it's a bit ugly. It's designed to suppress this: user=> (list-to-map 1 2 3 4 5) {1 2, 3 4} user=> (hash-map 1 2 3 4 5) # I need to clean this up. Thanks for looking On Jun 18, 11:58 am, Rowdy Rednose wrote: > Interesting. It's a bit different from what I currently need, but I'm > curr

Re: Apply a function to some values in a map

2009-06-18 Thread Rowdy Rednose
Interesting. It's a bit different from what I currently need, but I'm currently looking at the sources. I wondered why you define this: (defn list-to-map [& params] (apply hash-map (reduce concat (partition 2 params Couldn't you just use the plain hash-map function? user=> (= (list-t

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread psf
That is funny... I put a little Clojure plug into the article entitled "Trailblazing with Roadrunner" in the very same issue of CiSE. Paul On Jun 18, 12:00 am, Konrad Hinsen wrote: > The July/August issue of the IEEE magazine "Computing in Science and   > Engineering" has an introduction to fun

Re: Apply a function to some values in a map

2009-06-18 Thread Sean Devlin
Here's my solution to the problem. It's a bit long winded, so bear with me (or ignore it :)) I defined a function trans (defn trans [& params]...) Let me show an example: user=> (def test-map {:a 0 :b "B" :c "C"}) #'user/test-map user=> ((trans :count count) test-map) {:count 3, :a 0, :b "B"

Re: accum

2009-06-18 Thread jvt
I was a little surprised that fold was not a standard function but I didn't run my mouth off about it - just typed "reduce" into the repl and found out it was called that instead. On Jun 17, 5:45 pm, Wrexsoul wrote: > On Jun 17, 2:47 pm, Kyle Schaffrick wrote: > > > As a friendly suggestion, I

Re: Runtime Compilation of Clojure from Android

2009-06-18 Thread Marklar
I tried the second apk and it works perfectly. Nice job! My phone is a retail G1 with the JesusFreak 1.51 image. The menu I was referring to was the menu of the terminal application from which I was using telnet. Let me know if you'd like to investigate why the first one wasn't working, I'd be ab

Re: Apply a function to some values in a map

2009-06-18 Thread Chouser
On Thu, Jun 18, 2009 at 1:21 AM, Rowdy Rednose wrote: > > I've come up with this: > > (defn inc-values-in-map >  [map keys] >  (merge-with + map (zipmap keys (repeat 1 I'm glad you found a solution you liked better, but I like how succinct this one is. However, I would offer a friendly recom

Re: Clojure in "Computing in Science and Engineering"

2009-06-18 Thread Rich Hickey
On Thu, Jun 18, 2009 at 2:00 AM, Konrad Hinsen wrote: > > The July/August issue of the IEEE magazine "Computing in Science and > Engineering" has an introduction to functional programming for > scientists that uses Clojure for the examples. It is already > available (a bit in advance of the paper

Re: Clojure STM not serializable

2009-06-18 Thread Rich Hickey
On Jun 18, 2009, at 2:38 AM, Eric Willigers wrote: > > Hi all, > > I'm enjoying using Clojure. It is clean, concise and powerful. > > The containers and even defmacro are easy to use correctly. However, > I'm yet to be convinced the same applies with the STM implementation. > > In the user code

Re: Clojure STM not serializable

2009-06-18 Thread Christian Vest Hansen
You can use `ensure` if you want to make sure that the transaction fails if a or b are altered while the threads are sleeping in your example: http://clojure.org/api#ensure Otherwise, regarding serializable concurrency level: If you want mutual exclusion, then that's what locks are for. On Thu,

Clojure STM not serializable

2009-06-18 Thread Eric Willigers
Hi all, I'm enjoying using Clojure. It is clean, concise and powerful. The containers and even defmacro are easy to use correctly. However, I'm yet to be convinced the same applies with the STM implementation. In the user code below, people might expect b == a + 1 after the two transactions r

Re: Apply a function to some values in a map

2009-06-18 Thread Rowdy Rednose
It's actually good to have default values for non-existing entries, as in Timothy's examples. Otherwise the previous version will throw NPEs. So: (defn map-map ([f map] (map-map f map (keys map) nil)) ([f map keys] (map-map f map keys nil)) ([f map keys default] (reduce (fn [m k] (asso

Re: Apply a function to some values in a map

2009-06-18 Thread Rowdy Rednose
Thanks for the ideas guys I especially like the reduce/assoc approach. It's the one most clear to me so far and also the most efficient one, I guess, as it does only one assoc per changed key, without creating other intermediate maps. So this is what I ended up using, with the nice side-effect t

Re: Adding source file information to compiler exceptions

2009-06-18 Thread vseguip
Thanks for the link, I hadn't seen it. It seems like an overkill for what is in an essence a 4 line patch to have to sign the CA send it to Rich via postal mail, specially considering I'm from Spain and wait for his approval. I can do it if there isn't any other option though. Cheers, V. Seguí

Re: Apply a function to some values in a map

2009-06-18 Thread Stephen C. Gilardi
On Jun 18, 2009, at 2:39 AM, Stephen C. Gilardi wrote: (defn map-vals ([f m] (reduce conj {} (map (fn [[k v]] [k (f v)]) m))) ([f m keyseq] (conj m (map-vals f (select-keys m keyseq) I like the two-argument map-vals better in this version: (defn map-vals ([f m]