[JOB] Remote USA timezone Developer @ Clubhouse.io

2019-08-30 Thread Timothy Pratley
Clubhouse [https://clubhouse.io/] Pleasant Clojure/Datomic architecture. Diverse team. Distributed remote. Established product with a growing customer base. Please email me at timothyprat...@gmail.com or t...@clubhouse.io -- You received this message because you are subscribed to the Google Group

Nov 20 Q: How can I build datalog queries around a firebase backend?

2016-11-20 Thread Timothy Pratley
Thanks to encouragement from Chris I want to continue on the Firebase path and investigate the pros/cons of storing datoms instead of entities. I am thinking the schema will be: {tx: {x1: {user: u1 t: epoch}} eavt: {e1: {e: 1 a: age v: 40 t

Re: [BUG] : clojure.data/diff handles nested empty collections incorrectly

2015-02-23 Thread Timothy Pratley
Hi Andy, Having thunk on it, I will try to articulate my preference for nil over {} more clearly: (clojure.data/diff {:x {:y 1}} {:x {}}) ;; => ({:x {:y 1}} {:x nil} nil) Do you agree the current result is wrong? :x nil is not 'in' {:x {}} nil is not associative so in this context does not mea

Re: [BUG] : clojure.data/diff handles nested empty collections incorrectly

2015-02-20 Thread Timothy Pratley
Hi Andy, On Fri, Feb 20, 2015 at 5:51 PM, Andy Fingerhut wrote: > The goal with your library is to transmit deltas between two systems, and > then apply those deltas to the other system to make them match, yes? > Correct, it works well for what I need it to do. :) > How would you use the dif

Re: [BUG] : clojure.data/diff handles nested empty collections incorrectly

2015-02-20 Thread Timothy Pratley
On Fri, Feb 20, 2015 at 4:40 PM, Andy Fingerhut wrote: > Why not ({:x {:y 1}} {:x {}} nil) ? > Hi Andy, Great point! Both solutions convey accurately the same meaning? I have a subjective preference to nil as the absence of things in b that are not in a. Conversely {:x {}} implies that :x is

[BUG] : clojure.data/diff handles nested empty collections incorrectly

2015-02-20 Thread Timothy Pratley
Alex/Rich, if a patch is welcome for this I am happy to raise a ticket and submit. Test case: (clojure.data/diff {:x {:y 1}} {:x {}}) Expected: ({:x {:y 1}} nil nil) Actual: ;; => ({:x {:y 1}} {:x nil} nil) Problem: There is nothing only in the second input, so the second result should be nil

test output diffs

2014-06-23 Thread Timothy Pratley
Is there any appetite for a ticket to include diffs in core.test? -- 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 you

Re: condp first matching predicate

2014-03-18 Thread Timothy Pratley
Nice, 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

condp first matching predicate

2014-03-17 Thread Timothy Pratley
Hi, Is there a better way to write (cond (neg? 1) "neg" (zero? 1) "zero" (pos? 1) "pos" :default "default") I came up with this: (condp #(%1 %2) 1 neg? "neg" zero? "zero" pos? "pos" = "default") Which I wouldn't so much mind if I knew the name for #(%1 %2) And this: (defma

Re: [ANN] A post on CLJS DOM manipulation libraries

2013-12-15 Thread Timothy Pratley
Very illuminating - thank you! This is a topic that needed explaining :) -- -- 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 patie

Re: ANN Introducing EEP, a young [event] stream processing library

2013-09-05 Thread Timothy Pratley
Awesome! Thank you for making this available, neat library - I like it. PS: You can improve your golf score by using rand-nth :) :) (defn gen-events [] (map #(assoc %1 :id %2) (repeatedly #({:host(rand-nth hosts) :status (rand-nth status-codes)

reporting function inputs as part of exceptions

2012-09-03 Thread Timothy Pratley
I'm working on a project where it would be quite convenient to have the input values to the function reported in any exceptions that get thrown. I'm guessing the way to do this would be to create a replacement defn which had a try catch and threw a new error with the inputs captured. Has anyone

Clooj is great :)

2011-12-28 Thread Timothy Pratley
Have just been trying Clooj out and I have to say, it is really really good! Thanks Arthur for the neat tool. I particularly like that the repl interaction is very slick, and how it takes care of project structure in a very minimalist but clearly structured way. -- You received this message becau

Re: New home for ClojureCLR

2011-12-23 Thread Timothy Pratley
Nice! Good move :) Great to see the .NET support continuing and strengthening. On Tue, Dec 20, 2011 at 1:49 PM, dmiller wrote: > ClojureCLR has a new home! > > Code repo:  https://github.com/clojure/clojure-clr > JIRA: http://dev.clojure.org/jira/browse/CLJCLR > > Old binary distributions for v

Re: immutable quad tree

2011-04-20 Thread Timothy Pratley
Thanks :) On Wed, Apr 20, 2011 at 1:32 AM, pepijn (aka fliebel) wrote: > I made on here, but removed it later, not sure if it's any good: > https://github.com/pepijndevos/Begame/blob/d1bf8d687cda0a318cbce5f5ddac57b103c43d98/src/ant_mine/quadtree.clj > > On Apr 19, 8:09 pm

