Re: Sweet-expressions

2013-03-30 Thread JvJ
Once you write enough lisp, eliminating parens becomes more trouble than 
it's worth.

Also the guy who did this has the same name as my dad?  I'm ashamed.

On Monday, 25 March 2013 06:52:23 UTC-4, poetix wrote:
>
> I really like the look of this:
>
> http://readable.sourceforge.net/
>
> which defines a completely reversible transformation between e.g.
>
> define fibfast(n)
>   if {n < 2}
> n
> fibup(n 2 1 0)
>
> and
>
> (define (fibfast n)
>   (if (< n 2)
> n
> (fibup n 2 1 0)))
>
>
> and wonder how difficult it would be to support it (or something like it) 
> in/for Clojure. A coffeescript-like approach might be a good first step.
>
> Any thoughts?
>
> Dominic
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-30 Thread JvJ
Here's a cheezy hack, use identity.

#(identity {:foo %})

On Thursday, 28 March 2013 17:51:10 UTC-4, Ryan wrote:
>
> Thanks for your explanation Jonathan. I am still a bit confused however 
> what is the proper solution here. Should i use an anonymous function 
> instead to do what I want or can it be done with the #() syntax?
>
> Hyphens is my preferred way as well, but, those keys represent sql columns 
> which they use underscore so I gotta go with underscores in order code to 
> match them :)
>
> Ryan
>
> On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg 
> wrote:
>>
>> It's because the #() syntax always calls the content as a function.
>>
>> So #(...) is the same as (fn [] (...)). In your case, 
>> #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
>> is the same as:
>> (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
>> Note the extra () around {}. In other words, your map is called
>> as a function.
>>
>> Maps can normally be called as functions, like this:
>> ({:hello :world} :hello)
>> => :world
>> That's why you get the "Wrong number of args" error
>> (and not a "a map is not a function" error).
>> Hope that makes sense.
>>
>> Btw, hyphen is normally used instead of underscore
>> in both variables and keywords. Just a slight style
>> "issue", but maybe you had your reasons. :)
>>
>> Jonathan
>>
>>
>> On Thu, Mar 28, 2013 at 10:16 PM, Ryan  wrote:
>>
>>> Hello!
>>>
>>> I am having a small issue with a hash-map initialization and I am 
>>> failing to understand why. I have the following situation:
>>>
>>> (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))
>>>
>>>
>>> (defn my-function [foo-id a-keyword a-list] 
>>>
>>>   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))

>>>
>>> So, by running the above function like this:
>>>
>>> (my-function 5 "my_keyword" a-list) 
>>>
>>>
>>> I get the following error:
>>>
>>> *clojure.lang.ArityException: Wrong number of args (0) passed to: 
 PersistentArrayMap*
>>>
>>>  
>>> I am trying to get the following result:
>>>
>>> ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword 
>>> another-value})
>>>
>>> Any ideas? I have played around in repl for the last 2 hrs but I haven't 
>>> found the proper way to do this.
>>>
>>> Thank you for your time :)
>>>
>>>  -- 
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send 
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>>
>>
>>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Invoke a specific multimethod

2013-03-30 Thread JvJ
Also, nice syntax highlighting!  How'd you do that?

