Re: How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-04 Thread Alan Thompson
If you haven't seen it before, you can use the excellent Claypoole library for many parallel scheduling tasks. Alan On Wed, Jan 2, 2019 at 1:07 PM wrote: > I guess this is more of a JVM question than a Clojure question, unless > Clojure exerts

Re: How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-02 Thread Orestis Markou
If you call future, you will be using the future threadpool which is unbounded. If you know there’s always going to be a small amount of tasks in-flight, you can safely just use future to parallelize your work, and the scheduled executor to trigger trigger the work periodically. Have a look at

Re: How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-02 Thread Matching Socks
You are right, this is not a Clojure question. I suppose your scheduled task could put a bunch of tasks on a queue and a thread-pool executor could work the queue in multiple threads. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-02 Thread Justin Smith
A ScheduledThreadPool doesn't parallelize or partition your work, it schedules tasks and keeps a pool of Thread objects it can reuse for that purpose. If you need a job to be broken into smaller pieces, executed on a schedule, you'll need to implement some sort of coordination. There's some prior a

How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-02 Thread lawrence . krubner
I guess this is more of a JVM question than a Clojure question, unless Clojure exerts any special magic here. I'm open to a more Clojure approach than what I have now. Someone suggested I use Executors/newScheduledThreadPool for some recurring work, so I set it up like this: (def scheduler-a

Re: How does clojure.core quote function work for keyword?

2016-07-26 Thread Steve Miner
It’s working as expected. The :: notation is expanded by the reader, before evaluation. As keywords are basically constants (like numbers or strings), you rarely see them quoted. > On Jul 26, 2016, at 8:52 AM, Mamun wrote: > > Hi > > How does clojure.core quote function w

How does clojure.core quote function work for keyword?

2016-07-26 Thread Mamun
Hi How does clojure.core quote function work for keyword? If it is namespace keyword then it is displaying with namespace. Is it excepted result? (println (quote a)) => a (println (quote :a) ) => :a (println (quote ::a) ) => :user/a ;; I am expecting it shoul

Re: How does one print the stacktrace from slingshot?

2015-10-09 Thread Lawrence Krubner
Thank you. On Friday, October 9, 2015 at 6:16:23 AM UTC-4, Marc O'Morain wrote: > > If you pass (:throwable &throw-context) as an arg before the string it > will print the stack trace: > > (timbre/log :trace (:throwable &throw-context) "the true stack trace: ") > > > > > On Fri, Oct 9, 2015 a

Re: How does one print the stacktrace from slingshot?

2015-10-09 Thread Marc O'Morain
If you pass (:throwable &throw-context) as an arg before the string it will print the stack trace: (timbre/log :trace (:throwable &throw-context)  "the true stack trace: ") On Fri, Oct 9, 2015 at 11:00 AM, Lawrence Krubner wrote: > I'm trying to use Slingshot. I would like to print the stac

Re: How does one print the stacktrace from slingshot?

2015-10-09 Thread Lawrence Krubner
Ah, not enough sleep. I was catching it a lower level and re throwing it in a form that tripped me up. Got rid of low level catch and did: (timbre/log :trace " the true stack trace: " (stack/parse-exception (:throwable &throw-context))) using clj-stacktrace and all is good. On Frid

How does one print the stacktrace from slingshot?

2015-10-09 Thread Lawrence Krubner
I'm trying to use Slingshot. I would like to print the stacktrace. If I do: (timbre/log :trace " the stack trace via slingshot-support " (slingshot-support/stack-trace)) I get: the stack trace via slingshot-support [Ljava.lang.StackTraceElement;@72ee66cd How do I get what is in

Re: how does source work?

2014-02-04 Thread t x
Issue resolved. Thanks! On Tue, Feb 4, 2014 at 1:09 PM, Michał Marczyk wrote: > source-fn is a private Var in the clojure.repl namespace; you can > still use source to display its definition, but you'll have to use the > fully qualified name: > > user=> (source clojure.repl/source-fn) > (defn sou

Re: how does source work?

