Re: What is the status of Clojure on LLVM or C?

2013-03-30 Thread Marko Topolnik


On Friday, March 29, 2013 5:37:19 PM UTC+1, Herwig Hochleitner wrote:

 2013/3/29 Marko Topolnik marko.t...@gmail.com javascript:

 Yes, you are involving Clojure startup here, which turns the tables 
 altogether. This is far more work than just Java startup: all the 
 namespaces must be initialized: all their def'd values calculated at 
 runtime and assigned. Some of these may involve quite heavyweight service 
 startup. This is the real issue in the Clojure startup story: it is not 
 aggressively optimized towards zero startup time. It is a problem that 
 carries over to other underlying implementations.


 The opposite is also true and weighs more heavy in this case, I think. 
 Java is not optimized for good startup times. In particular, you can't 
 embed any composite constants in byte code. Not even arrays. That means 
 every last piece of metadata has to be allocated and built from scratch at 
 startup. Every class for every toplevel fn has to be loaded (a process that 
 involves deserialization aswell), initialized and instantiated.

 In a native code implementation of clojure, all the statically known 
 functions, data and metadata structures could be directly embedded into the 
 binary. Thus the init cost of a namespace with defn as the only toplevel 
 forms could be near zero.


An excellent point. Indeed, the semantics of the JVM are not specfiically 
geared towards quick startup. Do mind, however, that this is just 
specification we're talking about. An implementation may perform any 
optimization as long as it maintains the semantics. As an obvious example, 
take the startup of the JVM itself, which loads and initializes many 
hundreds of classes, and sets up a myriad of internal datastructures, 
within 100-200 ms. This kind of optimization is unfortunately not something 
client code can participate in, and that's where many problems start. 
Clojure would basically need its own custom JVM derivation which would 
provide an accessible way to fossilize a namespace and turn it into a 
binary blob that can be loaded in microsecoonds, resulting in a fully 
initialized image in memory.

At a certain point in this departure from the JVM comes a moment where it 
is saner to start from scratch and build your own runtime, but that means 
you undo some 15 years of experience in building and optimizing a runtime 
for heayweight production systems. Some lessons can be carried over, but a 
huge spectrum of fine detials will be left for you to reinvent.

As long as the JVM is alive and strong I doubt we shall ever see a native 
implementation that wouldn't cause frustration to its users, because it 
won't be the universally best choice. For many years to come nothing will 
be able to dethrone the JVM at the server side, where startup time means 
nothing and long-running stability is precious. So whatever runtime you 
choose, it will take you only that far before its specific limitations 
start giving you a headache.

But hey, that's life: no language has conquered all the bases. Otherwise C 
would by now be just a tale from the elders.

-marko

-- 
-- 
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: Clojure Style Guide

2013-03-30 Thread Colin Fleming
I agree - I thoroughly enjoyed this.


On 30 March 2013 08:45, Alan Thompson thompson2...@gmail.com wrote:

 Hey - Just saw a nice article on this in (def newsletter) .  It looks like
 quite a good reference on the subject.

 https://github.com/bbatsov/clojure-style-guidehttps://github.com/bbatsov/clojure-style-guide#mutation

 Alan Thompson

 --
 --
 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.




Problem with map (only when running on browser)

2013-03-30 Thread Nico
I have the following code:

(defn log-call [call]
  (.log js/console (pr-str call)))

(defn generate-report []
  ;; Get the data from the textarea calls_log
  (let [all-calls (.split (.-value (.getElementById js/document 
calls_log)) \n)
[calls-headers  calls-log] all-calls]
  
; Output all calls to the console log
;(.log js/console (pr-str calls-log 
(map log-call calls-log)))


That code works on the REPL connected to the browser, and the date is 
displayed on the console. However, the compiled code doesn't run on the 
browser. I've tried debugging it with Chrome, but I'm not getting any 
errors, and I don't really know what's going on when following it step by 
step.

If I comment the last line and uncomment the second to last, the code works 
on the browser. So basically if I don't do the map, it works. I am very 
confused.

I only started using ClojureScript today, and already had a bunch of 
problems (including not being able to get domina 1.0.2-SNAPSHOT to work, 
trying to follow the moder_cljs tutorial), so I would really appreciate 
some help with this. Thank you very much!


Nico

-- 
-- 
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] Pedestal Application Framework

2013-03-30 Thread Jeremiah Dodds
Cedric Greevey cgree...@gmail.com writes:

 It's a definite improvement ... but please print and sign the agreement, then
 scan and mail? There are a growing number of people that do *everything*
 online, to the point of not having a printer, not having a scanner, or not
 having either.

 Of course, the same people tend to have trouble with the quaint notion that a
 funny-looking squiggle emitted by pen onto paper is somehow a securer form of
 authentication than a 128-bit cryptographic signature of a document hash. :)

 -- 

