Re: soft question: should remote channels appear like local channels

2014-01-31 Thread Cedric Greevey
You do need to handle connection loss in some way, which is never a concern with purely local channels. The middle level needs to detect a broken connection (as distinct from a full buffer on put or an empty one on take) and signal it somehow (OOB value, exception, put to a control channel, or etc.

Re: Request for help optimising a Clojure program

2014-01-30 Thread Cedric Greevey
+1 On Thu, Jan 30, 2014 at 11:13 AM, Andy Fingerhut wrote: > Thanks to the work and thought of Mark Engelberg, Alex Miller, Rich > Hickey, myself, and likely several others who I should be naming here but > am forgetting, the latest (not yet released) Clojure master version has an > improved has

Clooj 0.4.0/REPL bug parsing comments that shouldn't be being parsed

2014-01-28 Thread Cedric Greevey
user=> (defn foo [] ; 2*a/b ) NumberFormatException Invalid number: 2*a clojure.lang.LispReader.readNumber (LispReader.java:258) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:219) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException

Re: Looking for a reference binary parsing

2014-01-27 Thread Cedric Greevey
On Mon, Jan 27, 2014 at 4:13 PM, danneu wrote: > ztellman's Gloss is magic to me. > > - Here's an example of my first attempt to use Gloss to parse the Bitcoin > protocol: https://gist.github.com/danneu/7397350 -- In 2-chan.clj, it > demonstrates using ztellman's Aleph to send Bitcoin's verack ha

Re: equality

2014-01-27 Thread Cedric Greevey
Seems to me that BigDecimal, being essentially a BigInteger numerator and a power-of-ten denominator, could have been accommodated in Category 1 given that Ratio could. On Mon, Jan 27, 2014 at 10:26 AM, Andy Fingerhut wrote: > As Jim already mentioned, you can use == to compare numbers for equal

Re: How to place unicode characters in span tag in reagent (formerly known as cloact)

2014-01-27 Thread Cedric Greevey
So, the source code for the web page says ↺ then? It may be already being entity escaped. Try just [:span "\U"] with the appropriate code (maybe the same one, 8634) for and see if that works. On Mon, Jan 27, 2014 at 6:15 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote:

Re: async/close! called when channel is gc-ed ?

2014-01-26 Thread Cedric Greevey
(b) is easy if you're willing to drop down to Java, or use gen-class. You can define a finalize method. On the other hand, you might also want to look into WeakReference and ReferenceQueue, which can be used from Clojure with interop. You can discover when objects become eligible for GC with Refer

Re: clojure.edn/read-string exceptions => nil

2014-01-26 Thread Cedric Greevey
Shouldn't that be: (defn filter-printable [obj] (cond (or (symbol? obj) (number? obj) (string? obj) (keyword? obj)) obj (vector? obj) (apply vector (map filter-printable obj)) (seq? obj) (map filter-printable obj) (set? obj) (into #{} (map filter-printable obj)) (map? obj) (into {

Re: Clojure memory usage

2014-01-25 Thread Cedric Greevey
You might want to use the G1 collector (JVM opt UseG1GC) if you're using Java 7 as I've heard that the G1 collector gives memory back to the OS more readily than the other options. On Sat, Jan 25, 2014 at 1:55 PM, Jarrod Swart wrote: > This was talked about here: > https://groups.google.com/for

Re: core.async over websocket + cljs + clojure

2014-01-25 Thread Cedric Greevey
What about a hybrid blocking/timeout approach? At the sending end of the network bridge you have the "taker" and at the receiving end the "putter". The "putter", when it sees an object on the wire, puts it on a local channel (blocking put with timeout). If it succeeds it sends an ack up the wire. I

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
on? > > Like you said it can't be #{}. If you seed an intersection with #{} you > get #{}, so you can't intersect from the empty set. The identity for an > intersection is whatever the common element is, but how would you know that? > > On Friday, January 24,

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
ection ...). I couldn't think of one. > > Breaking this problem out into 'parallel' units of reduction isn't > possible because the problem is dependent on order. Which reducers can't > have, or so I think after what I have read today. > > > On Friday, Ja

Re: clojure.core/reduce calls (f) if given a reducible coll and no init value