2014-02-04 Thread Michał Marczyk
source-fn is a private Var in the clojure.repl namespace; you can still use source to display its definition, but you'll have to use the fully qualified name: user=> (source clojure.repl/source-fn) (defn source-fn "Returns a string of the source code for the given symbol, if it can find it. T

how does source work?

2014-02-04 Thread t x
Hi, user> (source source) (defmacro source "Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source filter)" [n] `(println (or (source-fn '~n) (str "S

Re: How does "

2013-09-14 Thread Alan Shaw
(>! ch (:value t)) >( (go > > ( > (close! ch > > I am confused what this line does: > > ( > It looks like we are pulling a value off channel that's returned from that > call to walker? But why? W

Re: How does "

2013-09-14 Thread Alan Shaw
The go block itself (and thus any call to walker) returns a channel. This value is indeed thrown away; its utility lies entirely in the fact that the caller had to wait for it. All of the actual values from the tree are written to the supplied channel 'ch', and the ultimate caller of this function

Re: How does "

2013-09-13 Thread Cedric Greevey
( > It looks like we are pulling a value off channel that's returned from that > call to walker? But why? We seem to be throwing this value away? I don't see > it being stored anywhere. > > How does this give us synchronization? > > -- > -- > You r

How does "

2013-09-13 Thread larry google groups
I am stupid and recursion is clearly beyond my intellect. Martin Trojer has a great blog post here which I learned a lot from but I don't understand why the final example works: http://martintrojer.github.io/clojure/2013/07/17/non-tailrecursive-functions-in-coreasync/ He offers this as an exam

Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
I ended up using (list ~@attrs) which is very similar to what you're suggesting...:) JIm On 05/09/13 20:22, Dave Ray wrote: ~(vec attrs), perhaps? On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); > wrote: HI all, I've gotten myself into a weird situati

Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Dave Ray
~(vec attrs), perhaps? On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); wrote: > HI all, > > I've gotten myself into a weird situation... > > I'm defining a def-like macro and I want to use 'name-with-attributes'. > Consider the following skeleton: > > > (defmacro defX [name & args] > (let [[na

how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Jim - FooBar();
HI all, I've gotten myself into a weird situation... I'm defining a def-like macro and I want to use 'name-with-attributes'. Consider the following skeleton: (defmacro defX [name & args] (let [[name attrs] (name-with-attributes name args)] `(let [cs-coll# ~attrs] (assert (every? componen

Re: how does one embed nrepl in his own application?

2013-03-06 Thread Chas Emerick
On Mar 6, 2013, at 3:04 PM, Jim - FooBar(); wrote: > On 06/03/13 19:30, Sean Corfield wrote: >> What's your use case that you'd have folks connecting into the nrepl >> server without a regular nrepl client? > > I was just curious about minimal ways of connecting remotely...installing > lein migh

Re: how does one embed nrepl in his own application?

2013-03-06 Thread Jim - FooBar();
On 06/03/13 19:30, Sean Corfield wrote: What's your use case that you'd have folks connecting into the nrepl server without a regular nrepl client? I was just curious about minimal ways of connecting remotely...installing lein might not always be an option. Jim -- -- You received this messa

Re: how does one embed nrepl in his own application?

2013-03-06 Thread Sean Corfield
Ah, I didn't even know about tty support! I just take the path of least resistance and use an nrepl client (nrepl.el in Emacs or lein repl at the command line)... What's your use case that you'd have folks connecting into the nrepl server without a regular nrepl client? On Wed, Mar 6, 2013 at 1:3

Re: how does one embed nrepl in his own application?

2013-03-06 Thread Jim - FooBar();
On 05/03/13 23:05, Sean Corfield wrote: nrepl uses a specific protocol so you can't use telnet. You'll need an nrepl client of some sort. Leiningen is the easiest one but I believe there are nrepl clients in other languages than Clojure? thanks Sean, I found out that nrepl comes with a tty tran

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Sean Corfield
nrepl uses a specific protocol so you can't use telnet. You'll need an nrepl client of some sort. Leiningen is the easiest one but I believe there are nrepl clients in other languages than Clojure? On Tue, Mar 5, 2013 at 8:37 AM, Jim - FooBar(); wrote: > On 05/03/13 15:22, Weber, Martin S wrote:

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
On 05/03/13 15:22, Weber, Martin S wrote: $ lein run -m replbuiltin.core & $ lein repl :connect 42042 user=> (in-ns 'replbuiltin.core) replbuiltin.core=> (foo 42) 42 trying to use 'telnet localhost' instead of 'lein repl :connect' cos I may not have lein access, and it doesn't work! I don't g

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
haps someone ha already done that or something...I know leiningen uses it (DUH!) but I'd like to start with something small if possible... alternatively, how does one use rlwrap with the socket-based repl from contrib? It seems like a reasonable repl-server but the fact that you can't u

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Chas Emerick
.I know leiningen uses it (DUH!) but I'd like to start with > something small if possible... > > > alternatively, how does one use rlwrap with the socket-based repl from > contrib? It seems like a reasonable repl-server but the fact that you can't > use backsp

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
wow! that is 10 times easier than I expected...I guess I'll have to ditch the socket-based approach... thanks Martin :) Jim On 05/03/13 15:22, Weber, Martin S wrote: $ lein new replbuiltin && cd replbuiltin $ sed -Ee 's,.0",.0"][org.clojure/tools.nrepl "0.2.2",' < project.clj > p && mv -f p p

Re: how does one embed nrepl in his own application?

2013-03-05 Thread Weber, Martin S
$ lein new replbuiltin && cd replbuiltin $ sed -Ee 's,.0",.0"][org.clojure/tools.nrepl "0.2.2",' < project.clj > p && mv -f p project.clj $ lein deps $ cat < src/replbuiltin/core.clj (ns replbuiltin.core (:use [clojure.tools.nrepl.server :only [start-server stop-server]])) (defn foo [x] x) (def

how does one embed nrepl in his own application?

2013-03-05 Thread Jim - FooBar();
done that or something...I know leiningen uses it (DUH!) but I'd like to start with something small if possible... alternatively, how does one use rlwrap with the socket-based repl from contrib? It seems like a reasonable repl-server but the fact that you can't use backspace, arrow

Re: How does clj-http work regarding https?

2013-02-23 Thread Chris Jeris
ing a CA certificate that authenticates the SSL certificate Omniture is presenting. Check your javax.net.ssl.trustStore property. peace, C On Sat, Feb 23, 2013 at 8:54 PM, Jonah Benton wrote: > If you cut Charles out of the picture and just send your payload directly > to Omniture over https, how

Re: How does clj-http work regarding https?

2013-02-23 Thread Jonah Benton
If you cut Charles out of the picture and just send your payload directly to Omniture over https, how does Omniture respond? On Sat, Feb 23, 2013 at 6:52 PM, larry google groups < lawrencecloj...@gmail.com> wrote: > > > > Described in a little more detail

Re: How does clj-http work regarding https?

2013-02-23 Thread Jonah Benton
ert is false? > > > > > > Charles has consistently said, in each report, "SSL Proxying not > > > > enabled for this host: enable in Proxy Settings, SSL locations" > > > > > > And I've made the change you suggested, but I still see that messa

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
> And I've made the change you suggested, but I still see that message. > > > > On Feb 23, 5:24 pm, Jonah Benton wrote: > > > > Try adding > > > > > :insecure? true > > > > > to the map. Charles dynamically generates a cert pretending

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
t; > > :insecure? true > > > > to the map. Charles dynamically generates a cert pretending to be the > > > target host when acting as an ssl proxy, and clj-http probably has to be > > > told to accept it. > > > > On Sat, Feb 23, 2013 at 4:18 PM, larry

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
stently said, in each report, "SSL Proxying not > > > enabled for this host: enable in Proxy Settings, SSL locations" > > > > And I've made the change you suggested, but I still see that message. > > > > On Feb 23, 5:24 pm, Jonah Benton wrote: >

Re: How does clj-http work regarding https?

2013-02-23 Thread Jonah Benton
ions" > > > > And I've made the change you suggested, but I still see that message. > > > > On Feb 23, 5:24 pm, Jonah Benton wrote: > > > > > > > > > > > > > > > > > Try adding > > > > > :insecure? t

Re: How does clj-http work regarding https?

2013-02-23 Thread Jonah Benton
e the > > target host when acting as an ssl proxy, and clj-http probably has to be > > told to accept it. > > > > On Sat, Feb 23, 2013 at 4:18 PM, larry google groups < > > > > > > > > > > > > > > > > lawrencecloj...@gmail.

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
t; > > > Try adding > > > :insecure? true > > > to the map. Charles dynamically generates a cert pretending to be the > > target host when acting as an ssl proxy, and clj-http probably has to be > > told to accept it. > > > On Sat, Feb 23, 2013 at 4

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
t, Feb 23, 2013 at 4:18 PM, larry google groups < > > > > > > > > lawrencecloj...@gmail.com> wrote: > > > This might be a dumb "How does the Internet work" kind of question. > > > I have been asked to pull data from Omniture, using the Omnitu

Re: How does clj-http work regarding https?

2013-02-23 Thread Jonah Benton
t; > This might be a dumb "How does the Internet work" kind of question. > > I have been asked to pull data from Omniture, using the Omniture API. > I thought this would take me an hour, but I've been working on this > for 3 days now. I keep getting authentication errors.

Re: How does clj-http work regarding https?

2013-02-23 Thread larry google groups
) {:trace-redirects  ["https://api2.omniture.com/admin/1.3/rest/? method=Report.QueueOvertime"],  :request-time 1064,  :status 401,  :headers  {"date" "Sat, 23 Feb 2013 21:40:15 GMT",   "server" "Omniture AWS/2.0.0",   "www-authent

How does clj-http work regarding https?

2013-02-23 Thread larry google groups
This might be a dumb "How does the Internet work" kind of question. I have been asked to pull data from Omniture, using the Omniture API. I thought this would take me an hour, but I've been working on this for 3 days now. I keep getting authentication errors. I became curious abo

How does Clojure change the "shape" of your application

2012-07-17 Thread Colin Yates
This is for all those polyglot users - how do you find Clojure has changed the shape of your application? By shape I mean the code artifacts. For example, I find in Java I tend to have many packages (in some dead-end attempt at hinting at modular encapsulation) and many little classes and int

How does one make BigDecimals contagious over doubles, instead of the other way around, in a particular computation?

2012-06-25 Thread Cedric Greevey
How does one make BigDecimals contagious over doubles, instead of the other way around, in a particular computation? I can see the reasoning for making doubles preferred by default: once an operation combines a double with a BigDecimal, the additional BigDecimal precision is consumed by the

Re: How does this code works.

2012-04-15 Thread Zach Allaun
I'm new to clojure as well, so someone please correct me if the following explanation is wrong, but I'll give it a shot :). The JVM does not natively support TCO; clojure uses the recur form to accomplish what is effectively the same thing despite that shortcoming of its host. The recur form wo

Re: How does this code works.

2012-04-15 Thread Roberto Mannai
if (n == 0) return the "factorial", else go to the "loop label" and recur with the two parameters (n--) and (factorial * n). Go on until n-- reaches 0. In a Java-like translation we could have: int n = number; factorial = 1; while(n > 0){ factorial *= n--; } return factorial; On Sun, Apr

How does this code works.

2012-04-15 Thread Anto
I'm very new to Clojure. And I was pretty much interested to learn about vectors, list . maps in clojure. I have a code like this : (defn factorial-1 [number] "computes the factorial of a positive integer in a way that doesn't consume stack space" (loop [n number factorial 1] (if (zero

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 8:52 PM, Phil Hagelberg wrote: > On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: >> It looks like each top-level form currently gets its own fresh >> DynamicClassLoader. >> >> [...] >> >> (do (def a #()) (def b #())) > > If you'll pardon a nit-pick, this example is somewha

Re: How does clojure class reloading work?

2011-09-22 Thread Alan Malloy
On Sep 22, 5:52 pm, Phil Hagelberg wrote: > On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: > > It looks like each top-level form currently gets its own fresh > > DynamicClassLoader. > > > [...] > > > (do (def a #()) (def b #())) > > If you'll pardon a nit-pick, this example is somewhat misleadin

Re: How does clojure class reloading work?

2011-09-22 Thread Phil Hagelberg
On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: > It looks like each top-level form currently gets its own fresh > DynamicClassLoader. > > [...] > > (do (def a #()) (def b #())) If you'll pardon a nit-pick, this example is somewhat misleading since do forms are special-cased by the compiler so th

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
Wow, using what you just explained, I am now able to reload .class files. (defn reload-class [classname] (.defineClass (clojure.lang.DynamicClassLoader.) classname (to-byte-array (io/file "/home/user/dj/usr/src/scratch/src/scratch/ hello.class"))

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 2:56 PM, Kevin Downey wrote: > most likely the compiler is creating a new DynamicClassLoader, it uses > a var clojure.lang.Compiler/LOADER and pushes and pops class loaders > from there. You nailed it. It looks like each top-level form currently gets its own fresh Dynamic

Re: How does clojure class reloading work?

2011-09-22 Thread Kevin Downey
dunno. > > This would imply that the new classloader, would have to re-"find" the > classes the old classloader found from before. How does the pushing/ > popping mechanism work so that it only applies to the deftypes? > > Best, > Brent > > > On Sep 22, 2:56 

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
they stop getting pointed to. So two main points to confirm with you: -A new Dynamic Classloader is created during each deftyp call -the old classloader is lost This would imply that the new classloader, would have to re-"find" the classes the old classloader found from before. How does t

Re: How does clojure class reloading work?

2011-09-22 Thread Kevin Downey
copied my question from stackoverflow to get more looks in >> case there are people in here that are not on >> stack.http://stackoverflow.com/questions/7471316/how-does-clojure-class-rel... >> I will sync the good answers) >> >> I've been reading code and documenta

Re: How does clojure class reloading work?

2011-09-22 Thread Brent Millare
t; (Note: I've copied my question from stackoverflow to get more looks in > case there are people in here that are not on > stack.http://stackoverflow.com/questions/7471316/how-does-clojure-class-rel... > I will sync the good answers) > > I've been reading code and docum

How does clojure class reloading work?

2011-09-19 Thread Brent Millare
(Note: I've copied my question from stackoverflow to get more looks in case there are people in here that are not on stack. http://stackoverflow.com/questions/7471316/how-does-clojure-class-reloading-work I will sync the good answers) I've been reading code and documentation to try to

Re: How does pmap partition its work?

2011-01-28 Thread Stuart Sierra
David Liebke gave a talk at Clojure-Conj 2010 titled "From Concurrency to Parallelism" with detailed performance comparisons of map, pmap, and Fork/Join-style iteration. Look for it on clojure.blip.tv in the near future! -Stuart Sierra clojure.com -- You received this message because you are

Re: How does pmap partition its work?

2011-01-27 Thread Ken Wesson
On Thu, Jan 27, 2011 at 5:05 PM, Rasmus Svensson wrote: > 2011/1/27 Ken Wesson : >> On Thu, Jan 27, 2011 at 2:09 PM, Michael Gardner wrote: >>> On Jan 27, 2011, at 7:24 AM, Rasmus Svensson wrote: >>> If you simply want all tasks to be performed as quickly as possible, one alternative co

Re: How does pmap partition its work?

2011-01-27 Thread Rasmus Svensson
2011/1/27 Ken Wesson : > On Thu, Jan 27, 2011 at 2:09 PM, Michael Gardner wrote: >> On Jan 27, 2011, at 7:24 AM, Rasmus Svensson wrote: >> >>> If you simply want all tasks to be performed as quickly as possible, >>> one alternative could be to use an ExecutorService (perhaps one >>> created with n

Re: How does pmap partition its work?

2011-01-27 Thread Ken Wesson
On Thu, Jan 27, 2011 at 2:09 PM, Michael Gardner wrote: > On Jan 27, 2011, at 7:24 AM, Rasmus Svensson wrote: > >> If you simply want all tasks to be performed as quickly as possible, >> one alternative could be to use an ExecutorService (perhaps one >> created with newFixedThreadPool) with its in

Re: How does pmap partition its work?

2011-01-27 Thread Michael Gardner
On Jan 27, 2011, at 7:24 AM, Rasmus Svensson wrote: > If you simply want all tasks to be performed as quickly as possible, > one alternative could be to use an ExecutorService (perhaps one > created with newFixedThreadPool) with its invokeAll method. invokeAll > takes a collection of callables (in

Re: How does pmap partition its work?

2011-01-27 Thread Rasmus Svensson
2011/1/24 Michael Gardner : > Suppose I have a sequence of tasks I'd like to parallelize using pmap. The > amount of CPU time these tasks require varies greatly; in particular, many of > them will require virtually no work. Can I rely on pmap to divide the work > efficiently even if there is som

Re: How does pmap partition its work?

2011-01-25 Thread Michael Gardner
On Jan 25, 2011, at 12:13 PM, Andy Fingerhut wrote: > In my original message describing pmap's behavior, there was a little > "gotcha" near the end: > > "Note: Sometimes working at odds with pmap's "Don't work too far ahead" > approach is if the input sequence to pmap is chunked. When a chunk

Re: How does pmap partition its work?

2011-01-25 Thread Andy Fingerhut
In my original message describing pmap's behavior, there was a little "gotcha" near the end: "Note: Sometimes working at odds with pmap's "Don't work too far ahead" approach is if the input sequence to pmap is chunked. When a chunk is reached, all elements in that chunk have threads start

Re: How does pmap partition its work?

2011-01-25 Thread Michael Gardner
On Jan 25, 2011, at 9:33 AM, Ken Wesson wrote: > Well, that's weird, because the documentation *I* read says it > composits the arguments together into a command line and hands off to > Runtime/exec. And the documentation of *that* says it returns a > Process object and the process it launches run

Re: How does pmap partition its work?

2011-01-25 Thread Ken Wesson
On Tue, Jan 25, 2011 at 10:21 AM, Michael Gardner wrote: > On Jan 25, 2011, at 9:06 AM, Ken Wesson wrote: > >> sh is asynchronous. It calls Runtime/exec, which launches the sleep as >> a separate process and immediately returns a Process object (which >> your pmap should be returning a seq of). It

Re: How does pmap partition its work?

2011-01-25 Thread Michael Gardner
On Jan 25, 2011, at 9:06 AM, Ken Wesson wrote: > sh is asynchronous. It calls Runtime/exec, which launches the sleep as > a separate process and immediately returns a Process object (which > your pmap should be returning a seq of). It may produce n+2 Process > objects at a time but it produces the

Re: How does pmap partition its work?

2011-01-25 Thread Ken Wesson
On Tue, Jan 25, 2011 at 9:45 AM, Michael Gardner wrote: > I have run across something else I don't understand about pmap. Why does the > following: > > (pmap (fn [_] (clojure.java.shell/sh "sleep" "10")) (range 32)) > > result in all 32 "sleep" processes being run at once? I thought pmap used n+2

Re: How does pmap partition its work?

2011-01-25 Thread Michael Gardner
I have run across something else I don't understand about pmap. Why does the following: (pmap (fn [_] (clojure.java.shell/sh "sleep" "10")) (range 32)) result in all 32 "sleep" processes being run at once? I thought pmap used n+2 threads, where n is the number of processors/cores available (I h

Re: How does pmap partition its work?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 11:05 AM, Armando Blancas wrote: >> This is much faster than either of the other eager-pmaps I posted to >> this thread, and yet it's only using 60% CPU on my dual-core box. That >> means there's still another x1.6 or so speedup possible(!) but I'm not >> sure how. >> > > C

Re: How does pmap partition its work?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 10:29 AM, Michael Gardner wrote: > Thanks for the work, Ken. You're welcome. > Clojure's multi-threaded performance can be mysterious indeed I think that may be generally true of multi-processing of every kind. :) > Anyway, for now I will probably just stick with pmap +

Re: How does pmap partition its work?

2011-01-24 Thread Armando Blancas
> This is much faster than either of the other eager-pmaps I posted to > this thread, and yet it's only using 60% CPU on my dual-core box. That > means there's still another x1.6 or so speedup possible(!) but I'm not > sure how. > Could -server make a difference here? -- You received this messag

Re: How does pmap partition its work?

2011-01-24 Thread Michael Gardner
On Jan 23, 2011, at 10:56 PM, Ken Wesson wrote: > I've managed to make this more efficient, by making each agent send > process a larger portion of the job than one single item: > > (defn eager-pmap [f & colls] > (let [cores (.. Runtime getRuntime availableProcessors) >agents (cycle (for

Re: How does pmap partition its work?

2011-01-23 Thread Ken Wesson
On Sun, Jan 23, 2011 at 11:34 PM, Ken Wesson wrote: > Other posts to the thread indicate that longer-range patterns in the > inputs could cause problems. If you know you'll be consuming the full > sequence, try this: > > (defn eager-pmap [f & colls] >  (map deref (doall (apply map #(future (f %))

Re: How does pmap partition its work?

2011-01-23 Thread Ken Wesson
Other posts to the thread indicate that longer-range patterns in the inputs could cause problems. If you know you'll be consuming the full sequence, try this: (defn eager-pmap [f & colls] (map deref (doall (apply map #(future (f %)) colls This creates all of the futures right away (due to t

Re: How does pmap partition its work?

2011-01-23 Thread Ken Wesson
On Sun, Jan 23, 2011 at 10:31 PM, Ken Wesson wrote: > On Sun, Jan 23, 2011 at 8:56 PM, Michael Gardner wrote: >> Suppose I have a sequence of tasks I'd like to parallelize using pmap. The >> amount of CPU time these tasks require varies greatly; in particular, many >> of them will require virtu

Re: How does pmap partition its work?

2011-01-23 Thread Ken Wesson
On Sun, Jan 23, 2011 at 8:56 PM, Michael Gardner wrote: > Suppose I have a sequence of tasks I'd like to parallelize using pmap. The > amount of CPU time these tasks require varies greatly; in particular, many of > them will require virtually no work. Can I rely on pmap to divide the work > eff

Re: How does pmap partition its work?

2011-01-23 Thread Michael Gardner
On Jan 23, 2011, at 8:34 PM, Andy Fingerhut wrote: > No, you cannot rely on pmap to do that. Thanks for the detailed and informative answer. I'll probably settle for shuffling the list of inputs before passing them to pmap, and just accept that there may be some inefficiency in the distributio

Re: How does pmap partition its work?

2011-01-23 Thread Andy Fingerhut
No, you cannot rely on pmap to do that. pmap is lazy in the sequence it produces, so it tries not to work farther ahead of the consumer of its "output sequence" than the amount of parallelism it uses, which is the number of available processors plus 2. Suppose you have 4 available process

How does pmap partition its work?

2011-01-23 Thread Michael Gardner
Suppose I have a sequence of tasks I'd like to parallelize using pmap. The amount of CPU time these tasks require varies greatly; in particular, many of them will require virtually no work. Can I rely on pmap to divide the work efficiently even if there is some pattern to the distribution of eas

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
On 6 September 2010 02:01, CuppoJava wrote: > Ah that makes sense! Thanks Michal! Great! :-) > I have looked through Lisp in Small Pieces, and didn't find it very > well written. I think a lot was lost through the translation. Oh, that's unfortunate. Perhaps I should step up my French-learning

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Ah that makes sense! Thanks Michal! I have looked through Lisp in Small Pieces, and didn't find it very well written. I think a lot was lost through the translation. Besides SICP, the other great lisp book I read was actually "The Scheme Programming Language". The chapter on continuations is mind-b

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
In the presence of macros, it's best to think "Lisp compilation = evaluation of all forms". So, you do two things at the same time: (1) accumulate object code to be output as the result of the compilation and (2) actually execute the programme, so that you can call functions and examine variables w

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Thanks for all the replies! SICP is one of my favorite books actually, I have read through it many times already. My question is particularly concerning expanding macros during compilation. If your source has NO use of macros. Then it's trivial to compile. Just compile each form one by one. The

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
On 5 September 2010 18:46, CuppoJava wrote: > I'm writing a simple lisp for educational purposes, and I can't figure > out how to do compilation. The final chapter of SICP [1] deals with compilation of Scheme code down to a kind of assembly language (also introduced in the book). It's fantastical

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Daniel Gagnon
On Sun, Sep 5, 2010 at 5:11 PM, Stuart Sierra wrote: > Clojure compiles sources to Java ".class" files. To create a .class > file that can be run at the command line, you need a namespace with a > (:gen-class) directive and a function named "-main". Here's an > example: > I think the question wa

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Stuart Sierra
Clojure compiles sources to Java ".class" files. To create a .class file that can be run at the command line, you need a namespace with a (:gen-class) directive and a function named "-main". Here's an example: (ns com.example.myapp (:gen-class)) (defn -main [] (println "Hello

Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Hi everyone, I'm writing a simple lisp for educational purposes, and I can't figure out how to do compilation. In particular, I can't figure out how I can get a compiled file to run in the same way as if it were loaded. I read on the webpage that Clojure can do this. Does anyone know how Clojure do

Re: How does contains? work?

2010-06-27 Thread ru
Thank you very much to all for comprehensive explanations. As newcomer to Clojure dare to remark that this is not very consistent semantics of "contains" :) On 25 июн, 21:25, ataggart wrote: > My sense from reading Rich's writing on the subject is that 'contains? > was named with the use of sets

Re: How does contains? work?

2010-06-25 Thread ataggart
My sense from reading Rich's writing on the subject is that 'contains? was named with the use of sets in mind. There is also a pairing logic involved whereby if 'contains? returns true, the the value returned by 'get is valid (this covers cases in maps where the value actually is nil). As Meikel

Re: How does contains? work?

2010-06-25 Thread Peter Schuller
> Explain me this, please: > > user=> (def x (cons 'a nil)) > #'user/x > user=> x > (a) > user=> (contains? x 'a) > false > user=> contains? checks whether the collection contains the *key*, not the value. So for example the list [:a :b] contains keys 0 and 1, but not 2 or :a: user=> (contains? [

Re: How does contains? work?

2010-06-25 Thread Meikel Brandmeyer
BTW: Searching the group archives for contains? will bring up a lot of information on this topic. -- 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 modera

Re: How does contains? work?

2010-06-25 Thread Meikel Brandmeyer
Hi, (some '#{a} x) or (some #(= 'a %) x) in case 'a can be false or nil. Sincerely Meikel -- 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 -

How does contains? work?

2010-06-25 Thread ru
Hello, Explain me this, please: user=> (def x (cons 'a nil)) #'user/x user=> x (a) user=> (contains? x 'a) false user=> And, what is Clojure analogue of Lisp "member" function. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Recursions under lazy-seq - how does it work?

2009-11-25 Thread David Brown
On Wed, Nov 25, 2009 at 11:01:32PM +0100, Meikel Brandmeyer wrote: >(defmacro lazy-seq > "..." > [& body] > `(LazySeq. ~(with-meta `fn* {:once true}) [] ~...@body)) It's also probably good to explain why fn* is quoted with backquote rather than a regular quote. This took me a while to figure

Re: Recursions under lazy-seq - how does it work?

2009-11-25 Thread Meikel Brandmeyer
Hi, Am 25.11.2009 um 22:43 schrieb David Brown: (defmacro lazy-seq "..." [& body] (list 'new 'clojure.lang.LazySeq (list* '#^{:once true} fn* [] body))) That's it. The neat thing is that you or I can also write macros that do this kind of thing. It's one of the things that m

  1   2   >