Re: Confused about comp

2012-12-15 Thread Peter West


On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>
> (I took the liberty of replacing #(= \a %) with #{\a})
>
> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg 
> 
> > wrote:
>
>> (comp (partial apply str) (partial filter #{\a}))
>>
>
>
You're most welcome. Thank you for this.

A couple of questions, if I may.

In (partial apply str) why the apply?

Given the apply, why the partial?

Thanks
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.core/format generalization

2012-12-15 Thread Alexander Semenov
Sorry for that stupid question. Was coding to much. :)

Cheers.

On Saturday, December 15, 2012 3:42:24 AM UTC+3, Alexander Semenov wrote:
>
> Hi, folks.
>
> I need a generalized version of clojure.core/format function, i.e. 
> function that accepts a pattern like "-%s-%s-%s-", two functions and format 
> args. It most return a 'formatted' seq. The first supplied function is 
> called for each non-special character from the pattern and returns its 
> uplifted version (wrapped in vector, for example), another function is 
> called for each special character substitution which is then uplifted as 
> well. So, to demonstrate its usage perspective:
>
> (gen-format
>   "-%s-%s-%s-"
>   vector
>   (fn [x] (vector x (get-some-meta-info x))
>   :one
>   :two
>   :three)
>
> Result: ([-] [:one some-meta-1] [-] [:two some-meta-2] [-] [:three 
> some-meta-3] [-]).
>
> Should I implement such an abstraction myself or there is something ready?
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Baishampayan Ghose
The apply is needed here because filter is going to return a sequence
of strings and you really want to `apply' str on it.

-BG

On Sat, Dec 15, 2012 at 1:39 PM, Peter West  wrote:
> A couple of questions, if I may.
>
> In (partial apply str) why the apply?
>
> Given the apply, why the partial?



--
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Confused about comp

2012-12-15 Thread Peter West


On Saturday, 15 December 2012 18:09:13 UTC+10, Peter West wrote:
>
>
>
> On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>>
>> (I took the liberty of replacing #(= \a %) with #{\a})
>>
>> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg wrote:
>>
>>> (comp (partial apply str) (partial filter #{\a}))
>>>
>>
>>
> You're most welcome. Thank you for this.
>
> A couple of questions, if I may.
>
> In (partial apply str) why the apply?
>
> Given the apply, why the partial?
>
>
About the 'apply', apply takes at least [f args], but (apply str) has only 
[f]. 'partial' establishes a context in which some args are assumed to be 
missing, and are assumed to be applied when the partial function is 
applied. Is this correct?

'comp' doesn't work in the place of 'partial'. So (comp apply str) doesn't 
work for (at least) the same reason that (apply str) doesn't work. 'str' 
returns a single value, which means that the arg list to be presented to 
apply consists of only a single value, instead of [f args]. Is this correct?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Full Syntactical Reference

2012-12-15 Thread John Gabriele
On Friday, December 14, 2012 6:40:50 PM UTC-5, lin...@redhandgaming.net 
wrote:

>
> Where can I find, or does there exist, a place where I can view all 
> Clojure's built in functions with a short description of their arguments 
> and what they do?
>

As Andy pointed out, Clojuredocs is the place for that.

Extremely handy is the [cheatsheet](http://clojure.org/cheatsheet), which 
contains links throughout to clojuredocs for many commonly-used functions. 
(Note the link at the top of that page which points to versions of the 
cheatsheet with tooltips).

---John

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Peter West
Thanks Baishampayan.

I'm still puzzled about this though, because (doc str) says that with one 
argument x, str returns x.toString(). What it returns is
"clojure.lang.LazySeq@fe1"

So it seems to be returning a lazy sequence. Why is the function not simply 
applied? Other functions are "applied" simple by expressing their form.


On Saturday, 15 December 2012 18:52:26 UTC+10, Baishampayan Ghose wrote:
>
> The apply is needed here because filter is going to return a sequence 
> of strings and you really want to `apply' str on it. 
>
> -BG 
>
> On Sat, Dec 15, 2012 at 1:39 PM, Peter West 
> > 
> wrote: 
> > A couple of questions, if I may. 
> > 
> > In (partial apply str) why the apply? 
> > 
> > Given the apply, why the partial? 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Peter West
On Saturday, 15 December 2012 17:42:05 UTC+10, puzzler wrote:
>
> (I took the liberty of replacing #(= \a %) with #{\a})
>
> On Fri, Dec 14, 2012 at 11:37 PM, Mark Engelberg 
> 
> > wrote:
>
>> (comp (partial apply str) (partial filter #{\a}))
>>
>
>
Puzzler,

Your change replaces the single argument function with a single element 
set. This is because a set is a function of its members, returning true if 
an argument is a member of the set?
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Marko Topolnik


> I'm still puzzled about this though, because (doc str) says that with one 
> argument x, str returns x.toString(). What it returns is
> "clojure.lang.LazySeq@fe1"
>
> So it seems to be returning a lazy sequence. Why is the function not 
> simply applied? Other functions are "applied" simple by expressing their 
> form. 
>

No, it is returning exactly as advertised, the result of calling 
#toString() on an instance of LazySeq.

The difference between (str a-lazy-seq) and (apply str a-lazy-seq) is that 
in the first case str is called with one argument, the lazy seq, and in the 
second case with, say 5 arguments, for a lazy seq of length 5. The lazy seq 
is *spliced* into separate arguments to str. 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Baishampayan Ghose
An example will make it clear for you...

(str ) => (str '("foo" "bar" "baz"))

(apply str ) => (str "foo" "bar" "baz)

Hope this helps.

-BG

On Sat, Dec 15, 2012 at 3:48 PM, Peter West  wrote:
> Thanks Baishampayan.
>
> I'm still puzzled about this though, because (doc str) says that with one
> argument x, str returns x.toString(). What it returns is
> "clojure.lang.LazySeq@fe1"
>
> So it seems to be returning a lazy sequence. Why is the function not simply
> applied? Other functions are "applied" simple by expressing their form.
>
>
> On Saturday, 15 December 2012 18:52:26 UTC+10, Baishampayan Ghose wrote:
>>
>> The apply is needed here because filter is going to return a sequence
>> of strings and you really want to `apply' str on it.
>>
>> -BG
>>
>> On Sat, Dec 15, 2012 at 1:39 PM, Peter West  wrote:
>> > A couple of questions, if I may.
>> >
>> > In (partial apply str) why the apply?
>> >
>> > Given the apply, why the partial?
>>
>>
>>
>> --
>> Baishampayan Ghose
>> b.ghose at gmail.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Need ideas for carving project into namespaces

2012-12-15 Thread Jim - FooBar();

I know my reply is a bit delayed but the past 2-3 days have been frantic!

On 12/12/12 18:00, Michał Marczyk wrote:

@Jim:

That function generates factory functions which themselves use no
reflection and incur no performance penalty at all. The only
performance hit visible at runtime comes from the fact that generating
those factory functions involves compiling code at runtime (but you
should hopefully be able to arrange things so that you only need to do
it once per type).


aaa ok that is good to know...I'm not sure what you mean by "re-arrange 
things so that you only need to do
it once per type " though. I am only interested in creating pieces of a 
single type per 'session'. My lib for writing board games 
(core/gui/searching/ai) deals with one game at a time. IN other words 
you can't open up a single gui showing 2 games or do any tree-searching 
for that matter! That makes sense right?



Also, the class named by the recordname argument needs to exist when
record-factory is called, so I'm not sure it can really be of much
help in dealing with circular dependencies.


Well, surely it must 'exist', however it doesn't have to be :required or 
:imported or :used so you avoid creating circular dependencies in the 
first place. I can confirm this because for example, my 'games/chess' ns 
depends on 'lib/core'  which depends on 'lib/util' (where the 
record-factory is)  and i can create a ChessPiece record by passing the 
fully qualified record-name from chess.clj -> core.clj -> util.clj and 
get back the actual ChessPiece object. No circular dependencies. If i 
didn't have that, I'd have to :import ChessPiece in util.clj and in fact 
the end-user would need a way of injecting :imports into util.clj which 
I 'm not even sure it's possible. Now the end-user uses ctor directly 
(which he has access to as he is the one who define the pieces for the 
game he's writing). However it is perfectly possible to go the "long 
way" and pass a string to core.clj and then to util.clj and return the 
object back to chess.clj. I'm certainly not advocating this is a good or 
a nice approach but it can be done if performance is not considered 
critical. In fact, the discussion going on on this thread is quite 
enlightening... I never realised people were having so many problems 
with circular dependencies.



Jim




--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Need ideas for carving project into namespaces

2012-12-15 Thread Jim - FooBar();

@Mark
To be honest i cannot answer your question...however it works...demo 
follows:


sorted@sorted-desktop:~$ lein2 repl
nREPL server started on port 50832
REPL-y 0.1.0-beta10
Clojure 1.4.0
Exit: Control+D or (exit) or (quit)
Commands: (user/help)
Docs: (doc function-name-here)
  (find-doc "part-of-name-here")
  Source: (source function-name-here)
  (user/sourcery function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
  (user/clojuredocs name-here)
  (user/clojuredocs "ns-here" "name-here")
user=> (defn record-factory [recordname]
  #_=>   (let [recordclass ^Class (resolve (symbol recordname))
  #_=> max-arg-count (apply max (map #(count 
(.getParameterTypes ^java.lang.reflect.Constructor %))
  #_=>(.getConstructors 
recordclass)))
  #_=> args (map #(symbol (str "x" %)) (range (- max-arg-count 
2)))]

  #_=> (eval `(fn [~@args] (new ~(symbol recordname) ~@args)
#'user/record-factory
user=> (ns foo)
nil
foo=> (defrecord Bar [x y])
foo.Bar
foo=> (ns user)  ;;back to user ns (doesn't depend on foo)
nil
user=> ((record-factory "foo.Bar") 1 2)
#foo.Bar{:x 1, :y 2}
user=> (Bar. 1 2)
CompilerException java.lang.IllegalArgumentException: Unable to resolve 
classname: Bar, compiling:(NO_SOURCE_PATH:1)



Jim


On 12/12/12 17:59, Mark Engelberg wrote:
On Wed, Dec 12, 2012 at 9:53 AM, Jim - FooBar(); > wrote:


Yes it would...You're using reflection so no need to :use or
:require the namespaces any more.
Point your browser here if you're not following:
https://github.com/jimpil/Clondie24/blob/master/src/Clondie24/lib/util.clj


What gets those classes loaded/imported to begin with?  I don't see 
how the classes ever get built if nobody requires the file containing 
the defrecords.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

another n00b defrecord combination question

2012-12-15 Thread mond
I have defined these types of records for modelling a simple shopping cart:

; An item in the cart
(defrecord Item [id name product quantity purchased])

; The product that relates to the item in the cart
(defrecord Product [id name description prices])

; A price definition
(defrecord Price [price tax-rate currency])


; Sample items
(def items [
 (->Item 1 "Brogues" "P-123" 1 true)
 (->Item 2 "Underpants" "P-345" 1 false)
 (->Item 3 "Shirt" "P-678" 1 true)
 ])

; Sample products
(def products [
(->Product "P-123" "Brogues" "Men's Leather Slip on 
Brogues" (->Price 93.00 21 "EURO"))
(->Product "P-345" "Underpants" "CK Y Fronts" (->Price 
23.50 21 "EURO"))
(->Product "P-678" "Shirt" "Slim Fit White Vest Shirt" 
(->Price 45.99 21 "EURO"))
(->Product "P-1231" "Table" "Coffee Table" (->Price 375 21 
"EURO"))
(->Product "P-3451" "Chairs" "Set of Four(4) chairs" 
(->Price 200 21 "EURO"))
(->Product "P-6781" "TableCloth" "Classic red and white 
checks 2m x 2m" (->Price 17.99 21 "EURO"))
])

My requirement is to combine data from the two collections such that I can 
show the detailed product information for any item, for example:

 (->Item 3 "Shirt" "Slim Fit White Vest Shirt" (->Price 45.99 
21 "EURO") 1 true)

When I tried to use merge-with union I had an error which surprised me 
since I thought records are also maps:

user=> (merge-with union items products)
ClassCastException user.Product cannot be cast to java.util.Map$Entry 
 clojure.core/key (core.clj:1465)

Although I will fight on, any tips from any of you that have done this 
before would be greatly helped.

Thanks

ray

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Armando Blancas

>
> (comp (partial apply str) (partial filter #{\a}))
>

Or, (comp join (partial filter #{\a}))
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: another n00b defrecord combination question

2012-12-15 Thread mond
I think I am close to answering this myself (which is always nice!)

I have done the necessary joins with map and I can return a product 
description

user=> (map (fn [item product] (= (:product item (:id product))) 
(:description product)) items products)
("Men's Leather Slip on Brogues" "CK Y Fronts" "Slim Fit White Vest Shirt")

Or a purchased status for the matching item

user=> (map (fn [item product] (= (:product item (:id product))) 
(:purchased item)) items products)
(true false true)

But I have my knickers in a twist when I want to get more than one value 
out or a combination of values. 

user=> (map (fn [item product] (= (:product item (:id product))) (:id item 
:description product)) items products)
(user=> IllegalArgumentException Wrong number of args passed to keyword: 
:id  clojure.lang.Keyword.throwArity (Keyword.java:85)

So does anyone have the last bit of syntax to help me take back a list of 
values from the inputs?

Thanks

ray


On Saturday, December 15, 2012 5:25:59 PM UTC+1, mond wrote:
>
> I have defined these types of records for modelling a simple shopping cart:
>
> ; An item in the cart
> (defrecord Item [id name product quantity purchased])
>
> ; The product that relates to the item in the cart
> (defrecord Product [id name description prices])
>
> ; A price definition
> (defrecord Price [price tax-rate currency])
>
>
> ; Sample items
> (def items [
>  (->Item 1 "Brogues" "P-123" 1 true)
>  (->Item 2 "Underpants" "P-345" 1 false)
>  (->Item 3 "Shirt" "P-678" 1 true)
>  ])
>
> ; Sample products
> (def products [
> (->Product "P-123" "Brogues" "Men's Leather Slip on 
> Brogues" (->Price 93.00 21 "EURO"))
> (->Product "P-345" "Underpants" "CK Y Fronts" (->Price 
> 23.50 21 "EURO"))
> (->Product "P-678" "Shirt" "Slim Fit White Vest Shirt" 
> (->Price 45.99 21 "EURO"))
> (->Product "P-1231" "Table" "Coffee Table" (->Price 375 21 
> "EURO"))
> (->Product "P-3451" "Chairs" "Set of Four(4) chairs" 
> (->Price 200 21 "EURO"))
> (->Product "P-6781" "TableCloth" "Classic red and white 
> checks 2m x 2m" (->Price 17.99 21 "EURO"))
> ])
>
> My requirement is to combine data from the two collections such that I can 
> show the detailed product information for any item, for example:
>
>  (->Item 3 "Shirt" "Slim Fit White Vest Shirt" (->Price 45.99 
> 21 "EURO") 1 true)
>
> When I tried to use merge-with union I had an error which surprised me 
> since I thought records are also maps:
>
> user=> (merge-with union items products)
> ClassCastException user.Product cannot be cast to java.util.Map$Entry 
>  clojure.core/key (core.clj:1465)
>
> Although I will fight on, any tips from any of you that have done this 
> before would be greatly helped.
>
> Thanks
>
> ray
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: another n00b defrecord combination question

2012-12-15 Thread mond
OK - I have it now:

(map (fn [item product] (= (:product item (:id product))) [(:id item) 
(:description product)]) items products)

This feels OK to me but if anyone has a nicer / more idiomatic solution, I 
will be happy to take feedback.

ray

On Saturday, December 15, 2012 7:08:21 PM UTC+1, mond wrote:
>
> I think I am close to answering this myself (which is always nice!)
>
> I have done the necessary joins with map and I can return a product 
> description
>
> user=> (map (fn [item product] (= (:product item (:id product))) 
> (:description product)) items products)
> ("Men's Leather Slip on Brogues" "CK Y Fronts" "Slim Fit White Vest Shirt")
>
> Or a purchased status for the matching item
>
> user=> (map (fn [item product] (= (:product item (:id product))) 
> (:purchased item)) items products)
> (true false true)
>
> But I have my knickers in a twist when I want to get more than one value 
> out or a combination of values. 
>
> user=> (map (fn [item product] (= (:product item (:id product))) (:id item 
> :description product)) items products)
> (user=> IllegalArgumentException Wrong number of args passed to keyword: 
> :id  clojure.lang.Keyword.throwArity (Keyword.java:85)
>
> So does anyone have the last bit of syntax to help me take back a list of 
> values from the inputs?
>
> Thanks
>
> ray
>
>
> On Saturday, December 15, 2012 5:25:59 PM UTC+1, mond wrote:
>>
>> I have defined these types of records for modelling a simple shopping 
>> cart:
>>
>> ; An item in the cart
>> (defrecord Item [id name product quantity purchased])
>>
>> ; The product that relates to the item in the cart
>> (defrecord Product [id name description prices])
>>
>> ; A price definition
>> (defrecord Price [price tax-rate currency])
>>
>>
>> ; Sample items
>> (def items [
>>  (->Item 1 "Brogues" "P-123" 1 true)
>>  (->Item 2 "Underpants" "P-345" 1 false)
>>  (->Item 3 "Shirt" "P-678" 1 true)
>>  ])
>>
>> ; Sample products
>> (def products [
>> (->Product "P-123" "Brogues" "Men's Leather Slip on 
>> Brogues" (->Price 93.00 21 "EURO"))
>> (->Product "P-345" "Underpants" "CK Y Fronts" (->Price 
>> 23.50 21 "EURO"))
>> (->Product "P-678" "Shirt" "Slim Fit White Vest Shirt" 
>> (->Price 45.99 21 "EURO"))
>> (->Product "P-1231" "Table" "Coffee Table" (->Price 375 
>> 21 "EURO"))
>> (->Product "P-3451" "Chairs" "Set of Four(4) chairs" 
>> (->Price 200 21 "EURO"))
>> (->Product "P-6781" "TableCloth" "Classic red and white 
>> checks 2m x 2m" (->Price 17.99 21 "EURO"))
>> ])
>>
>> My requirement is to combine data from the two collections such that I 
>> can show the detailed product information for any item, for example:
>>
>>  (->Item 3 "Shirt" "Slim Fit White Vest Shirt" (->Price 45.99 
>> 21 "EURO") 1 true)
>>
>> When I tried to use merge-with union I had an error which surprised me 
>> since I thought records are also maps:
>>
>> user=> (merge-with union items products)
>> ClassCastException user.Product cannot be cast to java.util.Map$Entry 
>>  clojure.core/key (core.clj:1465)
>>
>> Although I will fight on, any tips from any of you that have done this 
>> before would be greatly helped.
>>
>> Thanks
>>
>> ray
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: another n00b defrecord combination question

2012-12-15 Thread Benjamin R. Haskell

(responses inline)

On Sat, 15 Dec 2012, mond wrote:


I have defined these types of records for modelling a simple shopping cart:

; An item in the cart
(defrecord Item [id name product quantity purchased])

; The product that relates to the item in the cart
(defrecord Product [id name description prices])

; A price definition
(defrecord Price [price tax-rate currency])


; Sample items
(def items [
(->Item 1 "Brogues" "P-123" 1 true)
(->Item 2 "Underpants" "P-345" 1 false)
(->Item 3 "Shirt" "P-678" 1 true)
])

; Sample products
(def products [
   (->Product "P-123" "Brogues" "Men's Leather Slip on
Brogues" (->Price 93.00 21 "EURO"))
   (->Product "P-345" "Underpants" "CK Y Fronts" (->Price
23.50 21 "EURO"))
   (->Product "P-678" "Shirt" "Slim Fit White Vest Shirt"
(->Price 45.99 21 "EURO"))
   (->Product "P-1231" "Table" "Coffee Table" (->Price 375 21
"EURO"))
   (->Product "P-3451" "Chairs" "Set of Four(4) chairs"
(->Price 200 21 "EURO"))
   (->Product "P-6781" "TableCloth" "Classic red and white
checks 2m x 2m" (->Price 17.99 21 "EURO"))
   ])

My requirement is to combine data from the two collections such that I can
show the detailed product information for any item, for example:

(->Item 3 "Shirt" "Slim Fit White Vest Shirt" (->Price 45.99 21 
"EURO") 1 true)

When I tried to use merge-with union I had an error which surprised me 
since I thought records are also maps:


user=> (merge-with union items products)
ClassCastException user.Product cannot be cast to java.util.Map$Entry
clojure.core/key (core.clj:1465)


It looks like your second response worked around it, but for anyone 
following along: merge-with takes two or more maps, and uses the 
function you pass to merge the values of common keys.  So, the error is 
caused because merge-with expects items and products to be maps (not 
vectors of map-like things).



On Sat, 15 Dec 2012, mond wrote:


I think I am close to answering this myself (which is always nice!)

I have done the necessary joins with map and I can return a product
description

user=> (map (fn [item product] (= (:product item (:id product)))
(:description product)) items products)
("Men's Leather Slip on Brogues" "CK Y Fronts" "Slim Fit White Vest Shirt")


The (= (:product item (:id product))) here is being ignored. 
It "works" because your example arrays happen to have the items and 
products lined up properly (first three products match the items 
in order):


(map (fn [item product]
   (= (:product item (:id product))) ; the result of this comparison is 
thrown away
   (:description product) ; this is the value that is returned
) items products)

If you want to match things up, you might be better off creating maps 
for each category of thing:


; (with items and products as you'd defined them before)
(def product->item (zipmap (map :product items) items))
;=> {"P-123" #user.Item{...}, "P-345" #user.Item{...}, ...}

(def id->product (zipmap (map :id products) products))
;=> {"P-123" #user.Product{...}, "P-345" #user.Product{...}, ...}

(def combined (merge-with union product->item id->product))
;=> {"P-123" #user.Product{... with :quantity and :purchased },
;"P-1231" #user.Product{... with no Item keys ...}, ...etc.



Or a purchased status for the matching item

user=> (map (fn [item product] (= (:product item (:id product)))
(:purchased item)) items products)
(true false true)

But I have my knickers in a twist when I want to get more than one 
value out or a combination of values.


user=> (map (fn [item product] (= (:product item (:id product))) (:id item
:description product)) items products)
(user=> IllegalArgumentException Wrong number of args passed to keyword:
:id  clojure.lang.Keyword.throwArity (Keyword.java:85)

So does anyone have the last bit of syntax to help me take back a list 
of values from the inputs?


Other than the matching issue (the = form isn't being used -- see 
above), the problem with what you've written is that you want a map, 
rather than a list:


(map (fn [item product] {:id item :description product}) items products)

Or if you really want a list, you need to quote it:

(map (fn [item product] '(:id item :description product)) items products)

--
Best,
Ben

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: another n00b defrecord combination question

2012-12-15 Thread Benjamin R. Haskell

On Sat, 15 Dec 2012, Benjamin R. Haskell wrote:


Or if you really want a list, you need to quote it:

(map (fn [item product] '(:id item :description product)) items products)


Oops, wrong.  Rather, you would want clojure.core/list:

(map (fn [item product] (list :id item :description product)) items products)

--
Best,
Ben

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Long response time after a clojure process was inactive for some time

2012-12-15 Thread Stefan Ring
On Thursday, December 13, 2012 8:21:09 PM UTC+1, Trastabuga wrote:
>
> A while ago I created a small web site based on Clojure. I noticed that 
> when there was no requests to the site for some period of time (a few 
> hours) it may take up to 20-30 seconds to process an incoming request.
> I am wondering, what's the reason for this time lag after some period of 
> inactivity in a Clojure process? Is it Java specific? 
>
> Sounds like the JVM process gets swapped out during the period of 
inactivity.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Marek Šrank
...which should be also a lot faster :)

On Saturday, December 15, 2012 5:44:01 PM UTC+1, Armando Blancas wrote:
>
> (comp (partial apply str) (partial filter #{\a}))
>>
>
> Or, (comp join (partial filter #{\a}))
>  
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Alan Malloy
Nonsense. Why would that be any faster? (join coll) is defined as (apply 
str coll).

On Saturday, December 15, 2012 12:21:45 PM UTC-8, Marek Šrank wrote:
>
> ...which should be also a lot faster :)
>
> On Saturday, December 15, 2012 5:44:01 PM UTC+1, Armando Blancas wrote:
>>
>> (comp (partial apply str) (partial filter #{\a}))
>>>
>>
>> Or, (comp join (partial filter #{\a}))
>>  
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: another n00b defrecord combination question

2012-12-15 Thread mond
Thanks for picking up the cudgels Ben!

To be honest I am struggling to repeat your advice in the REPL.  In any 
case, I decided to change the data structures in line with your advice and 
put the IDs into maps rather than the records.

(defrecord Item [name product quantity purchased])

(defrecord Product [name description prices])

(defrecord Price [price tax currency])

(def items [ {:id 1 :item (->Item "Brogues" "P-123" 1 true)}
 {:id 2 :item (->Item "Underpants" "P-345" 2 false)}
 {:id 3 :item (->Item "Shirt" "P-678" 1 true)} ])

(def carts [ (->Cart "Birthday" (first items))
 (->Cart "Xmas" (rest items)) ])

(def products [ {:id "P-1231" :product (->Product "Table" "Coffee Table" 
(->Price 375 21 "EURO"))}
{:id "P-3451" :product (->Product "Chairs" "Set of Four(4) 
chairs" (->Price 200 21 "EURO"))}
{:id "P-123" :product (->Product "Brogues" "Men's Leather 
Slip on Brogues" (->Price 93.00 21 "EURO"))}
{:id "P-345" :product (->Product "Underpants" "CK Y Fronts" 
(->Price 23.50 21 "EURO"))}
{:id "P-678" :product (->Product "Shirt" "Slim Fit White 
Vest Shirt" (->Price 45.99 21 "EURO"))}
{:id "P-6781" :product (->Product "TableCloth" "Classic red 
and white checks 2m x 2m" (->Price 17.99 21 "EURO"))} ])

Do you think the zipmap is still the way to go (to resolve the 'foreign 
key' or could there be an easier way? I guess the fact that only items have 
to zipmapped is one advantage.

Thanks for your support

ray


On Saturday, December 15, 2012 7:53:32 PM UTC+1, Benjamin R. Haskell wrote:
>
> On Sat, 15 Dec 2012, Benjamin R. Haskell wrote: 
>
> > Or if you really want a list, you need to quote it: 
> > 
> > (map (fn [item product] '(:id item :description product)) items 
> products) 
>
> Oops, wrong.  Rather, you would want clojure.core/list: 
>
> (map (fn [item product] (list :id item :description product)) items 
> products) 
>
> -- 
> Best, 
> Ben 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Clojure syntax coloring for wordpress blogs

2012-12-15 Thread Nick Gonzalez
Does anyone have a good method for syntax coloring clojure code snippets 
for a wordpress blog?  I've recently started my new blog, and I'm posting 
clojure snippets, and would like for them to be syntax highlighted and 
indented properly.

Nick Gonzalez

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: defrecord and overriding "empty"

2012-12-15 Thread Joseph Smith
Well here I am over a year later with the same problem. I'm curious, what 
was your solution for the time being?

On Tuesday, September 27, 2011 1:06:37 PM UTC-5, David Nolen wrote:
>
> On Tue, Sep 27, 2011 at 1:54 PM, Nathan Sorenson 
> > wrote:
>
>> Should IPersistentCollection even be defining 'empty', if one of the 
>> language's key data types doesn't support it? I think it would be better to 
>> either pull 'empty' into it's own protocol so clojure.walk doesn't match on 
>> IPersistentCollection when walking a data structure with the false 
>> expectation that it can create an empty version, or rename 'empty' it to 
>> something that records can implement, like 'default.' 
>
>
> This is a fair point. ClojureScript fixes this by providing 
> IEmptyableCollection.
>
> David 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

JavaFX and Clojure

2012-12-15 Thread Christian Sperandio
Hi,

After some studies about JavaFX with Clojure, and bricks broke with my 
head, I wrote a sort of wrapper to work more easily with both.
It's here : https://github.com/chrix75/javafx-clj

You can play with JavaFX in your REPL and you have the macro with-javax and 
wit-javafx-let that let you write JavaFX code  without managing the JavaFX 
runtime thread.

I hope it can help.

Chris

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ClojureCLR binary download issue

2012-12-15 Thread Shantanu Kumar
Hi,

Thought to bring up the recent ClojureCLR binary download issue:

1. The http://clojure.org/ homepage links ClojureCLR to the old Github repo.
2. The `Download` links on ClojureCLR repo have gone missing: 
https://github.com/clojure/clojure-clr

#2 may have to do with Github's recent announcement to drop the Downloads 
feature. The old URLs continue to work for download, but it may not be 
possible for first timers to know them. I'd suggest to put up the downloads 
at the Clojure website's Download page: http://clojure.org/downloads


[Off-topic] -- I noticed this when I wanted to confirm the binaries because 
I was running into the following error:

FATAL UNHANDLED EXCEPTION: System.MissingFieldException: Field 
'clojure.lang.RT.OutVar' not found.

Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: another n00b defrecord combination question

2012-12-15 Thread Benjamin R. Haskell

On Sat, 15 Dec 2012, mond wrote:


Thanks for picking up the cudgels Ben!


Ha.  It's nice to have reached a point where I feel at-all confident 
with any of this... happy to help.



To be honest I am struggling to repeat your advice in the REPL.  In 
any case, I decided to change the data structures in line with your 
advice and put the IDs into maps rather than the records.


(defrecord Item [name product quantity purchased])

(defrecord Product [name description prices])

(defrecord Price [price tax currency])

(def items [ {:id 1 :item (->Item "Brogues" "P-123" 1 true)}
             {:id 2 :item (->Item "Underpants" "P-345" 2 false)}
             {:id 3 :item (->Item "Shirt" "P-678" 1 true)} ])

(def carts [ (->Cart "Birthday" (first items))
             (->Cart "Xmas" (rest items)) ])

(def products [ {:id "P-1231" :product (->Product "Table" "Coffee Table" (->Price 375 21 
"EURO"))}
                {:id "P-3451" :product (->Product "Chairs" "Set of Four(4) chairs" 
(->Price 200 21 "EURO"))}
                {:id "P-123" :product (->Product "Brogues" "Men's Leather Slip on Brogues" 
(->Price 93.00 21 "EURO"))}
                {:id "P-345" :product (->Product "Underpants" "CK Y Fronts" (->Price 
23.50 21 "EURO"))}
                {:id "P-678" :product (->Product "Shirt" "Slim Fit White Vest Shirt" 
(->Price 45.99 21 "EURO"))}
                {:id "P-6781" :product (->Product "TableCloth" "Classic red and white checks 2m x 
2m" (->Price 17.99 21 "EURO"))} ])

Do you think the zipmap is still the way to go (to resolve the 
'foreign key' or could there be an easier way? I guess the fact that 
only items have to zipmapped is one advantage.


It seems like items and products should still have an :id property, so I 
don't think you need to detach the ID from its entity.  The zipmap'ed 
version is useful as an index, not really as its own structure.  So, it 
ends up as just a single map (not an array of maps) with ID's as keys, 
and the corresponding entity as the value:



(defrecord Item [id name product quantity purchased])

(defrecord Product [id name description prices])

(defrecord Price [price tax currency])

(def items [ (->Item 1 "Brogues" "P-123" 1 true)
             (->Item 2 "Underpants" "P-345" 2 false)
             (->Item 3 "Shirt" "P-678" 1 true) ])

(def products [ (->Product "P-1231" "Table" "Coffee Table" (->Price 375 21 
"EURO"))
                (->Product "P-3451" "Chairs" "Set of Four(4) chairs" (->Price 200 21 
"EURO"))
                (->Product "P-123" "Brogues" "Men's Leather Slip on Brogues" (->Price 
93.00 21 "EURO"))
                (->Product "P-345" "Underpants" "CK Y Fronts" (->Price 23.50 21 
"EURO"))
                (->Product "P-678" "Shirt" "Slim Fit White Vest Shirt" (->Price 45.99 21 
"EURO"))
                (->Product "P-6781" "TableCloth" "Classic red and white checks 2m x 2m" 
(->Price 17.99 21 "EURO")) ])

; two useful indexes(/indices?):

(def prod->item
  "An index from Product ID to an Item"
  (zipmap (map :product items) items))

(def id->product
  "An index from Product ID to a Product"
  (zipmap (map :id products) products))

; Then you can use that to get the products joined with their items:

(defn product-with-item
  "Find the Item info and merge it into the product, without overwriting :id"
  [product]
  (merge-with (fn [a b] a) product (prod->item (:id product

; example usage:

(product-with-item (id->product "P-345"))
;=> #user.Product{:id 2,
; :name "Underpants",
; :description "CK Y Fronts",
; :prices #user.Price{:price 23.5, :tax 21, :currency "EURO"},
; :purchased false,
; :quantity 2,
; :product "P-345"}

(def joined-products (map product-with-item products))
;=> A list of all the products joined with their items

--
Best,
Ben

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


How to structure a Clojure day for noobs?

2012-12-15 Thread ulsa
In a couple of months, I'll have a whole day of teaching Clojure to ten of 
my colleagues. They are experienced Java programmers, but otherwise Clojure 
rookies. Any tips on how to structure such a workshop day?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to structure a Clojure day for noobs?

2012-12-15 Thread Marko Topolnik
There is one advice I can give from my teaching experience: don't overwhelm 
them with data. A person can assimilate only so many concepts in a day, no 
matter whether the workshop lasts two or eight hours. 

Pick a few key concepts and spend much time on approaching each concept 
from many different angles. Have everyone involved with exercises. Make 
layered exercises: each of those ten people is going to progress at their 
own pace. Allow enough time for the slowest ones to get through the basic 
part of the exercise, but have a stash of extra stuff for the quicker ones, 
so they don't get bored and frustrated while waiting on others.

On Saturday, December 15, 2012 11:13:21 PM UTC+1, ulsa wrote:
>
> In a couple of months, I'll have a whole day of teaching Clojure to ten of 
> my colleagues. They are experienced Java programmers, but otherwise Clojure 
> rookies. Any tips on how to structure such a workshop day?
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: defrecord and overriding "empty"

2012-12-15 Thread David Nolen
In core.logic we have a protocol called IUninitialized that you can
implement. That works well enough for our needs.

On Saturday, December 15, 2012, Joseph Smith wrote:

> Well here I am over a year later with the same problem. I'm curious, what
> was your solution for the time being?
>
> On Tuesday, September 27, 2011 1:06:37 PM UTC-5, David Nolen wrote:
>>
>> On Tue, Sep 27, 2011 at 1:54 PM, Nathan Sorenson  wrote:
>>
>>> Should IPersistentCollection even be defining 'empty', if one of the
>>> language's key data types doesn't support it? I think it would be better to
>>> either pull 'empty' into it's own protocol so clojure.walk doesn't match on
>>> IPersistentCollection when walking a data structure with the false
>>> expectation that it can create an empty version, or rename 'empty' it to
>>> something that records can implement, like 'default.'
>>
>>
>> This is a fair point. ClojureScript fixes this by providing
>> IEmptyableCollection.
>>
>> David
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to 
> clojure@googlegroups.com 'clojure@googlegroups.com');>
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com  'clojure%2bunsubscr...@googlegroups.com');>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure syntax coloring for wordpress blogs

2012-12-15 Thread Alexander Solovyov
On Sat, Dec 15, 2012 at 11:02 PM, Nick Gonzalez wrote:

> Does anyone have a good method for syntax coloring clojure code snippets
> for a wordpress blog?  I've recently started my new blog, and I'm posting
> clojure snippets, and would like for them to be syntax highlighted and
> indented properly.


Highlight.js maybe?

http://softwaremaniacs.org/soft/highlight/en/

There is a plugin for wordpress:

http://wordpress.org/extend/plugins/wp-highlightjs/

-- 
Alexander

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ANN: lein-clr 0.2.0 for ClojureCLR

2012-12-15 Thread Aaron
Cool.  I'm just seeing this now.  I actually spent some time a while back 
getting a very simple nleiningen working in ClojureCLR.  I had nuget 
downloads working and also the ability to AOT compile namespaces and merge 
them into a single DLL.  It's not fully ready for prime time yet though, in 
part because it depends on some custom modifications to the ClojureCLR 
compiler.  In the long run, I'd like to work together on getting a full 
lein clr implementation working.  I'd love to discuss further if you have 
time.

By the way Dave - speaking of custom modifications to ClojureCLR, this past 
week, my colleague and I merged your latest master with our changes 
(https://github.com/kocubinski/clojure-clr).  I hope to put together some 
formal patches soon which clearly identify the changes I'm suggesting for 
the main compiler.

While we're at it, a few other things I'm working on or have working in 
clojure-clr are:
tools.logging and pinvoke (https://github.com/aaronc/ClojureClrEx) - 
logging is mostly ported but with only one backend working, 
pinvoke/dllimport works great, but no docs
a nice interface to WPF (https://github.com/aaronc/ClojureWpf) - pretty 
stable, but again no docs yet
nrepl (https://github.com/aaronc/tools.nrepl/tree/clr) - needs quite a bit 
more work

Unfortunately, I haven't been too diligent with documentation, but I hope 
to correct that as time allows.  

On Sunday, November 18, 2012 4:03:03 PM UTC-5, Shantanu Kumar wrote:
>
> Hi,
>
> I pushed lein-clr 0.2.0 https://github.com/kumarshantanu/lein-clr JARs to 
> Clojars a little while ago. The focus of this release is to
>
> 1. add dependency support (via NuGet/wget/curl, Leiningen :dependencies)
> 2. lower the bar to get started with ClojureCLR (with automated download 
> of ClojureCLR)
> 3. remove the need to call `assembly-load-from` in code
>
> The changelog and TODO are here: 
> https://github.com/kumarshantanu/lein-clr/blob/master/CHANGES.md
>
> I hope this release is usable enough to start building ClojureCLR apps and 
> libraries with it. This is an early project and can certainly use feedback 
> and contribution. Please let me know what you think.
>
> Shantanu
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: JavaFX and Clojure

2012-12-15 Thread Christian Sperandio
I had a test to show how it work.


Le samedi 15 décembre 2012 22:10:50 UTC+1, Christian Sperandio a écrit :
>
> Hi,
>
> After some studies about JavaFX with Clojure, and bricks broke with my 
> head, I wrote a sort of wrapper to work more easily with both.
> It's here : https://github.com/chrix75/javafx-clj
>
> You can play with JavaFX in your REPL and you have the macro with-javax 
> and wit-javafx-let that let you write JavaFX code  without managing the 
> JavaFX runtime thread.
>
> I hope it can help.
>
> Chris
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Peter West
Hi Mark and Baishampayan,

I can see what difference it makes, but I can't get a handle on the 
rationale. For instance, I found this discussion:
http://stackoverflow.com/questions/1257028/why-should-i-use-apply-in-clojure

It starts with a quote from a Rich Hickey blog post, as follows.

> A big difference between Clojure and CL is that Clojure is a Lisp-1, so 
> funcall is not needed, and apply is only used to apply a function to a 
> runtime-defined collection of arguments. So, (apply f [i]) can be written 
> (f i).


But it can't, can it? In this context (apply f [i]) with respect to (f i)*
 apply *has *side-effects*!

Further on in the discussion, this example is given.

(+ [1 2 3 4 5])


which does not add the numbers. But

> (apply + [1 2 3 4 5])

does.

There seem to be inscrutabilities in the way arguments are handled in 
Clojure. The reason this is so troubling is that going the other way is so 
transparent. That is, a String is automatically converted to a sequence as 
required.
 

>  


On Saturday, 15 December 2012 20:39:04 UTC+10, Marko Topolnik wrote:
>
>
> I'm still puzzled about this though, because (doc str) says that with one 
>> argument x, str returns x.toString(). What it returns is
>> "clojure.lang.LazySeq@fe1"
>>
>> So it seems to be returning a lazy sequence. Why is the function not 
>> simply applied? Other functions are "applied" simple by expressing their 
>> form. 
>>
>
> No, it is returning exactly as advertised, the result of calling 
> #toString() on an instance of LazySeq.
>
> The difference between (str a-lazy-seq) and (apply str a-lazy-seq) is that 
> in the first case str is called with one argument, the lazy seq, and in the 
> second case with, say 5 arguments, for a lazy seq of length 5. The lazy seq 
> is *spliced* into separate arguments to str. 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Confused about comp

2012-12-15 Thread Mark Engelberg
On Sat, Dec 15, 2012 at 3:58 PM, Peter West  wrote:

> But it can't, can it? In this context (apply f [i]) with respect to (f i)*
>  apply *has *side-effects*!
>

This doesn't really make any sense.  There are no side effects here.  I
think maybe you just don't understand what apply does.  Let me try to
explain it a different way.

Some functions, like +, are designed to take 1, 2, 3, 4, 5, or any number
of arguments.  You can write:
(+ 1 2)
(+ 1 2 3)
(+ 1 2 3 4)
(+ 1 2 3 4 5)
etc.
The "contract" for + is that it takes any number of numbers as an input.

One thing + can't do is add up the numbers in a list, at least not when
written in this way:
(+ [1 2 3 4 5])
This doesn't make any sense, because + is expecting numbers, and we passed
it a vector.

It might seem somewhat ironic that + can't take a list of numbers.
Obviously, it knows how to add a series of numbers, it just expects them to
be one after each other, as arguments, not all bundled up in a list.

If only we could delete those brackets around [1 2 3 4 5]...  If only we
had some sort of "adapter" that could take a list/vector of items, and pass
them in as multiple arguments to a function that was designed to take
multiple arguments...

That is what apply does.

(apply + [1 2 3 4 5]) turns into
(+ 1 2 3 4 5)

Similarly,
(apply str [\a \b \c \d]) turns into
(str \a \b \c \d)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureCLR binary download issue

2012-12-15 Thread dmiller


On Saturday, December 15, 2012 3:27:26 PM UTC-6, Shantanu Kumar wrote:
>
> Hi,
>
> Thought to bring up the recent ClojureCLR binary download issue:
>
> 1. The http://clojure.org/ homepage links ClojureCLR to the old Github 
> repo.
>

Whoever maintains the homepage will have to fix this.  Note: there are two 
links to ClojureCLR on the home page.  The one in the first paragraph is 
the one that is broken.  The one in the list further down the page is okay.

 

> 2. The `Download` links on ClojureCLR repo have gone missing: 
> https://github.com/clojure/clojure-clr
>
> #2 may have to do with Github's recent announcement to drop the Downloads 
> feature. The old URLs continue to work for download, but it may not be 
> possible for first timers to know them. I'd suggest to put up the downloads 
> at the Clojure website's Download page: http://clojure.org/downloads
>


Thanks for the notice.  I had missed it.   I don't have access to the 
clojure.org downloads page.  I'll seek an alternative for delivering the 
binaries.


> [Off-topic] -- I noticed this when I wanted to confirm the binaries 
> because I was running into the following error:
>
> FATAL UNHANDLED EXCEPTION: System.MissingFieldException: Field 
> 'clojure.lang.RT.OutVar' not found.
>
> Shantanu
>

Did this error occur from one of the downloaded binaries? Can you confirm 
which version?

-David
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Who's using Clojure?

2012-12-15 Thread vemv
Surely because Fogus was in process of upgrading it :D

go check it out now! 
http://dev.clojure.org/display/community/Clojure+Success+Stories

On Friday, December 14, 2012 3:34:23 PM UTC+1, Jeff Heon wrote:
>
> I'm asked to log in now to access this page.
>
> On Thursday, April 28, 2011 11:03:53 PM UTC-4, Christopher Redinger wrote:
>>
>> We've got a good start to the list going
>>
>> http://dev.clojure.org/display/community/Clojure+Success+Stories
>>
>> Any more we should get listed?
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Using Google Template Library with ClojureScript App

2012-12-15 Thread Ari
Hi,

Since it can not be included as a dependency, how does one integrate the 
Google Closure Template library into a Leiningen-based 
Clojure/ClojureScript application? Ideally, I'd like for the templates to 
be auto-compiled as is done for *.cljs files via the cljsbuild plugin. 
Thanks.

-Ari 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Running a clojure script

2012-12-15 Thread Mark Engelberg
Let's say I have a file "hello.clj" that simply contains the line:
(println "hello, world")

What's the simplest way to run this clojure file?  I'm looking for
something simpler than setting up a lein project.  Is there something along
the lines of:
java clojure.jar hello.clj
that would actually work?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Running a clojure script

2012-12-15 Thread Dave Ray
Yep.

   java -jar clojure.jar hello.clj

Should do the trick. Alternatively,

  java -cp clojure.jar clojure.main hello.clj

Will also work if you need to control the classpath more.

Dave

On Saturday, December 15, 2012, Mark Engelberg wrote:

> Let's say I have a file "hello.clj" that simply contains the line:
> (println "hello, world")
>
> What's the simplest way to run this clojure file?  I'm looking for
> something simpler than setting up a lein project.  Is there something along
> the lines of:
> java clojure.jar hello.clj
> that would actually work?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to 
> clojure@googlegroups.com 'clojure@googlegroups.com');>
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com  'clojure%2bunsubscr...@googlegroups.com');>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure syntax coloring for wordpress blogs

2012-12-15 Thread Vijay Kiran

I use WP-Syntax[1] plugin which uses GeSHi , which seems be working fine 
for me on my blog [2]

[1] http://wordpress.org/extend/plugins/wp-syntax/
[2] 
http://www.vijaykiran.com/2012/01/31/web-application-development-with-clojure-part-3/

On Saturday, December 15, 2012 10:02:11 PM UTC+1, Nick Gonzalez wrote:
>
> Does anyone have a good method for syntax coloring clojure code snippets 
> for a wordpress blog?  I've recently started my new blog, and I'm posting 
> clojure snippets, and would like for them to be syntax highlighted and 
> indented properly.
>
> Nick Gonzalez
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Running a clojure script

2012-12-15 Thread Mark Engelberg
Thanks.  I think that used to be on the Getting Started page, but now the
page is just links to info about how to get up and running with IDEs, so I
had trouble finding it.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureCLR binary download issue

2012-12-15 Thread Shantanu Kumar
On Sunday, 16 December 2012 06:01:54 UTC+5:30, dmiller wrote:

>
> [Off-topic] -- I noticed this when I wanted to confirm the binaries 
>> because I was running into the following error:
>>
>> FATAL UNHANDLED EXCEPTION: System.MissingFieldException: Field 
>> 'clojure.lang.RT.OutVar' not found.
>>
>> Shantanu
>>
>
> Did this error occur from one of the downloaded binaries? Can you confirm 
> which version?
>

This is the URL I downloaded ClojureCLR from, which still works even though 
the Downloads tab is not visible on Github anymore:

https://github.com/downloads/clojure/clojure-clr/clojure-clr-1.4.0-Debug-4.0.zip

The error is happening on Linux running Mono 2.10 for me. There is no error 
on Windows (both .NET and Mono.)

Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Running a clojure script

2012-12-15 Thread Armando Blancas
Why are you using puzzler's account and what did you did to him?!

On Saturday, December 15, 2012 7:28:56 PM UTC-8, puzzler wrote:
>
> Thanks.  I think that used to be on the Getting Started page, but now the 
> page is just links to info about how to get up and running with IDEs, so I 
> had trouble finding it.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

ClojureCLR errors on Mono Linux

2012-12-15 Thread Shantanu Kumar
Hi,

I noticed the following ClojureCLR errors using Mono 2.10 on Ubuntu 12.04 
(they do not happen on Windows using either .NET or Mono):

1. when running Clojure.Compile.exe:

Exception: System.MissingFieldException: Field 'clojure.lang.RT.OutVar' not 
found.

2. when using Clojure.Main.exe:

Exception: System.TypeLoadException: Could not load type 'Clojure.CljMain' 
from assembly 'Clojure.Main, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=null'.

It would be great if anybody can let me know what's going on.

Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureCLR binary download issue

2012-12-15 Thread Shantanu Kumar


On Sunday, 16 December 2012 09:20:31 UTC+5:30, Shantanu Kumar wrote:
>
> On Sunday, 16 December 2012 06:01:54 UTC+5:30, dmiller wrote:
>
>>
>> [Off-topic] -- I noticed this when I wanted to confirm the binaries 
>>> because I was running into the following error:
>>>
>>> FATAL UNHANDLED EXCEPTION: System.MissingFieldException: Field 
>>> 'clojure.lang.RT.OutVar' not found.
>>>
>>> Shantanu
>>>
>>
>> Did this error occur from one of the downloaded binaries? Can you confirm 
>> which version?
>>
>
> This is the URL I downloaded ClojureCLR from, which still works even 
> though the Downloads tab is not visible on Github anymore:
>
>
> https://github.com/downloads/clojure/clojure-clr/clojure-clr-1.4.0-Debug-4.0.zip
>
> The error is happening on Linux running Mono 2.10 for me. There is no 
> error on Windows (both .NET and Mono.)
>

I posted a new thread about the errors here:

https://groups.google.com/forum/?fromgroups=#!topic/clojure/f8XFoiwkloQ

Shantanu

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: ClojureCLR errors on Mono Linux

2012-12-15 Thread Shantanu Kumar
This is when using ClojureCLR 1.4.0 Debug-4.0 version.

Shantanu

On Sunday, 16 December 2012 09:45:21 UTC+5:30, Shantanu Kumar wrote:
>
> Hi,
>
> I noticed the following ClojureCLR errors using Mono 2.10 on Ubuntu 12.04 
> (they do not happen on Windows using either .NET or Mono):
>
> 1. when running Clojure.Compile.exe:
>
> Exception: System.MissingFieldException: Field 'clojure.lang.RT.OutVar' 
> not found.
>
> 2. when using Clojure.Main.exe:
>
> Exception: System.TypeLoadException: Could not load type 'Clojure.CljMain' 
> from assembly 'Clojure.Main, Version=1.0.0.0, Culture=neutral, 
> PublicKeyToken=null'.
>
> It would be great if anybody can let me know what's going on.
>
> Shantanu
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Running a clojure script

2012-12-15 Thread Mark Engelberg
Hmmm, looks like googlegroups is stripping out my email address and
replacing it with one of my google account handles.  Probably depends on
what method you are using to view the group messages.  I'm not going out of
my way to be pseudonymous, it just seems to be a feature of the group.

On Sat, Dec 15, 2012 at 8:12 PM, Armando Blancas wrote:

> Why are you using puzzler's account and what did you did to him?!
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Belgian Clojure base meetup?

2012-12-15 Thread Thomas Goossens
If you are from Belgium, Don't get too excited - yet - .

I've been wondering about organising a small meetup somewhere next 
semester. (I peeked at our northern neighbours: 
http://www.meetup.com/The-Amsterdam-Clojure-Meetup-Group/events/88386392/)

Though, I have no idea at all how many people here in Belgium are actively 
using clojure and would be interested in such a thing.

Its not a plan, just being curious and checking whether it would be worth 
the time.

So if you are from Belgium, give me a shout!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en