On Saturday, 30 March 2013 23:54:03 UTC-4, JvJ wrote:
>
> get-method.  Thanks, that was exactly what I was looking for!
>
> On Saturday, 30 March 2013 07:20:54 UTC-4, Chas Emerick wrote:
>>
>> On Mar 30, 2013, at 12:00 AM, George Oliver wrote:
>>
>>
>>
>> On Friday, March 29, 2013 6:19:19 PM UTC-7, JvJ wrote:
>>>
>>> Is it possible to invoke a particular multimethod and bypass the 
>>> dispatch function?
>>>
>>> For instance, suppose that I have a multimethod with a dispatch value of 
>>> ::foo, and it's a really complex method.
>>>
>>> Now, I want all cases where the dispatch function returns nil to use the 
>>> same multimethod.  Is there a way I can intercept the nil and
>>> pass it directly on to the ::foo multimethod?
>>>
>>
>> You could use the default multimethod to catch nil, and then call the 
>> multi with ::foo. 
>>
>>
>> That will only work if the dispatch fn is identity or similar.
>>
>> If you control the dispatch fn, then you don't need to "intercept nil" -- 
>> just returning ::foo from the dispatch fn when it might otherwise return 
>> nil will get you to the method you want.
>>
>> If you *don't* control the dispatch fn, but you're providing the methods 
>> for :foo and nil, then you can use `get-method` to obtain the method 
>> associated with a particular dispatch value:
>>
>> => (*defmulti* foo :bar)
>> #'user/foo
>> => (*defmethod* foo :baz
>>  [x]
>>  (str x))
>> #
>> => (*defmethod* foo :default
>>  [x]
>>  ((get-method foo :baz) x))
>> #
>> => (foo {:bar :baz})
>> "{:bar :baz}"
>> => (foo {:some :other :value :here})
>> "{:some :other, :value :here}"
>>
>> Of course, if the functionality you need is available as a separate 
>> top-level fn, and you can avoid the extra effective dispatch through the 
>> multimethod, all the better.
>>
>> Cheers,
>>
>> - Chas
>>
>>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Invoke a specific multimethod

2013-03-30 Thread JvJ
get-method.  Thanks, that was exactly what I was looking for!

On Saturday, 30 March 2013 07:20:54 UTC-4, Chas Emerick wrote:
>
> On Mar 30, 2013, at 12:00 AM, George Oliver wrote:
>
>
>
> On Friday, March 29, 2013 6:19:19 PM UTC-7, JvJ wrote:
>>
>> Is it possible to invoke a particular multimethod and bypass the dispatch 
>> function?
>>
>> For instance, suppose that I have a multimethod with a dispatch value of 
>> ::foo, and it's a really complex method.
>>
>> Now, I want all cases where the dispatch function returns nil to use the 
>> same multimethod.  Is there a way I can intercept the nil and
>> pass it directly on to the ::foo multimethod?
>>
>
> You could use the default multimethod to catch nil, and then call the 
> multi with ::foo. 
>
>
> That will only work if the dispatch fn is identity or similar.
>
> If you control the dispatch fn, then you don't need to "intercept nil" -- 
> just returning ::foo from the dispatch fn when it might otherwise return 
> nil will get you to the method you want.
>
> If you *don't* control the dispatch fn, but you're providing the methods 
> for :foo and nil, then you can use `get-method` to obtain the method 
> associated with a particular dispatch value:
>
> => (*defmulti* foo :bar)
> #'user/foo
> => (*defmethod* foo :baz
>  [x]
>  (str x))
> #
> => (*defmethod* foo :default
>  [x]
>  ((get-method foo :baz) x))
> #
> => (foo {:bar :baz})
> "{:bar :baz}"
> => (foo {:some :other :value :here})
> "{:some :other, :value :here}"
>
> Of course, if the functionality you need is available as a separate 
> top-level fn, and you can avoid the extra effective dispatch through the 
> multimethod, all the better.
>
> Cheers,
>
> - Chas
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Floating point comparator issue?

2013-03-30 Thread JvJ
That makes sense.  Thanks.