immutable quad tree

2011-04-19 Thread Timothy Pratley
How would I represent a quad tree (or any spatial index that allows me to find close neighbors quickly) in Clojure? -- 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

Re: ClojureCLR in production ?

2011-03-25 Thread Timothy Pratley
Hi Jules On Wed, Mar 23, 2011 at 12:34 AM, Jules wrote: > I was wondering whether anyone else had ClojureCLR in production and > how they felt about it ? Whether it will be mature enough in say 3 > months to support a production app ? I've been using it for a small project and haven't run into a

Clojure CLR ISeq IEnumerable

2011-03-07 Thread Timothy Pratley
Feature request: It would be handy for ISeq to inherit IEnumerable. My use case is wanting to expose an IEnumerable "Values" from a Clojure IPersistentMap (vals ) call Currently I can do it easily enough by casting to PersistentTreeMap which has a .Values implementation, but I suspect there is prob

Re: CLR classpath

2011-03-03 Thread Timothy Pratley
On Wed, Mar 2, 2011 at 8:39 AM, dmiller wrote: > (1)  I think the copy solution is the easiest. Ok sounds good > (2)  I'll have to look at the ambiguous match problem. User error on my part; I figured out that mixing .NET versions is bad... switch to compiled from source and it is working beau

CLR classpath

2011-02-27 Thread Timothy Pratley
Hi there, I want to use ClojureCLR in a C# project I am working on and need some guidance. 1) How do I correctly add ClojureCLR as a project reference in Visual Studio (2010)? I tried adding the Clojure.dll and that allowed my code to compile fine referencing a Clojure datastructure, but at run

Re: feedback on first compojure app: Sportello

2011-01-05 Thread Timothy Pratley
On Sun, Jan 2, 2011 at 11:30 AM, Alex Baranosky wrote: > Any comments on style, technique or just anythings I missed would be greatly > appreciated.  I'm really trying to expand my horizons and perfect the app as > a kind of kata. Sophisticated! I like it. I will take exception to the naming of "

Re: My first clojure web app