2014-01-24 Thread Cedric Greevey
An interesting question this raises is if there is any sensible way to define (intersection). It would need to behave as an identity element for intersection, so would need to behave as a set (so, (set? (intersection)) => truthy) that contained everything (so, (contains? (intersection) foo) => foo

Re: semantics of >! on closed channels

2014-01-24 Thread Cedric Greevey
timed out. On Fri, Jan 24, 2014 at 3:20 AM, John Szakmeister wrote: > On Thu, Jan 23, 2014 at 9:17 PM, Cedric Greevey > wrote: > > [meta, but about something apparently triggered by the message, from this > > thread, that I'm quoting] > > > > Why did readi

Re: semantics of >! on closed channels

2014-01-23 Thread Cedric Greevey
t someone posting to a google group > can get a virus through a text email, and that that virus somehow affected > your browser, is just laughable. > > Timothy > > > On Thu, Jan 23, 2014 at 7:34 PM, Cedric Greevey wrote: > >> Which part didn't you understand? Wh

Re: semantics of >! on closed channels

2014-01-23 Thread Cedric Greevey
the presumption that the seemingly superficial hijack left it infected with a nasty rootkit of some sort, or was it just a prank, or even a known software bug somewhere?) On Thu, Jan 23, 2014 at 9:20 PM, Timothy Baldridge wrote: > Umwat? > On Jan 23, 2014 7:17 PM, "Cedric

Re: semantics of >! on closed channels

2014-01-23 Thread Cedric Greevey
[meta, but about something apparently triggered by the message, from this thread, that I'm quoting] Why did reading this post cause gmail to go bonkers? I saw this thread had new articles since earlier today, brought it up, and read the previous message, then just after I'd scrolled down to this o

Re: avoiding repetition in ns declarations

2014-01-22 Thread Cedric Greevey
Maybe there should be a way to export stuff for transitive inclusion: (ns common-includes (:require [foo.core :refer [fooify] :export true]) ...) ... (ns my-ns (:require [common-includes :as c])) (defn bar [x] (c/fooify x 42)) On Wed, Jan 22, 2014 at 4:22 PM, Stuart Sierra wrote: >

Re: core.async question - canceling thread

2014-01-22 Thread Cedric Greevey
It's not safe if the thread is holding any locks. It *may* also leak native resources if the thread is holding those, but native resources held by a heap-allocated Java object are supposed to be cleaned up by the finalizer if the object is GC'd, and I think Thread.stop properly removes that thread'

Re: Eastwood lint tools - some Qs

2014-01-13 Thread Cedric Greevey
IMO, :eastwood-arglist (and a proliferation of other tool-specific metadata) would be exactly the wrong approach; :arglists should be the real defn-form arglists. Instead there should be an optional :pretty-arglists for documentation generators to use in lieu of :arglists if it is present. That wou

Re: How can I improve this?

2014-01-10 Thread Cedric Greevey
On Fri, Jan 10, 2014 at 10:22 AM, Laurent PETIT wrote: > Hi, > > Use frequencies to get a map of path => nb of occurrences, then for each > entry of the map, create unique names. > Cannot provide an impl on the uPhine, sorry > "uPhine"? :) -- -- You received this message because you are subscr

Re: [ANN] Counterclockwise 0.21.0

2014-01-09 Thread Cedric Greevey
On Thu, Jan 9, 2014 at 4:01 PM, Laurent PETIT wrote: > ccw-ide.org is hosted by OVH France. > Of what significance is that? Unless you mean to say that they abuse their customers by sometimes using the machine hosting a customer's site to generate nefarious network activity, which then gets blame

Re: [ANN] Counterclockwise 0.21.0

2014-01-09 Thread Cedric Greevey
My DNS is Google's 8.8.8.8 >>>> >>>> $ host ccw-ide.org >>>> ccw-ide.org has address 213.186.33.3 >>>> >>>> $ host doc.ccw-ide.org >>>> doc.ccw-ide.org has address 213.186.33.3 >>>> >>>> doc.ccw-ide.

Re: [ANN] Counterclockwise 0.21.0

2014-01-09 Thread Cedric Greevey
://cl.ly/image/280j3J2Q1X2m > > Thought for a while that domain has expired. > > > On Thu, Jan 9, 2014 at 2:51 PM, Cedric Greevey wrote: > >> You might like to know that PeerBlock (and therefore probably other >> privacy software, especially any using iblocklist.com's Leve

Re: [ANN] Counterclockwise 0.21.0

2014-01-09 Thread Cedric Greevey
You might like to know that PeerBlock (and therefore probably other privacy software, especially any using iblocklist.com's Level 1 bad-actor list) is false positiving on ccw-ide.org, misidentifying it as something called OVH Somethingorother. -- -- You received this message because you are subs

Re: Possible heisenbug in test suite (not in individual test runs) with memoization

2014-01-06 Thread Cedric Greevey
It's possibly an interaction between memoization and dynamic vars; more specifically, a result might be being memoized with one with-precision context active, and then recalled with a different one active, with arguments that compare equal despite the different precisions (say, because those argume

Cute Clojure tricks

2014-01-05 Thread Cedric Greevey
How many states can the US have and keep a flag with a reasonably close to square arrangement of stars like it currently has? (take-while #(<= % 100) (sort (distinct (for [m (range 3 20) n (range (int (* m 3/4)) (inc m))] (- (* 2 m n) m n -1) (8 13 18 23 25 32

Re: Sorting Nested Vectors and filter out some

2014-01-04 Thread Cedric Greevey
You might wish to consider a different data structure. For example, the inner objects might be better off as maps with named keys, so your lookup keys would be things like :amount rather than 5. And instead of out of band values like the string "N/A" you'd just omit a mapping in such cases. At the

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Yeah, he probably could. But maybe he has a good reason for avoiding it that we're not aware of. Though I'm not sure what that could be. On Fri, Jan 3, 2014 at 8:11 PM, Jason Wolfe wrote: > > > > On Fri, Jan 3, 2014 at 4:43 PM, Timothy Washington wrote: > >> The crux of the problem is that the

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Amend what I said: your params would need to be something like `(... system-atom ...), or `(... a-namespace/system-atom ...), or `(... (:foo @system-atoms) ...). Then (eval `(~afn ~@params)) will splice that in and the resulting code will look up the appropriate Var (and then the appropriate map ke

Re: Core.async, Rules for passing clojure vals to go block

2014-01-03 Thread Cedric Greevey
Your best bet is to move your "system atom" out to a top-level def, like so: (def system-atom (atom '({}))) Then just use (eval `(~afn system-atom)) later on, from places where the system-atom Var is visible (same ns, or :use'd), or use (eval `(~afn x/system-atom)) to qualify the name. The syntax

Re: core.async - extracting code from a go block

2013-12-31 Thread Cedric Greevey
It should work if it's inlined or a macro. It won't shrink foo's generated code size any if bar is a macro, but it will split up the source code into smaller pieces if that's all you're concerned about. On Tue, Dec 31, 2013 at 8:50 PM, Paul Butcher wrote: > I recently discovered that parking ca

Re: Akka-like framework in Clojure ?

2013-12-31 Thread Cedric Greevey
On Tue, Dec 31, 2013 at 9:26 AM, Jakub Holy wrote: > I also believe that Rich Hickey has some good reasons for why / when not > to use actor-based concurrency. I cannot find the reference now, perhaps it > is mentioned (also) in the StrangeLoop 2013 Clojure core.async > Channels

Re: case/java interop weirdness

2013-12-31 Thread Cedric Greevey
Not really, as the lookups will happen at macroexpansion time and not at runtime. It should be as efficient as a normal (case ...). On Tue, Dec 31, 2013 at 7:00 AM, Paul Butcher wrote: > On 30 Dec 2013, at 16:34, Cedric Greevey wrote: > > To do it with case, you'd need to wrap c

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:59 PM, Massimiliano Tomassoli wrote: > On Monday, December 30, 2013 6:31:52 PM UTC+1, Cedric Greevey wrote: > >> On Mon, Dec 30, 2013 at 12:30 PM, Massimiliano Tomassoli < >> kiuh...@gmail.com> wrote: >> >>> On Sunday, Dece

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:45 PM, Massimiliano Tomassoli wrote: > On Monday, December 30, 2013 6:27:05 PM UTC+1, Cedric Greevey wrote: > >> On Mon, Dec 30, 2013 at 12:13 PM, Massimiliano Tomassoli < >> kiuh...@gmail.com> wrote: >> >>> On Sunday, December

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:30 PM, Massimiliano Tomassoli wrote: > On Sunday, December 29, 2013 11:30:16 PM UTC+1, Cedric Greevey wrote: > >> On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge wrote: >> >>> Not mentioned in Cedric's post are two other important

Re: protocols and overloading

2013-12-30 Thread Cedric Greevey
On Mon, Dec 30, 2013 at 12:13 PM, Massimiliano Tomassoli wrote: > On Sunday, December 29, 2013 10:11:47 PM UTC+1, tbc++ wrote: >> >> Not mentioned in Cedric's post are two other important things: >> >> Protocols can be extended to existing types. For example: >> >> (defprotocol IType >> (type-a

Re: case/java interop weirdness

2013-12-30 Thread Cedric Greevey
To do it with case, you'd need to wrap case in a macro that expanded to `(case ~thingy ~(eval case1) ...) or something along those lines, with the evals snapping lookups like FetcherEvent/EVENT_TYPE_FEED_POLLED to the associated constants. This will have the effect of classloading the class with th

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
tee in '99 and gcc was normally pretty > good at tracking the emerging standard at the time... > > But, yes, the template compilation model and it's impact on linking > modules that specialized the same template had been problematic > earlier on. > > On Sun, Dec 29, 2013

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
On Sun, Dec 29, 2013 at 4:11 PM, Timothy Baldridge wrote: > Not mentioned in Cedric's post are two other important things: > > Protocols can be extended to existing types. > These are important for the Expression Problem, but not for the OP's query as originally stated, which simply asked for the

Re: Why is "add-watch" still in alpha?

2013-12-29 Thread Cedric Greevey
catch ArithmeticException _ :error))) where the consumer can look for :error instead of a number when derefing (in this case, this would be caused by the edge case b = 0). On Sun, Dec 29, 2013 at 5:01 PM, Cedric Greevey wrote: > On Sun, Dec 29, 2013 at 4:24 PM, larry google groups < >

Re: Why is "add-watch" still in alpha?

2013-12-29 Thread Cedric Greevey
On Sun, Dec 29, 2013 at 4:24 PM, larry google groups < lawrencecloj...@gmail.com> wrote: > And here is where the greatest disappointment arrives: neither > future > nor promise in

Re: protocols and overloading

2013-12-29 Thread Cedric Greevey
On Sun, Dec 29, 2013 at 12:27 PM, Massimiliano Tomassoli wrote: > What's the difference between protocols and simple overloading? > Dynamic dispatch. Overloading uses just the static type for dispatch, so this Java code: aBase = new Base(); aDerived = new Derived(); aBase2 = aDerived; something

Re: In your opinion, what's the best, and what's the worst aspects of using Clojure?

2013-12-28 Thread Cedric Greevey
wrote: > > On Dec 28, 2013, at 3:11 PM, Cedric Greevey wrote: > > > Adding to the above, in the specific context of genetic programming, I'd > suggest dividing the population into N subsets, one per core, and trialling > them in parallel to generate fitness scores; the

Re: In your opinion, what's the best, and what's the worst aspects of using Clojure?

2013-12-28 Thread Cedric Greevey
same values for num-to-keep and num-cores and whatever other parameters. Last snapshot before crash should crash the same way every time. On Sat, Dec 28, 2013 at 2:56 PM, Cedric Greevey wrote: > On Sat, Dec 28, 2013 at 12:45 PM, Lee Spector wrote: > >> >> On Dec 28, 2013,

Re: In your opinion, what's the best, and what's the worst aspects of using Clojure?

2013-12-28 Thread Cedric Greevey
On Sat, Dec 28, 2013 at 12:45 PM, Lee Spector wrote: > > On Dec 28, 2013, at 11:27 AM, Cedric Greevey wrote: > > > > It helps to go with the "functional, immutable" flow, in which case if > you get an unwanted exception it should *usually* have bubbled up from

Re: In your opinion, what's the best, and what's the worst aspects of using Clojure?

2013-12-28 Thread Cedric Greevey
On Sat, Dec 28, 2013 at 3:56 AM, Lee Spector wrote: > > On Dec 27, 2013, at 11:33 PM, guns wrote: > > > On Fri 27 Dec 2013 at 11:23:22PM -0500, Lee Spector wrote: > >> > >> On Dec 27, 2013, at 11:18 PM, guns wrote: > >>> > >>> (defmacro dump-locals [] ... > >>> ` > >> When and where do you call t

Re: Namespaces [was Re: Is Clojure right for me?]

2013-12-27 Thread Cedric Greevey
On Fri, Dec 27, 2013 at 3:13 PM, john walker wrote: > This works (clever hack!), but you would have to reduplicate the keys in > (defn bar [..]...), (defn baz [...] ...) etc. > (defmacro defthingyfn [name arglist & body] `(defn name ~(vec (cons '{:keys [thingy mumble fiddly]} arglist)) ~@body))

Re: Namespaces [was Re: Is Clojure right for me?]

2013-12-27 Thread Cedric Greevey
On Fri, Dec 27, 2013 at 2:32 PM, Mark Engelberg wrote: > On Fri, Dec 27, 2013 at 10:27 AM, Cedric Greevey wrote: > >> On Fri, Dec 27, 2013 at 1:08 PM, Mark Engelberg > > wrote: >>> >>> Solution 2: >>> >>> (defn foo [shared-info x] ... body us

Re: Namespaces [was Re: Is Clojure right for me?]

2013-12-27 Thread Cedric Greevey
On Fri, Dec 27, 2013 at 1:08 PM, Mark Engelberg wrote: > > Solution 2: > > (defn foo [shared-info x] ... body uses shared-info) > (defn bar [shared-info x] ... body uses shared-info) > > Call these functions via: > > (foo info 2) > (bar info 3) > In what way is this any worse than info.foo(2); in

Re: get rid of reflection in proxy-super?

2013-12-26 Thread Cedric Greevey
On Thu, Dec 26, 2013 at 6:57 PM, Colin Fleming wrote: > The problem is that your approach requires creating the proxy class with > the method bodies actually compiled into the body of the proxy class > method, they can't be in fns in a proxy map as they are now. This is ok in > the case where a me

Re: get rid of reflection in proxy-super?

2013-12-26 Thread Cedric Greevey
I'd suggest instead amending the core language to add a special form, maybe named .!, that works like . except it sees protected methods (and will cause an IllegalAccessError if it calls a protected method from outside of a subclass), and amend proxy to use .! for proxy-super (and put the proxy-sup

Re: How to go about 'proving' why dynamically typed languages are better.

2013-12-26 Thread Cedric Greevey
On Tue, Dec 24, 2013 at 12:23 PM, Rich Morin wrote: > On Dec 24, 2013, at 02:09, Cedric Greevey wrote: > > On Mon, Dec 23, 2013 at 7:37 PM, Rich Morin wrote: > > Media for Thinking the Unthinkable: > > Designing a new medium for science and engineering > &

Re: How to go about 'proving' why dynamically typed languages are better.

2013-12-24 Thread Cedric Greevey
On Mon, Dec 23, 2013 at 7:37 PM, Rich Morin wrote: > Media for Thinking the Unthinkable: > Designing a new medium for science and engineering > http://worrydream.com/MediaForThinkingTheUnthinkable/ > Is this available in a form that is skimmable, is greppable, is cheap for mobile users, ca

Re: When does clojure.lang.PersistentArrayMap become clojure.lang.PersistentHashMap

2013-12-23 Thread Cedric Greevey
The two classes have essentially the same semantics, but performance differences, which is why Clojure sometimes uses one and sometimes the other. If you want to enforce that a map is returned, enforce that the return is a subtype of java.util.Map rather than checking for a specific concrete class

Re: bug in clojure.zip when calling next on empty list node?

2013-12-23 Thread Cedric Greevey
On Sun, Dec 22, 2013 at 12:26 PM, Lee Spector wrote: > The issue I was rasing is that, when traversing '(() 0) with zip/next, one > should first visit the root, then (), and then 0. But what actually happens > is that between then () and the 0 one lands on a non-existent nil node. So > one ends up

Re: [ANN] Hoplon: web applications in Clojure and ClojureScript

2013-12-18 Thread Cedric Greevey
On Wed, Dec 18, 2013 at 10:45 PM, Micha Niskin wrote: > The difference between a cell and an atom with watchers attached is that > cells guarantee consistency. That is to say that the evaluation mechanism > ensures that a formula cell is never updated until all of the cells it > depends on have be

Re: [ANN] cljs-start 0.0.7 now support source-map

2013-12-17 Thread Cedric Greevey
On Tue, Dec 17, 2013 at 5:48 AM, Mimmo Cosenza wrote: > > May be for newcomers like me it will be good to add some integraional tips > for emacs(others) editors.. > > > I always feel guilty when talking about editors because I use emacs. It > seems that the top clojurists are pushing people to swi

Re: cider status

2013-12-16 Thread Cedric Greevey
On Mon, Dec 16, 2013 at 12:27 PM, Gary Johnson wrote: > Just to inject another sample into the population: > > As another hacker who lives in Emacs, I found the nrepl -> cider > transition to be quite painless. It took me maybe an hour of reading the > website docs, installing/uninstalling packag

Re: IE compatibility of clojurescript, Element undefined problem

2013-12-16 Thread Cedric Greevey
Everyone should give up IE6. And, preferably, every other version of IE. On Mon, Dec 16, 2013 at 7:59 AM, Xiangtao Zhou wrote: > hi all, > > I'm new for clojurescript. I found there is compatibility problem under > IE6, closurescript use Element which IE 6 dos not have. > > Line 34266, Elemen

Re: Is Clojure more functional then Scala?

2013-12-16 Thread Cedric Greevey
So, in other words, like most "which is the best programming language?" questions, the answer to this one is "It depends". :) On Mon, Dec 16, 2013 at 5:31 AM, Эльдар Габдуллин wrote: > Clojure targets multiple platforms, Scala - one. > > Clojure is Lisp. That means almost any programming paradig

Re: Clojure.org: Concurrency screencast 404

2013-12-16 Thread Cedric Greevey
On a related note, why is the 301 "Moved Permanently" HTTP status never used in actual practice? Instead, when things move you always get 404s and have to hunt them down manually. :P On Mon, Dec 16, 2013 at 3:44 AM, abhi wrote: > Hello, >Concurrency screencast link to blip.tv is throwing a

Re: cider status

2013-12-13 Thread Cedric Greevey
On Fri, Dec 13, 2013 at 2:43 AM, Adrian Mowat wrote: > > > Is cider just a new release of nrepl.el or a different thing entirely? > The former. Sorry to be a noob, but this is awfully confusing to the uninitiated. > Of course it is -- it's emacs. -- -- You received this message because you a

Re: type-hinting functions with variable (but known) return types

2013-12-11 Thread Cedric Greevey
The only thing I can think of off the top of my head is to write a hinted-array macro that turns (hinted-array Class expr) into ^Class (into-array Class expr). Emitting type hints or other form metadata in macros is do-able, but sometimes a bit tricky. Something like this might work (untested): (d

Re: Code layout

2013-12-11 Thread Cedric Greevey
On Wed, Dec 11, 2013 at 2:00 AM, Mark Engelberg wrote: > Put as much as is legible on one line. If you need to break lines, break > after the function name, not after the first parameter, in order to > minimize rightward drift. > I've always preferred (map foo coll1 coll2) over breaking af

Re: loop/recur with multiple branches

2013-12-10 Thread Cedric Greevey
On Tue, Dec 10, 2013 at 6:29 PM, Vincent Chen wrote: > Try this (not tested, might be missing parens and whatnot): > > (defn slice [x s n] > (loop [[h & tail] x, s s, n n, acc []] > (cond > (zero? n) acc > (zero? s) (recur tail s (dec n) (conj acc h)) > :else (recur tail (

Re: loop/recur with multiple branches

2013-12-10 Thread Cedric Greevey
On Tue, Dec 10, 2013 at 6:09 PM, Glen Mailer wrote: > I was recently working on some toy recursion problems, when I ran into a > function that I can express simply using normaly recursion, but I can't > seem to convert it into a form that works nicely with loop/recur. > > It's certainly not the r

Re: My first attempt at a macro: "can not recognize symbol"

2013-12-10 Thread Cedric Greevey
On Tue, Dec 10, 2013 at 12:53 PM, James Reeves wrote: > Remember that only the last form will be returned. So: > > (defn foo [] 1 2 3 4) > > `(defn ~start-function-name [] > will always return 4. The same principle applied with your macro. You > define four forms, but only return the last on

Re: Best way to loop a map of maps

2013-12-03 Thread Cedric Greevey
Tree-seq? But then, if the data is structured so each level has a distinct purpose, that's not really a great fit. Perhaps we need a for/doseq analog of assoc-in, update-in, etc.? At the very least I think this might work: (doseq [[outer-keys collections] m [collection-name collection] c

Re: I need a vector not a list?

2013-12-03 Thread Cedric Greevey
Seems to me that you can make a case for "a seq is sort of like an immutable PersistentIterator would be". Iterator -> next (get object) seq -> first (get object) Iterator -> next (mutate to point to next object) seq -> next (return new seq whose first is next object) On Tue, Dec 3, 2013 at

Re: core.async and performance

2013-11-29 Thread Cedric Greevey
On Fri, Nov 29, 2013 at 11:03 PM, Ben Mabey wrote: > On 11/29/13, 8:33 PM, Cedric Greevey wrote: > > Have you checked for other sources of performance hits? Boxing, var > lookups, and especially reflection. > > As I said, I haven't done any optimization yet. :) I did

Re: core.async and performance

2013-11-29 Thread Cedric Greevey
ow to make processor caches and branch prediction count for much, other than that the interpreter itself would be slower than it already is without these). On Fri, Nov 29, 2013 at 10:33 PM, Cedric Greevey wrote: > Have you checked for other sources of performance hits? Boxing, var > l

Re: core.async and performance

2013-11-29 Thread Cedric Greevey
Have you checked for other sources of performance hits? Boxing, var lookups, and especially reflection. I'd expect a reasonably optimized Clojure version to outperform a Python version by a very large factor -- 10x just for being JITted JVM bytecode instead of interpreted Python, times another how

Re: hash comparison

2013-11-28 Thread Cedric Greevey
Presumably it then compares the objects element by element. If the common case is for the arguments to (= x y) to be unequal with unequal hashes, though, this is still considerably faster. On Thu, Nov 28, 2013 at 5:03 PM, Andy Smith wrote: > Hi, > > I heard Rich Hickey talking about how identity

Re: [ANN] Overtone 0.9.0 Released

2013-11-27 Thread Cedric Greevey
r Wiki: >> >> https://github.com/overtone/overtone/wiki/Installing-overtone >> >> If anything isn't clear or obvious - please do let me know. >> >> Happy Hacking! >> >> Sam >> >> --- >> http://sam.aaron.name >> >> On

Re: Breaking out of doseq

2013-11-27 Thread Cedric Greevey
What about (first (filter identity (map (fn [[rx f]] (if (matches? rx input) (f input))) regexes))), where regexes is something like [[regex1 f1] [regex2 f2] ...] and input is some string. As long as none of the fs returns nil, this should work, using lazy sequence behavior to stop at the first mat

Re: [ANN] Overtone 0.9.0 Released

2013-11-27 Thread Cedric Greevey
add [some dependency vector] to your project.clj". If that's the case also for Overtone now, why was that not included in the announcement message? :) On Wed, Nov 27, 2013 at 2:12 AM, Samuel Aaron wrote: > Hi Cedric, > > On 26 Nov 2013, at 16:45, Cedric Greevey wrote: > &g

Re: [ANN] Overtone 0.9.0 Released

2013-11-26 Thread Cedric Greevey
Is there a turnkey download/install/play with version of this yet, or is that not until 1.0? On Tue, Nov 26, 2013 at 10:24 AM, Joseph Burnett wrote: > Sweet! > > > On Monday, November 25, 2013 8:46:44 AM UTC-8, Sam Aaron wrote: >> >> Hi there noise polluters! >> >> It's that glorious time again

Re: println / for unexpected behaviour

2013-11-26 Thread Cedric Greevey
On Tue, Nov 26, 2013 at 8:58 AM, Alex Miller wrote: > Realizing a lazy sequence incurs overhead on every item. Chunked seqs > amortize that cost by realizing a chunk of items at a time giving you > better overall performance at the cost of less laziness. > And in this case that resulted in all t

Re: println / for unexpected behaviour

2013-11-25 Thread Cedric Greevey
Clearly "board" is a chunked seq in this case. Use doseq when you want side effects for-each of some seqable, but don't care about the return values. The arguments for doseq are identical to those for for, but a) doseq will return nil and b) if the output of for was discarded (rather than the repl

Re: Spit seems to use incorrect line terminator on Windoze

2013-11-25 Thread Cedric Greevey
(println) outputs nothing *but* the host's line terminator. On Mon, Nov 25, 2013 at 6:22 AM, Tim Visher wrote: > On Mon, Nov 25, 2013 at 6:18 AM, Cedric Greevey > wrote: > > And yet it does happen, with PrintWriter and similar. Consider the > output of > > (print

Re: Spit seems to use incorrect line terminator on Windoze

2013-11-25 Thread Cedric Greevey
And yet it does happen, with PrintWriter and similar. Consider the output of (println) on different operating systems. On Mon, Nov 25, 2013 at 12:59 AM, Stefan Kamphausen wrote: > I agree with Alex. I would not want any magic to happen > to my string. > > Best, > Stefan > > -- > -- > You receive

Re: Spit seems to use incorrect line terminator on Windoze

2013-11-24 Thread Cedric Greevey
ght have a bug, write a bug report, and do us all > a favor. > > Timothy > > > On Sun, Nov 24, 2013 at 3:10 PM, Cedric Greevey wrote: > >> Not everyone wants to go to that much trouble just to tell everyone what >> he already told everyone via this list. >> >

Re: Spit seems to use incorrect line terminator on Windoze

2013-11-24 Thread Cedric Greevey
Not everyone wants to go to that much trouble just to tell everyone what he already told everyone via this list. On Sun, Nov 24, 2013 at 4:56 PM, Timothy Baldridge wrote: > Anyone can create an account on JIRA and create a ticket. > > Timothy > > > On Sun, Nov 24, 2013

Re: Spit seems to use incorrect line terminator on Windoze

2013-11-24 Thread Cedric Greevey
On Sun, Nov 24, 2013 at 3:36 PM, Tim Visher wrote: > Sounds like a bug to me. You could open a ticket to get further > discussion going. > Actually, TTBOMK I cannot, since I think one needs an account at some site I don't have an account at to do that. But someone who does and has a 'doze box ca

Spit seems to use incorrect line terminator on Windoze

2013-11-23 Thread Cedric Greevey
(spit "C:\\foo.txt" "test1\n") (spit "C:\\foo.txt" "test2\n" :append true) open file in notepad => "test1test2" (spit "C:\\foo.txt" "test1\r\n") (spit "C:\\foo.txt" "test2\r\n" :append true) open file in notepad => "test1 test2" So a newline in the string passed to spit

Re: core.async timeout channels are values - is this intended

2013-11-20 Thread Cedric Greevey
Isn't that not only violating least astonishment, but potentially introducing a terrible bug into the library? One could use "two different" timeout channels in two different alts, and if the timeout channels are aliased, then perhaps only one of the alts would actually get notified. On Wed, Nov

Re: 2013 State of Clojure & ClojureScript survey results

2013-11-19 Thread Cedric Greevey
On Tue, Nov 19, 2013 at 10:02 AM, James Reeves wrote: > > > I think in this case it's more a problem with the Java API, which the fs > library wraps. Until Java 7, I don't think relative path normalisation > existed in the core Java libraries. > > It didn't, and .toPath isn't in the 1.6 java.io.Fil

Re: Using xlisp assoc-lists in clojure

2013-11-18 Thread Cedric Greevey
It would probably be better to convert to/from normal Clojure maps at the edges of the Clojure code. If the input is '((k1 v1) (k2 v2) (k3 v3) (k1 v4)) and we want the earliest occurrence of k1 to "win", then that suggests (into {} (reverse alist)). If the input's flattened that would be (into {} (

Re: [ANN] overload-middleware 0.1.1

2013-11-17 Thread Cedric Greevey
On Sun, Nov 17, 2013 at 8:22 AM, Christian Romney wrote: > Maybe you should re-read this whole thread. Clinton is just pointing out > how impolite it is, particularly as the first response to an ANN post, to > poopoo all over someone else's work, > Please provide a citation to back up your claim

Re: [ANN] overload-middleware 0.1.1

2013-11-17 Thread Cedric Greevey
for writing it. > > -- Clinton Dreisbach > > > On Sun, Nov 17, 2013 at 7:53 AM, Cedric Greevey wrote: > >> So, when people here are talking about the web, they might not be talking >> about the web. Erm, okay, I guess ... >> >> >> On Sun, Nov 17, 2013 at

Re: [ANN] overload-middleware 0.1.1

2013-11-17 Thread Cedric Greevey
So, when people here are talking about the web, they might not be talking about the web. Erm, okay, I guess ... On Sun, Nov 17, 2013 at 7:11 AM, James Reeves wrote: > On 17 November 2013 05:25, Cedric Greevey wrote: > >> On Sat, Nov 16, 2013 at 9:35 PM, James Reeves wrote:

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Cedric Greevey
On Sat, Nov 16, 2013 at 9:35 PM, James Reeves wrote: > On 17 November 2013 01:52, Cedric Greevey wrote: > >> The distribution will be narrow and peak at around 1 second, though, >> which may not be what you want. Of course, the OP has since indicated that >> he meant non

Re: Question on Sequences

2013-11-16 Thread Cedric Greevey
This efficiency is why built-in functions to map, filter, etc. vectors to vectors aren't provided; better to use (into []) on a chain of seq-outputting transformations of a vector than to chain these hypothetical vector-native functions. OTOH, it occurs to me that efficient chaining can still be a

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Cedric Greevey
time >> before trying again? Good luck herding them cats. See also >> http://en.wikipedia.org/wiki/Wicked_problem ... >> >> >> >> On Sat, Nov 16, 2013 at 4:24 PM, James Reeves wrote: >> >>> It may be useful for certain web services. If the server get

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Cedric Greevey
On Sat, Nov 16, 2013 at 5:06 PM, James Reeves wrote: > Web servers are often used to serve information to clients other than web > browsers. > [citation needed] -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Cedric Greevey
e useful for certain web services. If the server gets overloaded > by a temporary spike, the clients could pick a random sleep time before > trying again. > > - James > > > On 16 November 2013 21:15, Cedric Greevey wrote: > >> I can think of very few web apps where this

Re: [ANN] overload-middleware 0.1.1

2013-11-16 Thread Cedric Greevey
I can think of very few web apps where this would be a desirable approach. A user getting a spurious error in response to a URL that they *know* is valid is just going to hammer on the "reload" button until they get a correct response from the server. So the server will end up even more congested t

Re: A Design (Simplification) Problem

2013-11-13 Thread Cedric Greevey
One might also wish to consider a "pull" model, in which clients explicitly request information they need from the server. A client could ask for an object's health, given its ID; or for the current ids and positions of monsters in a particular small geographical area (which the server would look u

  1   2   3   4   5   6   >