On Friday, 29 March 2013 22:21:21 UTC-4, Alan Malloy wrote:
>
> Comparator.compare returns an int. (int 0.2) and (int -0.2) both 
> return 0. Thus, your comparator is returning 0, saying "I don't care 
> what order these go in". 
>
> On Mar 29, 6:44 pm, JvJ  wrote: 
> > Alright check this out: 
> > 
> > ;; Normal subtraction as comparator sorts in ascending order 
> > (sort-by identity #(- %1 %2)   [1  -1]) 
> > (-1 1) 
> > 
> > ;; Reverse subtraction as comparator sorts in descending order 
> > (sort-by identity #(- %2 %1)   [1  -1]) 
> > (1 -1) 
> > 
> > ;;=== 
> > ;; And now with values of -0.1, 0.1 
> > 
> > ;; Reverse subtraction as comparator sorts in descending order 
> > (sort-by identity #(- %2 %1)   [0.1  -0.1]) 
> > (0.1 -0.1) 
> > 
> > ;; Normal subtraction STILL sorts in descending order?? 
> > (sort-by identity #(- %1 %2)   [0.1  -0.1]) 
> > (0.1 -0.1) 
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wrong number of args (0) passed to: PersistentArrayMap

2013-03-30 Thread larry google groups

It's so obvious when you point it out. 


On Saturday, March 30, 2013 10:02:30 PM UTC-4, Lars Nilsson wrote:
>
> On Sat, Mar 30, 2013 at 9:49 PM, larry google groups 
> > wrote: 
> > (def initial-data 
> >   :slides { 
> >  :who-is-going-to-summer-camp { :public-text "Who is 
> going to summer camp? 
> > 
>  :order-of-appearance 1 
> > 
>  :to-be-deleted true} 
> >  :what-is-your-budget { :public-text "What is your 
> budget? 
> >   :order-of-appearance 
> 2} 
> >  } 
> > 
> > :answers { 
> >:under-one-thousand-dollars { :public-text "Under 
> $1,000 dollars?" 
> >   :slides-id 
> :what-is-your-budget } 
> >:over-one-thousand-dollars { :public-text "Over 
> $1,000 dollars?" 
> >   :slides-id 
> :what-is-your-budget } 
> >} 
> > 
> >;; etc 
> > ) 
> > 
> > (defn delete-those-items-in-the-model-that-are-scheduled-to-be-deleted 
> [] 
> >   ;; 2013-02-28 - THIS FUNCTION IS CALLED AT STARTUP AND RUNS IN ITS OWN 
> THREAD, REPEATING ENDLESSLY. 
> >   (doseq [x (keys (@um/interactions))] 
> > (doseq [m (vals (um/get-from-model [x]))] 
> >   (if (:to-be-deleted m) 
> > (do 
> >   (um/delete-this-item m) 
> >   (monger/remove-this-item m) 
> >   (. java.lang.Thread sleep 90) 
> >   (delete-those-items-in-the-model-that-are-scheduled-to-be-deleted)) 
> > 
> > Assume um/get-from-model is almost the same as get-in. Assume 
> initial-data is stored in the atom um/interactions. Where am I calling a 
> map as a function here? 
>
> (@um/interactions) perhaps? 
>
> Lars Nilsson 
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wrong number of args (0) passed to: PersistentArrayMap

2013-03-30 Thread Lars Nilsson
On Sat, Mar 30, 2013 at 9:49 PM, larry google groups
 wrote:
> (def initial-data
>   :slides {
>  :who-is-going-to-summer-camp { :public-text "Who is going to 
> summer camp?
>  
> :order-of-appearance 1
>  
> :to-be-deleted true}
>  :what-is-your-budget { :public-text "What is your budget?
>   :order-of-appearance 2}
>  }
>
> :answers {
>:under-one-thousand-dollars { :public-text "Under $1,000 
> dollars?"
>   :slides-id 
> :what-is-your-budget }
>:over-one-thousand-dollars { :public-text "Over $1,000 
> dollars?"
>   :slides-id 
> :what-is-your-budget }
>}
>
>;; etc
> )
>
> (defn delete-those-items-in-the-model-that-are-scheduled-to-be-deleted []
>   ;; 2013-02-28 - THIS FUNCTION IS CALLED AT STARTUP AND RUNS IN ITS OWN 
> THREAD, REPEATING ENDLESSLY.
>   (doseq [x (keys (@um/interactions))]
> (doseq [m (vals (um/get-from-model [x]))]
>   (if (:to-be-deleted m)
> (do
>   (um/delete-this-item m)
>   (monger/remove-this-item m)
>   (. java.lang.Thread sleep 90)
>   (delete-those-items-in-the-model-that-are-scheduled-to-be-deleted))
>
> Assume um/get-from-model is almost the same as get-in. Assume initial-data is 
> stored in the atom um/interactions. Where am I calling a map as a function 
> here?

(@um/interactions) perhaps?

Lars Nilsson

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Wrong number of args (0) passed to: PersistentArrayMap

2013-03-30 Thread larry google groups
I understand that this error frequently appears when someone accidentally 
puts a map into the first position of a list, and so the map is called as a 
function: 

Exception in thread "Thread-13" clojure.lang.ArityException: Wrong number 
of args (0) passed to: PersistentArrayMap

But I am not sure why that is happening to me in the function below. Assume 
I have a data structure that looks like: 

(def initial-data 
  :slides {
 :who-is-going-to-summer-camp { :public-text "Who is going 
to summer camp? 

 :order-of-appearance 1

 :to-be-deleted true}
 :what-is-your-budget { :public-text "What is your budget? 
  :order-of-appearance 2}
 }

:answers {
   :under-one-thousand-dollars { :public-text "Under $1,000 
dollars?"
  
:slides-id :what-is-your-budget }
   :over-one-thousand-dollars { :public-text "Over $1,000 
dollars?"
  
:slides-id :what-is-your-budget }
   }

   ;; etc
)

(defn delete-those-items-in-the-model-that-are-scheduled-to-be-deleted []
  ;; 2013-02-28 - THIS FUNCTION IS CALLED AT STARTUP AND RUNS IN ITS OWN 
THREAD, REPEATING ENDLESSLY.
  (doseq [x (keys (@um/interactions))]
(doseq [m (vals (um/get-from-model [x]))]
  (if (:to-be-deleted m)
(do 
  (um/delete-this-item m)
  (monger/remove-this-item m)
  (. java.lang.Thread sleep 90)
  (delete-those-items-in-the-model-that-are-scheduled-to-be-deleted))

Assume um/get-from-model is almost the same as get-in. Assume initial-data 
is stored in the atom um/interactions. Where am I calling a map as a 
function here? 

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: Windows installer for Leiningen

2013-03-30 Thread Brent Millare
Nice work!

On Saturday, March 30, 2013 1:39:12 PM UTC-4, David Powell wrote:
>
> Hi,
>
> I've put together an installer for Leiningen on Windows:
> http://leiningen-win-installer.djpowell.net/
>
> Hopefully it should make it a bit easier for Windows people to get 
> Leiningen and a Clojure repl up and running.
>
> It requires a JDK to be installed first, but other than that there aren't 
> any dependencies.
> It should work on Windows XP and above, 32-bit or 64-bit.  With or without 
> powershell available.
>
> The installer should take the hassle out of setting up paths and 
> environment variables, and changing them when new JDKs are installed.
>
> The current version is beta1.  If you've got any feedback then give me an 
> email.
>
> -- 
> Dave
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Quirk with printing regexps

2013-03-30 Thread Mark Engelberg
On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut wrote:

> (defn print-regex-my-way [re]
>   (print "#regex ")
>   (pr (str re)))
>
> That might be closer to what you want.
>

Yes.  That does the trick.  That extra level of converting the regular
expression to a string does the trick because pr "does the right thing"
with strings, but not with regexes.  I'd classify pr's different behavior
on regexes as a bug, but this is an effective workaround.  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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Hugo Duncan
Gary Trakhman  writes:

> I made a little proof of concept last night.  You could always look at 
> bytecode that clojure emits in few ways, you can either hack the compiler 
> yourself, or force AOT in your project and use javap.  The first approach 
> is a bit intrusive, and the second has a somewhat annoying turnaround time, 
> and won't work for any code that calls eval at runtime.
>
> This takes another approach.  It uses java's Instrumentation stuff, to 
> provide a hook into all classloading past the point at which it's loaded, 
> where I store off all the bytes of defined classes into a big 
> ConcurrentHashMap.  Then I use eclipse.jdt.core's disassembler 
> functionality to print out the bytecode.

The Ritz' disassembler uses jpda to access the bytecode.  Not yet ported to
ritz-nrepl though.

Hugo

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Quirk with printing regexps

2013-03-30 Thread Mark Engelberg
On Thu, Mar 28, 2013 at 7:52 PM, Mikhail Kryshen wrote:

> On Thu, 28 Mar 2013 17:08:46 -0700
> Mark Engelberg  wrote:
>
> > Bug or feature?
>
> Certainly a feature for complex patterns with whitespace and embedded
> comments.
>
> For example, the following regexp parses line in Combined Log Format used
> by Apache httpd and other web servers:
>
> (def clf-pattern
>   #"(?x)^
> (\S*)\s  # remote host
> (\S*)\s  # remote logname
> (\S*)\s  # remote user
> \[([^\]]+)\]\s   # time the request was received
> \"([^\"\\]*(?:\\.[^\"\\]*)*)\"\s # first line of request
> (\S*)\s  # status
> (\S*)\s  # size of response in bytes
> \"([^\"\\]*(?:\\.[^\"\\]*)*)\"\s # referer
> \"([^\"\\]*(?:\\.[^\"\\]*)*)\"   # user-agent
> \s*$")
>
>
>
>

I appreciate this information.  It's useful to know this subtle difference
in how regular expressions store newlines depending on whether it was
entered as an actual newline character or an escape sequence designating a
newline character, and that this difference manifests when the regex is
prepended with (?x).

I see how this makes it easier to define a regexp using linebreaks for
clarity, and then signaling that those linebreaks are not intended to be
taken literally.

You probably would not want it to be printed in a single line.
>

Yes, but I would want it to pr in a single line.

This is one of the key differences between print and pr.  print is more
"human readable" and pr is a more machine-like view of the contents.  To
me, one of the main things that entails is that whitespace should be
printed in a way that you can see exactly what is going on and how it is
stored.

Compare
(pr "abc
def")
to
(print "abc
def")

then compare
(pr #"abc
def")
to
(print #"abc
def")

I think it is fairly clear that regular expressions *should* behave the
same way as strings here, and that pr should be printing whitespaces in a
visible, escaped way.  Based on everything you've told me, I'd still
classify the current behavior as a bug/oversight, not a feature.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting array length

2013-03-30 Thread Nicola Mometto

use the function alength

Alice writes:

> Why doesn't (.length (int-array 5)) work?
> Why should I use alength or count instead?
>
> --

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




ANN: Windows installer for Leiningen

2013-03-30 Thread David Powell
Hi,

I've put together an installer for Leiningen on Windows:
http://leiningen-win-installer.djpowell.net/

Hopefully it should make it a bit easier for Windows people to get
Leiningen and a Clojure repl up and running.

It requires a JDK to be installed first, but other than that there aren't
any dependencies.
It should work on Windows XP and above, 32-bit or 64-bit.  With or without
powershell available.

The installer should take the hassle out of setting up paths and
environment variables, and changing them when new JDKs are installed.

The current version is beta1.  If you've got any feedback then give me an
email.

-- 
Dave

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Getting array length

2013-03-30 Thread David Powell
It seems that .length isn't a real field at the JVM level - it is just part
of the Java - the language.  The JVM has a special arraylength op-code for
getting the length of arrays.

On Sat, Mar 30, 2013 at 5:17 PM, Alice  wrote:

> Why doesn't (.length (int-array 5)) work?
> Why should I use alength or count instead?
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Getting array length

2013-03-30 Thread Alice
Why doesn't (.length (int-array 5)) work?
Why should I use alength or count instead?

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Michael Klishin
2013/3/30 Gary Trakhman 

> Potential use cases:
>
> Writing fast code faster.
> Proving to newbies that clojure is not interpreted, further evidence of
> eval's coolness.
> Checking to make sure primitives are being used where you expect.
>

Great idea. This kind of information is very valuable when doing
optimization work and also helps understand
how the compiler works.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Names and clojure.core

2013-03-30 Thread John Gabriele
On Thursday, March 28, 2013 9:53:19 AM UTC-4, Michael Klishin wrote:
>
>
> 2013/3/28 Mark >
>
>> Do other people have this problem? Am I just too uncreative? Am I being 
>> too terse?
>
>
> Simply exclude some clojure.core functions in your namespace declaration 
> and use them as clojure.core/... 
> if you need them. It's perfectly fine to use names such as find,get and so 
> on in your own namespaces.
>
>
> http://clojure-doc.org/articles/language/namespaces.html#the_referclojure_helper_form
>
>
My only complaint about doing this is that it would cause me to do a 
double-take every time I saw the clojure.core name (ex. "Wait --- is that 
the clojure.core foo or the local foo? Lemme just glance around...").

I'd suspect that using slightly longer and hyphenated names would be easier 
to read and more descriptive, and it only require typing a few extra 
characters (`dna-seq`, `base-pairs`, etc.).

---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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with map (only when running on browser)

2013-03-30 Thread Cedric Greevey
On Sat, Mar 30, 2013 at 10:09 AM, Nico  wrote:

> BTW, it seems like knowing Clojure is a requirement to start using
> Clojurescript,
>

I think the general expectation has been that anyone using Clojurescript is
likely to be using both.

Maybe you should just learn Clojure? Between the many tutorial and
documentation resources posted, try-clojure, and the lightweight IDE clooj,
it shouldn't be too difficult.

P.S. Please fix your linewrap. The long lines make it inconvenient to read
this entire thread, at least in gmail's web interface.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Cedric Greevey
On Sat, Mar 30, 2013 at 9:06 AM, Gary Trakhman wrote
:
>
> Potential use cases:
>
> Writing fast code faster.
> Proving to newbies that clojure is not interpreted, further evidence of
> eval's coolness.
> Checking to make sure primitives are being used where you expect.
>

Scaring the bejesus out of Johnny 5.

:)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with map (only when running on browser)

2013-03-30 Thread Jim - FooBar();
Clojurescript is Clojure...you may be able to skip some JVM 
idiosyncrasies but it's the same language - no way around that!


Jim

On 30/03/13 14:09, Nico wrote:
Thank you very much sw1nn and John, both worked great. This goes to 
show how much of a newb I am.


Sorry if this is the wrong group (just realized it is the Clojure 
group and not Clojurescript one).


BTW, it seems like knowing Clojure is a requirement to start using 
Clojurescript, do you guys know of any turorials/resources to learn 
Clojurescript that don't rely on previous Clojure knowledge? (so far 
I've seen Clojurescript One and Modern. Clojurescript One is way too 
much for starters, too many things going on at once. Modern is better, 
but I couldn't get domina 1.0.2-SNAPSHOT to be automatically fetched 
from Clojars, hence I got stuck).



On Saturday, March 30, 2013 8:31:37 AM UTC-4, John Hume wrote:

When you want a side effect and don't care about return values,
it's idiomatic to use doseq.

(doseq [c calls-log] (log-call c))

On Mar 30, 2013 4:23 AM, "Neale Swinnerton" > wrote:

;(.log js/console (pr-str calls-log 
(map log-call calls-log)))

map is lazily evaluated, so if you never read it's result
nothing happens.

You can force evaluation with doall (and variants)

so...

  (doall (map log-call calls-log))

will behave as you expect.

-- 
-- 
You received this message because you are subscribed to the Google

Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from
it, send an email to clojure+u...@googlegroups.com .
For more options, visit
https://groups.google.com/groups/opt_out
.


--
--
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 unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with map (only when running on browser)

2013-03-30 Thread Nico
Thank you very much sw1nn and John, both worked great. This goes to show 
how much of a newb I am. 

Sorry if this is the wrong group (just realized it is the Clojure group and 
not Clojurescript one).

BTW, it seems like knowing Clojure is a requirement to start using 
Clojurescript, do you guys know of any turorials/resources to learn 
Clojurescript that don't rely on previous Clojure knowledge? (so far I've 
seen Clojurescript One and Modern. Clojurescript One is way too much for 
starters, too many things going on at once. Modern is better, but I 
couldn't get domina 1.0.2-SNAPSHOT to be automatically fetched from 
Clojars, hence I got stuck).


On Saturday, March 30, 2013 8:31:37 AM UTC-4, John Hume wrote:
>
> When you want a side effect and don't care about return values, it's 
> idiomatic to use doseq. 
>
> (doseq [c calls-log] (log-call c)) 
> On Mar 30, 2013 4:23 AM, "Neale Swinnerton" 
> > 
> wrote:
>
>> ;(.log js/console (pr-str calls-log 
>>> (map log-call calls-log)))
>>>
>>> map is lazily evaluated, so if you never read it's result nothing 
>> happens.
>>
>> You can force evaluation with doall (and variants)
>>
>> so...
>>
>>   (doall (map log-call calls-log)) 
>>
>> will behave as you expect.
>>  
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Gary Trakhman
https://github.com/gtrak/no.disassemble/

On Saturday, March 30, 2013 9:06:25 AM UTC-4, Gary Trakhman wrote:
>
> I made a little proof of concept last night.  You could always look at 
> bytecode that clojure emits in few ways, you can either hack the compiler 
> yourself, or force AOT in your project and use javap.  The first approach 
> is a bit intrusive, and the second has a somewhat annoying turnaround time, 
> and won't work for any code that calls eval at runtime.
>
> This takes another approach.  It uses java's Instrumentation stuff, to 
> provide a hook into all classloading past the point at which it's loaded, 
> where I store off all the bytes of defined classes into a big 
> ConcurrentHashMap.  Then I use eclipse.jdt.core's disassembler 
> functionality to print out the bytecode.
>
> There's a nice lein-plugin that adds the dependency to your project and 
> looks itself up in order to add the appropriate -javaagent flag to your jvm 
> startup options.
>
> Now you can do something like this:
>
> user=> (require 'no.disassemble)
> nil
>
> user=> (in-ns 'no.disassemble)
> #
>
> no.disassemble=> (println (disassemble (fn [])))
> // Compiled from NO_SOURCE_FILE (version 1.5 : 49.0, super bit)
> public final class no.disassemble$eval1174$fn__1175 extends 
> clojure.lang.AFunction {
>
>   // Method descriptor #7 ()V
>   // Stack: 0, Locals: 0
>   public static {};
> 0  return
>   Line numbers:
> [pc: 0, line: 1]
>
>   // Method descriptor #7 ()V
>   // Stack: 1, Locals: 1
>   public disassemble$eval1174$fn__1175();
> 0  aload_0
> 1  invokespecial clojure.lang.AFunction() [10]
> 4  return
>   Line numbers:
> [pc: 0, line: 1]
>
>   // Method descriptor #12 ()Ljava/lang/Object;
>   // Stack: 1, Locals: 1
>   public java.lang.Object invoke();
> 0  aconst_null
> 1  areturn
>   Line numbers:
> [pc: 0, line: 1]
>   Local variable table:
> [pc: 0, pc: 1] local: this index: 0 type: java.lang.Object
>
> }
> nil
> no.disassemble=> 
>
>
> Potential use cases:
>
> Writing fast code faster.
> Proving to newbies that clojure is not interpreted, further evidence of 
> eval's coolness.
> Checking to make sure primitives are being used where you expect.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Gary Trakhman
I made a little proof of concept last night.  You could always look at 
bytecode that clojure emits in few ways, you can either hack the compiler 
yourself, or force AOT in your project and use javap.  The first approach 
is a bit intrusive, and the second has a somewhat annoying turnaround time, 
and won't work for any code that calls eval at runtime.

This takes another approach.  It uses java's Instrumentation stuff, to 
provide a hook into all classloading past the point at which it's loaded, 
where I store off all the bytes of defined classes into a big 
ConcurrentHashMap.  Then I use eclipse.jdt.core's disassembler 
functionality to print out the bytecode.

There's a nice lein-plugin that adds the dependency to your project and 
looks itself up in order to add the appropriate -javaagent flag to your jvm 
startup options.

Now you can do something like this:

user=> (require 'no.disassemble)
nil

user=> (in-ns 'no.disassemble)
#

no.disassemble=> (println (disassemble (fn [])))
// Compiled from NO_SOURCE_FILE (version 1.5 : 49.0, super bit)
public final class no.disassemble$eval1174$fn__1175 extends 
clojure.lang.AFunction {

  // Method descriptor #7 ()V
  // Stack: 0, Locals: 0
  public static {};
0  return
  Line numbers:
[pc: 0, line: 1]

  // Method descriptor #7 ()V
  // Stack: 1, Locals: 1
  public disassemble$eval1174$fn__1175();
0  aload_0
1  invokespecial clojure.lang.AFunction() [10]
4  return
  Line numbers:
[pc: 0, line: 1]

  // Method descriptor #12 ()Ljava/lang/Object;
  // Stack: 1, Locals: 1
  public java.lang.Object invoke();
0  aconst_null
1  areturn
  Line numbers:
[pc: 0, line: 1]
  Local variable table:
[pc: 0, pc: 1] local: this index: 0 type: java.lang.Object

}
nil
no.disassemble=> 


Potential use cases:

Writing fast code faster.
Proving to newbies that clojure is not interpreted, further evidence of 
eval's coolness.
Checking to make sure primitives are being used where you expect.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with map (only when running on browser)

2013-03-30 Thread John D. Hume
When you want a side effect and don't care about return values, it's
idiomatic to use doseq.

(doseq [c calls-log] (log-call c))
On Mar 30, 2013 4:23 AM, "Neale Swinnerton"  wrote:

> ;(.log js/console (pr-str calls-log 
>> (map log-call calls-log)))
>>
>> map is lazily evaluated, so if you never read it's result nothing happens.
>
> You can force evaluation with doall (and variants)
>
> so...
>
>   (doall (map log-call calls-log))
>
> will behave as you expect.
>
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Invoke a specific multimethod

2013-03-30 Thread Chas Emerick
On Mar 30, 2013, at 12:00 AM, George Oliver wrote:

> 
> 
> On Friday, March 29, 2013 6:19:19 PM UTC-7, JvJ wrote:
> Is it possible to invoke a particular multimethod and bypass the dispatch 
> function?
> 
> For instance, suppose that I have a multimethod with a dispatch value of 
> ::foo, and it's a really complex method.
> 
> Now, I want all cases where the dispatch function returns nil to use the same 
> multimethod.  Is there a way I can intercept the nil and
> pass it directly on to the ::foo multimethod?
> 
> You could use the default multimethod to catch nil, and then call the multi 
> with ::foo. 

That will only work if the dispatch fn is identity or similar.

If you control the dispatch fn, then you don't need to "intercept nil" -- just 
returning ::foo from the dispatch fn when it might otherwise return nil will 
get you to the method you want.

If you *don't* control the dispatch fn, but you're providing the methods for 
:foo and nil, then you can use `get-method` to obtain the method associated 
with a particular dispatch value:

=> (defmulti foo :bar)
#'user/foo
=> (defmethod foo :baz
 [x]
 (str x))
#
=> (defmethod foo :default
 [x]
 ((get-method foo :baz) x))
#
=> (foo {:bar :baz})
"{:bar :baz}"
=> (foo {:some :other :value :here})
"{:some :other, :value :here}"

Of course, if the functionality you need is available as a separate top-level 
fn, and you can avoid the extra effective dispatch through the multimethod, all 
the better.

Cheers,

- Chas

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: would FixedThreadPool-backed reducers make sense?

2013-03-30 Thread Gary Verhaegen
The implementation of Clojure sequence library predates protocols.
This is, however, the way forward, at least in clojurescript :

https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L191

On 28 March 2013 14:49, vemv  wrote:
> I recall from Rich's presentation on reducers (and it's intuitively true
> anyway) that FJ is not well suited to all workloads: uniform ones would do
> just fine with a fixed allocation of tasks to threads. I believe the
> tradeoff in that case is that one has to manage parallelism very explicitly.
>
> Now, is it feasible to provide a reducers implementation backed by a fixed
> thead pool? How well would it perform (provided the workload is suitable)?
>
> Similarly, I'd find tempting (just if a little crazy) to define clj's "seq
> library" (map, filter, reduce...) as a huge protocol, providing e.g.
> simple-lazy, chunked, FJ, and fixed-thread-pool implementations.
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with map (only when running on browser)

2013-03-30 Thread Neale Swinnerton
>
> ;(.log js/console (pr-str calls-log 
> (map log-call calls-log)))
>
> map is lazily evaluated, so if you never read it's result nothing happens.

You can force evaluation with doall (and variants)

so...

  (doall (map log-call calls-log))

will behave as you expect.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.