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
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
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
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)
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
(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:
>
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
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
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
--~--~-~--~~~---~--~-
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
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
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
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.
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
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),
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
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"
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:
>
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
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
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 &
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
>
> (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
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
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) ...)
>
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
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
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
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
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
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
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
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
> 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
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
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
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
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
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)
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
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
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
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"
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
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
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
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
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
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,
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
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
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
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í
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]
54 matches
Mail list logo