2011-01-05 Thread Timothy Pratley
Neat, looks pretty nice. I love invitations to nit pick! database.clj (defn complete-todo [id] (dosync (ref-set *todo* (vec (remove #(= (get % :id) id) @*todo*) 1) ref-set is unnecessary you could re-factor this to use alter. The result is the same, but semantically set only applies when the

Re: A problem on java class import

2010-07-06 Thread Timothy Pratley
This works great for looking up classes: http://dishevelled.net/Generating-Clojure-import-lines-using-SLIME.html You can just call the function from the REPL if you don't use SLIME Hope that helps

Re: Naming factory functions

2010-04-29 Thread Timothy Pratley
On 23 April 2010 12:21, joshua-choi wrote: > When it comes to naming factory functions—functions that create things— > clojure.core gives four precedents: > > 1. Name it exactly what the new object is called. vector, hash-map, > set. > 2. Name it a shortened version of #1. vec. > 3. Prefix #1 wit

Re: Annotations

2010-04-29 Thread Timothy Pratley
On 24 April 2010 10:06, Rich Hickey wrote: > I've started adding some support for Java annotations, > Feedback welcome Neato! I've been hoping for this - thanks :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: confusing error from rand-int

2010-04-29 Thread Timothy Pratley
Hi Lee, On 29 April 2010 22:31, Lee Spector wrote: > The error that I get is: > > Caused by: java.lang.IllegalArgumentException: n must be positive >at java.util.Random.nextInt(Random.java:250) > Hopefully this will give you the clue you need: user=> (. thread-local-random-generator (ne

Re: Why I have chosen not to employ clojure

2010-03-25 Thread Timothy Pratley
Clojure can be used in so many different ways. I can't think of any other language where I have so many varied "integration options". The flexibility is confusing and frustrating, but I much prefer its presence than absence. :) I'm glad I stuck with it. -- You received this message because you ar

Re: REPL, refs and casting

2010-03-10 Thread Timothy Pratley
Hi Mike, On 10 March 2010 21:03, Mike Erickson wrote: > I am writing a simple blackjack game in Clojure I've written up a little commentary as to how I'd approach this problem differently: http://gist.github.com/328929 which hopefully will give you some ideas. The general thrust being to keep yo

Re: REPL, refs and casting

2010-03-10 Thread Timothy Pratley
On 11 March 2010 17:15, Timothy Pratley wrote: > You probably want to use conj instead of concat! Actually ignore that! I was being confused by the deck-building. Can you try running this code: http://gist.github.com/328912 It is exactly the same as yours but uses known starting conditi

Re: REPL, refs and casting

2010-03-10 Thread Timothy Pratley
On 11 March 2010 17:10, Timothy Pratley wrote: > I tried running your code and it worked fine for me... Ah excuse me it only 'worked' because I used vectors instead of lists: > [5 \S]]] [:player []]), :house ([:house []]), :deck nil} <--- should give you the clue you need,

Re: REPL, refs and casting

2010-03-10 Thread Timothy Pratley
On 10 March 2010 21:03, Mike Erickson wrote: > but calling (deal 2 :house) bombs out with the following stacktrace: Hi Mike, I tried running your code and it worked fine for me... so I think something else is playing tricks on you here like maybe you changed the function in your text buffer but

Re: clojure.core/compare and persistent lists

2010-03-10 Thread Timothy Pratley
group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=enFrom 633d8b03ecb304e94e43d41ef57eab8fbb354533 Mon Sep 17 00:00:00 2001 From: Timothy Pratley Date: Wed, 10 Mar 2010 22:14:13 +1100 Subject: [PATCH] Made ISeq Compar

Re: benchmarks on a poor-man's matrix concept

2010-03-08 Thread Timothy Pratley
On 9 March 2010 06:57, Jonathan Shore wrote: > the second because maps clearly are not "near the metal" maps are actually very very efficiently implemented. Small maps are especially efficient as they are implemented as array maps. user=> (type {:a 1, :b 2}) clojure.lang.PersistentArrayMap At te

Re: Clojure Implementation issues that may affect performance?

2010-03-08 Thread Timothy Pratley
On 9 March 2010 04:03, Jonathan Shore wrote: > (defn fib [#^Integer a] >   (if (< a 2) >     a >     (+ (fib (- a 1)) (fib (- a 2) > I'm just learning, so I may have overlooked something that mitigates or > otherwise avoids dispatch. You might want to experiment with something like (defn fib

Re: Two potential map-util functions

2010-03-08 Thread Timothy Pratley
>      true (update-in m (butlast v) #(dissoc % (last v)) No need for an unnamed function: true (update-in m (butlast v) dissoc (last v)) Regards, Tim. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: Canonical method to limit runtime of an evaluation?

2010-02-19 Thread Timothy Pratley
On 20 February 2010 07:22, p.bernard wrote: > Two Question: > 1. Is there a canonical method to limit eval execution time in the > REPL.  i.e (A method to force a limitation on the number of seconds > allowed to evaluate an clojure input resulting in a short circuited > exit of the eval request.)

Re: Clojure function varargs (not Java interop varargs)

2010-02-18 Thread Timothy Pratley
On 19 February 2010 18:04, Julien wrote: > Question #1 > > I want to write a vararg function that does something like this: > > (map vector [1 2 3] [4 5 6]) > which yields > ([1 4] [2 5] [3 6]) > > I try to capture this as a function: > > (defn rotate[& x] (map vector x)) > > but > > (rotate [1 2

Re: Common Lisp's append

2010-02-18 Thread Timothy Pratley
On 19 February 2010 15:18, Mike K wrote: > Hey Clojurians, > > I'm a Clojure and Common Lisp newbie. I heard that Norvig's PAIP was a > good book to study idiomatic CL code, so I've embarked on a project to > translate the examples to / work the exercises in Clojure.  I hope to > complete this pro

Re: http-agent usage in subsequent agent action question

2010-02-18 Thread Timothy Pratley
On 19 February 2010 13:35, sim wrote: > Yes there are other alternatives, but consider this. > > (doseq [url urls] >  (let [agt (http-agent url)] >    (send-off agt some-action))) Ok I understand better where you are coming from now... you want some-action to occur after http-agent tasks have run

Re: http-agent usage in subsequent agent action question

2010-02-18 Thread Timothy Pratley
On 18 February 2010 23:12, sim wrote: > I have been using http-agents to grab a bunch of pages and then > process them, my initial solutions involved partitioning a sequence of > urls and then awaiting for that group before moving on. Consider this alternative: (use 'clojure.contrib.duck-streams

Re: :strs and :syms directives

2010-02-17 Thread Timothy Pratley
On 17 February 2010 22:24, metaperl wrote: > Hi, the ref manual introduces :keys > which I understand. It then says: > > """There are similar :strs and :syms directives for matching string > and symbol keys.""" > > but no example is given. Could someone supply an

Re: can the :test metadata be used to constrain the range of a variable?

2010-02-17 Thread Timothy Pratley
On 17 February 2010 21:53, metaperl wrote: > > I tried to use :test to constrain the range of a variable, but it > didnt seem to work. Am I misunderstanding the purpose of this keyword? What you want is set-validator! :test can be used to store a unit test (typically for a function) but you shou

Re: since a list of chars is not a string...

2010-02-17 Thread Timothy Pratley
On 17 February 2010 22:10, metaperl wrote: > So what functions exist for conversion from chars to string and vice > versa? > Strings can be passed to any function expecting a collection like map, reduce, etc. To convert chars to a string you can use (str). Most of the string/character support is

Re: into map?

2010-02-16 Thread Timothy Pratley
On 17 February 2010 13:55, Base wrote: > {  0 [ 01 2 3] , >   1 [0 1 2 3] , >   2 [0 1 2 3] } > > and want to do something like > (defn create-map [] >    (into {} (dotimes [x 2] (assoc x (range 4) (zipmap (range 3) (repeat 3 (range 4))) -- You received this message because you are subscri

Re: send-off, number of threads & processor load

2010-02-16 Thread Timothy Pratley
On 17 February 2010 06:18, Alex Ott wrote: > send-off to dispatch tasks, that stores some data into central agent. > Tasks could be long running. > Yes, all send-off are sent to one agent, that accumulate information about > different documents As Chouser pointed out, agents execute one thread at

Re: refs, agents and add-watch

2010-02-11 Thread Timothy Pratley
On 12 February 2010 10:22, MiltondSilva wrote: > (add-watch products :prodkey send-products) > (add-watch material :matkey ask-material) > (dump material products products-store) >  (loop [cnt 10] >    (map #(send % client-act) clients) >    (map #(send % manufacture) artisans) >    (if (zero? cnt

Re: small code review..

2010-02-11 Thread Timothy Pratley
On 12 February 2010 03:19, Martin Hauner wrote: > I'm mostly interested if there is anything in my code one would/should > never do that way. Looks excellent, you've aced it! I'd like to discuss switching... You wrote: (cond (empty? rolls) 0 (strike? rolls)(+ (score-strike rolls) (sc

Re: Clojure and OOP

2010-02-11 Thread Timothy Pratley
On 11 February 2010 22:46, HB wrote: > Since Clojure is a LISP dialect, does this mean that it doesn't > support OOP? You might find this article interesting: http://blog.thinkrelevance.com/2009/8/12/rifle-oriented-programming-with-clojure-2 And related: http://stackoverflow.com/questions/151785

Re: Detecting Number of Available CPU Threads

2010-02-08 Thread Timothy Pratley
On 9 February 2010 11:29, Wardrop wrote: > I'm wondering if there's anyway in Clojure, that one can detect the > number of available processoring threads (.availableProcessors (Runtime/getRuntime)) might be what you are after? -- You received this message because you are subscribed to the Googl

Re: return value of use, requires?

2010-02-06 Thread Timothy Pratley
On 2 February 2010 05:14, Raoul Duke wrote: > given keyword isn't one that is supported, > or no load target given Good point, I've updated the ticket patch to check options are valid also, so the behavior is now: user=> (use 'foo :foo :bar) java.lang.Exception: Unsupported option(s) supplied: :

Re: Parens again

2010-02-03 Thread Timothy Pratley
On 4 February 2010 03:56, CuppoJava wrote: >  1. That indentation is *extremely* important. >  2. That it's not straightforward ( relative to C-languages ). >  3. You're not expected to easily indent code manually. This is insightful and succinct advise which would be a great FAQ or pre-amble to

Re: Namespace management

2010-02-03 Thread Timothy Pratley
On 4 February 2010 03:38, Konrad Hinsen wrote: > For now, I'd like to get feedback and ideas for improvements! Hi Konrad, I like it! My initial reaction is that I will use a central dedicated ns template for convenience. One thing I've wondered about with clojure core namespaces is: (clojure.xm

Re: Request for advice on java interop namespace hunting

2010-02-03 Thread Timothy Pratley
Thanks for all the responses! > http://dishevelled.net/Generating-Clojure-import-lines-using-SLIME.html Hey that's making life TOO easy! I especially love that it has REPL lookup. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Request for advice on java interop namespace hunting

2010-02-02 Thread Timothy Pratley
Hi, I've found myself a few times in a situation where I'm banging some java code into clojure, and the java source uses import foo.* blah.* bar.* Now Clojure requires explicit class naming (which I fully support) so I end up spending a good slice of time googling "java SomeWierdClass someapi" t

Re: update-in and get-in why no default?

2010-02-02 Thread Timothy Pratley
On 2 February 2010 17:41, Meikel Brandmeyer wrote: > I would get rid of the if-let. Ah yes! Ok patch updated to: + ([m ks not-found] + (if (seq ks) + (get (reduce get m (butlast ks)) (last ks) not-found) + m))) Note that (seq ks) will throw an illegal argument exception if ks is 5 fo

Re: update-in and get-in why no default?

2010-02-02 Thread Timothy Pratley
On 2 February 2010 17:55, Richard Newman wrote: > If you view 'get-in' as an unwrapping operation, unwrapping by zero steps > should return the existing collection, no? Thanks for that description I completely agree. > Can you explain why you think the result should be nil? I was not thinking

Re: Line directive in Clojure

2010-02-02 Thread Timothy Pratley
On 2 February 2010 15:39, Praki wrote: > Does Clojure have a notion of #line directive a la C/C++? This works for me: (println "file:" *file* " line:" @(clojure.lang.Compiler/LINE)) > If there is any built-in support in Clojure for ignoring blocks > delimited by special tags, as in GHC, that wo

Re: idiomatic question about reader macro

2010-02-02 Thread Timothy Pratley
http://briancarper.net/blog/clojure-reader-macros might interest you. On 2 February 2010 19:19, A.Rost wrote: > I would like to have them available, simply because I -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: update-in and get-in why no default?

2010-02-01 Thread Timothy Pratley
On 2 February 2010 00:18, Meikel Brandmeyer wrote: > Consider this (admittedly constructed) case: > (get-in {:a {:b 1}} [:x :c] {:c :uhoh}) Excellent point! > Or to use butlast/last instead of peek/pop. I think this is the best approach. butlast/last have linear time so the overhead is small.

Re: How to Initiate Clojure Application

2010-02-01 Thread Timothy Pratley
On 1 February 2010 09:32, Wardrop wrote: > Could someone step me through the idea behind the -main function > (which I've also seen written as just "main" without the hyphen). Is "-main" special in any way, or is this just a convention that some environments select? In the past I think I've used

Re: update-in and get-in why no default?

2010-02-01 Thread Timothy Pratley
> Am 31.01.2010 um 18:29 schrieb Daniel Werner: >> If I understand this arity version of get-in correctly, won't the >> default also be used if the value stored in the nested data structure >> evaluates to something false-y? Thanks for spotting that early! On 1 February 2010 05:46, Meikel Brandm

Re: idiom question: infinite sequence as data source for many threads?

2010-01-31 Thread Timothy Pratley
On 1 February 2010 15:21, free_variation wrote: > Mind if I use it? Of course I don't mind. It is intended for your use. :) Regards, Tim. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.co

Re: idiom question: infinite sequence as data source for many threads?

2010-01-29 Thread Timothy Pratley
Below I present 'submit-future' which is similar to the existing 'future' call in that it spawns a thread to execute a task, but differs in that it will block if n submitted futures are already running, where n is the number of available processors. I think this could be quite handy for the produce

Re: return value of use, requires?

2010-01-29 Thread Timothy Pratley
>> in the repl when i (use 'foo) vs. (use :foo) they both return nil, so >> it doesn't help me know that the former is right and the latter isn't. >> i think. would it be sensible for use to return true or something more >> positive than nil if it successfully brings in a namespace? > Ok. Ticket (a

Re: update-in and get-in why no default?

2010-01-29 Thread Timothy Pratley
2010/1/30 Rich Hickey : > Patches welcome for get-in, and my fnil. Groovy! uploaded to: https://www.assembla.com/spaces/clojure/tickets/256-get-in-optional-default-value https://www.assembla.com/spaces/clojure/tickets/257-add-fnil-for-wrapping-functions-to-handle-nil Regards, Tim. -- You recei

Re: more lazy "fun"

2010-01-28 Thread Timothy Pratley
2010/1/29 Timothy Pratley : > 2010/1/29 Raoul Duke : >> (let [final-answer (and (map #(= "foo" %) ["foo" "bar"]))] >>  (if final-answer "yay" "humbug")) > > user=> (if (some (partial = "foo") ["foo" &qu

Re: more lazy "fun"

2010-01-28 Thread Timothy Pratley
2010/1/29 Raoul Duke : > (let [final-answer (and (map #(= "foo" %) ["foo" "bar"]))] >  (if final-answer "yay" "humbug")) user=> (if (some (partial = "foo") ["foo" "bar"]) "yay" "humbug") "yay" user=> (if (some (partial = "foo") ["doo" "bar"]) "yay" "humbug") "humbug" -- You received this message

Re: idiom question: infinite sequence as data source for many threads?

2010-01-28 Thread Timothy Pratley
2010/1/29 Michael Wood : >> (doseq [d data-seq] >>  (.submit clojure.lang.Agent/pooledExecutor (cast Callable #(foo d > > What's the purpose of the cast here? > > #(...) is an fn, which is Callable by definition, isn't it?  So > wouldn't that line be equivalent to: > (.submit clojure.lang.Agent

Re: idiom question: infinite sequence as data source for many threads?

2010-01-28 Thread Timothy Pratley
2010/1/28 free_variation : > I have an infinite sequence.  I'd like to have the sequence be a > source for N parallel worker threads that now and then will show up to > grab a few elements from the sequence, then go off and crunch on the > data.  The sequence should be traversed only once per execu

Re: Leiningen plugin: run

2010-01-24 Thread Timothy Pratley
2010/1/24 Eric Lavigne : >     lein run Great! Very handy 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 yo

Re: Debugging in Clojure

2010-01-24 Thread Timothy Pratley
2010/1/23 ataggart : > If the authors of of c.c.trace are > amenable, I'm inclined to add this functionality to a variant of the > c.c.logging/spy macro Great idea! -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to

Re: loss-free print/read

2010-01-22 Thread Timothy Pratley
2010/1/22 dodo : > Does clojure provide a the possibility to retrieve the data structure > that represents a function? You would need to keep a copy, which is quite easy to do. Here is one way: (def fna-ast '(fn [x] (inc x))) (def fna (eval fna-ast)) (fna 5) => 6 You could store the ast as meta-d

Re: Multimethod attribute maps

2010-01-20 Thread Timothy Pratley
2010/1/20 Jacek Generowicz : > What is the purpose of the attribute map? The attribute map is added to the meta-data of the created. Meta-data contains info which can be used at runtime or to create documentation but is not part of the object itself and does not affect equality. Specifically for d

Re: Autodoc for the masses

2010-01-20 Thread Timothy Pratley
Fantastic! Love it :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group

Re: Using Runtime.exec to copy a file to a secure server.

2010-01-19 Thread Timothy Pratley
2010/1/20 CuppoJava : > (.. Runtime getRuntime (exec "scp myfile.txt u...@server:")) > (Thread/sleep 1000) > (.. Runtime getRuntime (exec "mypassword")) This creates two separate unrelated processes. You could instead get the stream of the original process and send it the info. -- You received th

Re: Empty defstruct

2010-01-19 Thread Timothy Pratley
2010/1/20 Andreas Wenger : > (struct-map person :name "Bill") Hi Andreas, Just another option to consider: {:type :person, :name "Bill", :age 20} I'll steer clear of discussing the original question :) Regards, Tim. -- You received this message because you are subscribed to the Google Groups

Re: hash literal oddity?

2010-01-18 Thread Timothy Pratley
Here is the previous discussion about duplicate keys in arraymaps, just for reference: http://groups.google.com/group/clojure/browse_thread/thread/5a38a6b61b09e025 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: Why "recur"?

2010-01-18 Thread Timothy Pratley
2010/1/18 Alex Ott > But this will not allow to jump to outer loop from inside of inner loop... > > If you require mutual recursion, letfn might be your answer See example here: http://groups.google.com/group/clojure/browse_thread/thread/a7aad1d5b94db748 -- You received this message because you

Re: [im]mutability, threads, state and idiom

2010-01-17 Thread Timothy Pratley
2010/1/16 Simon Brooke : > general case of a cyclic directed graph. Surely there must be some > clean idiomatic way of creating a cyclic graph? I experimented with something very similar when I first encountered Clojure: http://clojure.googlegroups.com/web/funmud.clj And ended up representing the

Re: ANN: dgraph 1.0, a dependency graph library for Clojure

2010-01-14 Thread Timothy Pratley
Hi Constantine, Very interesting! I'll definitely be trying this out. To give me a head-start, are there key differences with clojure.contrib.dataflow so I can better understand? Regards, Tim. 2010/1/15 Constantine Vetoshev : > I would like to announce the release of dgraph 1.0, a dependency g

Re: NullPointerException from #'> et al.

2010-01-14 Thread Timothy Pratley
2010/1/15 C. Florian Ebeling : > I agree. It only looks inconsistent when you assume nil is treated > uniformly by these comparison function, which does not make sense. I quite often wish to compare comparable objects that are not numbers and wrote some simple operators to do that: user=> ( ( ( (

Re: Contrib Logging change

2010-01-13 Thread Timothy Pratley
Hi Alex, 2010/1/13 ataggart : > You mean dropping it from the level-specific macros such as error and > fatal?  I'm inclined to disagree; being able to access the exception > instance itself is a Good Thing. Yes. You are quite right; preserving the exception is more important. If I understand co

Re: Redis-Clojure: NoRouteToHostException

2010-01-13 Thread Timothy Pratley
2010/1/14 mudphone : > I believe it has to do with opening too many sockets on the Redis > server, rather than the total number of members in the set. Sounds possible. It would be worthwhile seeing if (redis/with-server REDIS-SPEC (dotimes [i 10] (redis/sadd "large-set" (random-value i w

Re: Bug with Clojure 1.2 REPL (aka master branch) ?

2010-01-12 Thread Timothy Pratley
2010/1/13 David Nolen : > java.lang.NoSuchMethodError: clojure.lang.RestFn.(I)V > (NO_SOURCE_FILE:0) I got this temporarily until I updated both clojure and contrib and did clean builds. Have you tried ant clean;ant ? -- You received this message because you are subscribed to the Google Groups "C

Re: Contrib Logging change

2010-01-12 Thread Timothy Pratley
My thought would be to drop exceptions from normal logging calls. 1) It wont *break* any code, it may change the log output slightly as the exception is rendered by str or format instead of by the java logging formatter. 2) I think this is least surprising. 3) The exception taking java call coul

Log4j not detected when using recent jars

2010-01-12 Thread Timothy Pratley
Hi, GOSUB raised this on IRC and I'm stumped as to the behavior, can anyone help shed some light? In order to reproduce he provided a leiningen project: http://github.com/ghoseb/test-logging Now running a REPL from those dependencies (note you can just run lein deps; lein repl I am just listing

Re: Contrib Logging change

2010-01-11 Thread Timothy Pratley
2010/1/12 Phil Hagelberg : > Attached is a patch altering the logging library to behave this way by > accepting var-args and treating the last one as a throwable if applicable. > What do you think? Do other people have the same problem I do? Excellent idea. +1 from me. -- You received this messag

Re: Strange problem when adding type to a var defined by a macro.

2010-01-09 Thread Timothy Pratley
2010/1/10 Nicolas Buduroi : > That was it, thanks a lot. Ah great. My understanding is that type meta data should go on the object not the var, but that integers for example do not support meta data as they are java objects. Only things like vectors and hash maps do. So you can not set an integer

Re: Strange problem when adding type to a var defined by a macro.

2010-01-09 Thread Timothy Pratley
Hi Nicolas, The macro works fine. The problem is that the REPL tries to print the result (which is the var you created) and the print multimethod does not know what to do with your custom type, and the default method throws an exception. user=> (defbar fuz (+ 1 1)) java.lang.ClassCastException: c

Re: Brainstorming new sequence functions

2010-01-03 Thread Timothy Pratley
2010/1/4 Tom Hicks : > All the other code is there to parallel the functionality in 'subvec'. Ah right, I see what you mean. Calling count in the two argument form will realize the entire sequence unnecessarily. Take and drop are already lazy so no need to call lazy-seq... so if you wanted to expl

Re: Brainstorming new sequence functions

2010-01-03 Thread Timothy Pratley
2010/1/4 Tom Hicks : > Comments and code review welcome Hi Tom, Some interesting additions. Regarding sub-sequence it might also be written like so: (defn subseq2 [coll start end] (take (- end start) (drop start coll))) ; (subseq2 [0 1 2 3 4] 1 3) ; = (1 2) There is a clash with core's exis

Re: update-in and get-in why no default?

2010-01-02 Thread Timothy Pratley
2010/1/2 Timothy Pratley : > user=> ((fnil-2 1 +) nil 2 3 4 5) > java.lang.ClassCastException: java.lang.Integer cannot be cast to > clojure.lang.IFn (NO_SOURCE_FILE:0) Correction, I just realized of course it doesn't work if I specify the arguments around the wrong way! I shoul

Re: update-in and get-in why no default?

2010-01-02 Thread Timothy Pratley
2010/1/2 Sean Devlin : > I don't think your version of the signature supports variadic defaults well. Hi Sean, Thanks for commenting. Just by way of clarification, taking the function as the last argument seems to work fine in my experiments. I'm sure it could be better but here what I've been u

Re: update-in and get-in why no default?

2010-01-01 Thread Timothy Pratley
On Dec 13, 1:24 am, Rich Hickey wrote: > fnil seems to me to have greater utility than patching all functions > that apply functions with default-supplying arguments. Hi Rich, To further comment on fnil, after having experimented with it a bit now, I've come to slightly prefer specifying the 'd

Re: Status of bounded search on sorted-map?

2009-12-30 Thread Timothy Pratley
2009/12/31 Rob Lachlan : > About a year and a half ago, there was some discussion about having a > function that would enable some kind of bounded search on a sorted > Does this exist, currently?  I haven't looked at the gory details of subseq and rsubseq provide efficient bounded searching. I don

Re: update-in and get-in why no default?

2009-12-30 Thread Timothy Pratley
On Dec 13, 1:24 am, Rich Hickey wrote: > fnil seems to me to have greater utility than patching all functions > that apply functions with default-supplying arguments. Neat :) I like it. > The get-in function could be enhanced, and would mirror get. Should I interpret 'could' as 'patch welcom

Re: Processing list more elegantly

2009-12-30 Thread Timothy Pratley
uctions by Chris Houser ;; http://groups.google.com/group/clojure/browse_thread/thread/3edf6e82617e18e0 ;; improved by Stuart Holloway and Rich Hickey and Mark Engelberg ;; http://groups.google.com/group/clojure/browse_thread/thread/2be768e15d2b717a ;; made backward compatible by Timothy Pratley ;; ht

Re: Processing list more elegantly

2009-12-28 Thread Timothy Pratley
I find this quite interesting because Meikel has effectively created a faster version of reductions: (defn cumulative ([accum-fn s] (rest (cumulative accum-fn 0 s))) ([accum-fn accum s] (lazy-seq (when-let [[f & r] (seq s)] (cons accum (cumulative accum-fn (accum-fn accum f)

Re: Convert arabic to roman

2009-12-26 Thread Timothy Pratley
And also from that site the Haskell version is pretty neat though somewhat esoteric! (defn digit [x y z k] (condp = k 1 [x] 2 [x x] 3 [x x x] 4 [x y] 5 [y] 6 [y x] 7 [y x x] 8 [y x x x] 9 [x z])) (defn tim-roman [n] (cond (= n 0) "" (>= n 1000) (co

Re: Convert arabic to roman

2009-12-26 Thread Timothy Pratley
Actually - the original version doesn't work: user=> (to-roman 7) "III" Is not quite right... Whereas your version gives the correct output: user=> (roman-numeral 7) "VII" Your version is very clear. It is not necessary to check if the remaining value is greater than any of the previously fou

  1   2   3   4   5   >