Those people may be interested in sites like https://www.hellofax.com/
when faced with needing to print, sign, and scan some paper-trail :P

-- 
Jeremiah Dodds

blog   : http://jdodds.github.com
github : https://github.com/jdodds
freenode/skype : exhortatory
twitter: kaens

-- 
-- 
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: Apply elements in a vector as arguments to function

2013-03-30 Thread Marko Topolnik
ClojureDocs currently show just the original docstring followed by 
user-contributed examples. I think a lot of readers would benefit from 
somethig like this:

apply
(apply f args* argseq)
*Scripture:* Applies fn f to the argument list formed by prepending args to 
argseq.
*Interpretation: *The first argument (f) is a function and the last 
argument is a sequence (argseq). Calls f with elements of argseq as its 
arguments. If more arguments are specified (args*), they are added to the 
beginning of the argseq to form the complete argument list with which f is 
called.
*
*
*Examples:* (as usual)


-marko

On Wednesday, March 27, 2013 11:33:04 AM UTC+1, Marko Topolnik wrote:

 Now that Michael mentioned it, the docstring of *apply* says

 Applies fn f to the argument list formed by prepending intervening 
 arguments to args.


 I challenge any Clojure newbie to decipher this Hickeyism for me. This is 
 of course no exception; most of clojure.core is like that.

 I can personally testify to having learned (and *had to* learn) much more 
 from source code than from docstrings. M-. has always been my best 
 friend; C-d C-d came merely as a hint from Rich while solving the 
 compile me in your head puzzle.

 -marko

 On Wednesday, March 27, 2013 11:17:05 AM UTC+1, Ryan wrote:

 The idea that people should read the source to get reasonably 
 straightforward stuff done is wrong and does a lot of long term damage to 
 the community.


 I believe Jim meant to check the source to figure out how does it work, 
 not that the way it's implemented is the most proper way to implement it.
 If that's not what you wanted to point out can you please explain?

 On Wednesday, March 27, 2013 5:13:35 AM UTC+2, Michael Klishin wrote:


 2013/3/27 Jim - FooBar(); jimpi...@gmail.com

 aaa see? always check the docs first and the sources second (if 
 available)...I should have done that as well :)


 Definitely don't just check the sources and think it's something normal.

 Complain loudly to maintainers on this list that their documentation has 
 gaps and they should
 clarify this and that. The idea that people should read the source to 
 get reasonably straightforward
 stuff done is wrong and does a lot of long term damage to the community.
 -- 
 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: 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.




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 v...@vemv.net 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: 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))
#MultiFn clojure.lang.MultiFn@6194a872
= (defmethod foo :default
 [x]
 ((get-method foo :baz) x))
#MultiFn clojure.lang.MultiFn@6194a872
= (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: 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 ne...@isismanor.com 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.




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)
#Namespace 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: 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)
 #Namespace 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 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 
 ne...@isismanor.comjavascript: 
 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.comjavascript:
 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 javascript:
 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 javascript:.
 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 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 ne...@isismanor.com
javascript: 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
javascript:
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 javascript:
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
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 javascript:.
For more options, visit
https://groups.google.com/groups/opt_out
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: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Cedric Greevey
On Sat, Mar 30, 2013 at 9:06 AM, Gary Trakhman gary.trakh...@gmail.comwrote
:

 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 Cedric Greevey
On Sat, Mar 30, 2013 at 10:09 AM, Nico nbren...@gmail.com 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: 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 mjt...@gmail.com javascript:

 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: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Michael Klishin
2013/3/30 Gary Trakhman gary.trakh...@gmail.com

 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.




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: 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 dofflt...@gmail.com 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.




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 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.




Re: Quirk with printing regexps

2013-03-30 Thread Mark Engelberg
On Thu, Mar 28, 2013 at 7:52 PM, Mikhail Kryshen mikh...@kryshen.netwrote:

 On Thu, 28 Mar 2013 17:08:46 -0700
 Mark Engelberg mark.engelb...@gmail.com 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: ANN: no.disassemble, a runtime bytecode disassembler

2013-03-30 Thread Hugo Duncan
Gary Trakhman gary.trakh...@gmail.com 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 6:36 PM, Andy Fingerhut andy.finger...@gmail.comwrote:

 (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: 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.




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: 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
lawrencecloj...@gmail.com 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 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 
 lawrenc...@gmail.com javascript: 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: 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 kfjwhee...@gmail.com 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: 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))
 #MultiFn clojure.lang.MultiFn@6194a872
 = (*defmethod* foo :default
  [x]
  ((get-method foo :baz) x))
 #MultiFn clojure.lang.MultiFn@6194a872
 = (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
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))
 #MultiFn clojure.lang.MultiFn@6194a872
 = (*defmethod* foo :default
  [x]
  ((get-method foo :baz) x))
 #MultiFn clojure.lang.MultiFn@6194a872
 = (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: 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 areka...@gmail.com 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: 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.