Re: Implementing destructuring without setting your hair on fire

2011-01-21 Thread Mark Triggs
(reduce #(assoc %1 %2 (keyword %2)) {} (mapcat vmap [:keys :strs :syms]))) -- Mark Triggs -- 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

Re: filtering with multiple predicates

2010-07-24 Thread Mark Triggs
j-g-faustus writes: > I was apparently too late. Oh well :) My apologies for pre-emptively stealing your idea :) -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Re: filtering with multiple predicates

2010-07-23 Thread Mark Triggs
ere > is a mechanism similar to (or perhaps a generalization of) composition > for that, but I couldn't find it in the API docs. > > Bill Smith > Austin, TX -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: shared state/structure and concurrency

2010-03-15 Thread Mark Triggs
s that are happening concurrently in this program never have to > write to the same places, but sometimes they do have to read from the > same places and I'm wondering if this is responsible for some of what > I'm seeing. -- Mark Triggs -- You received this message

Another `line-seq' issue

2010-03-11 Thread Mark Triggs
equence and wanting to be fully lazy, so I'm not sure of the best way of achieving both objectives. I just thought I'd raise the issue in case someone brighter than me has any good ideas :) Cheers, Mark -- Mark Triggs -- You received this message because you are subscribed to

Re: Small line-seq regression?

2009-12-14 Thread Mark Triggs
omeone please check the other functions that were >> patched similarly? > > I'll do it since I created the original patch. > > https://www.assembla.com/spaces/clojure/tickets/222 Many thanks everyone. Cheers, Mark -- Mark Triggs -- You received this message because you are

Small line-seq regression?

2009-12-13 Thread Mark Triggs
r as a lazy sequence of strings. rdr must implement java.io.BufferedReader." [#^java.io.BufferedReader rdr] (let [line (. rdr (readLine))] (when line (cons line (lazy-seq (line-seq-new rdr)) and, I think, still preserves the intention of the original change. Does tha

Re: Specified behavior of every?

2009-12-02 Thread Mark Triggs
=>(every? even? nil) > true > > user=>(every? even? []) > true > > Is this behavior the specified behavior? Can I ASSUME it is true in > my code? -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Krishnamurthi's Automata in Clojure (OutOfMemoryError)

2009-11-27 Thread Mark Triggs
out of memory: > > (machine (iterate (fn [c] (if (= c \c) \a \d)) \c)) > > Java heap space > [Thrown class java.lang.OutOfMemoryError] -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: take repeatedly alternative?

2009-11-19 Thread Mark Triggs
thout 'repeatedly'. > > Can you give us an example of how you're using 'repeatedly' with take? > regards, > -tom -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Proposal: Extend behavior of hash-map

2009-11-17 Thread Mark Triggs
ntry))) > java-map)) > > user=>(put-all (java.util.HashMap. ) {:a 1 :b 2 :c 3}) > # > > I already tried into :) -- Mark Triggs -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojur

Re: Starting swank separately and connecting to it works almost but no REPL

2009-09-05 Thread Mark Triggs
ET RET > > In the *Messages* buffer I can see this: > > Connecting to Swank on port 4005.. [2 times] > Connected. Hack and be merry! > > I can then enter slime-mode and for example eval (+ 1 2) in a buffer > and I > get as reply 3 in the echo area.

Re: Idiom for array slicing

2009-08-18 Thread Mark Triggs
st >(lazy_reduce nthnext coll > (map - indices (cons 0 indices) -- Mark Triggs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cl

Re: Idiom for array slicing

2009-08-18 Thread Mark Triggs
>> >> Is there some disadvantage with this approach that I'm not seeing? -- Mark Triggs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to c

Re: Idiom for array slicing

2009-08-17 Thread Mark Triggs
eatedly #(int-array 102400))) without blowing up the stack or throwing OutOfMemory (on my JVM). Thanks again, Mark Mark Triggs writes: > Hi all, > > Is there an idiom for what I'm doing below, or does a function already > exist? > > (let [vowels (slice "abcdefgh

Idiom for array slicing

2009-08-17 Thread Mark Triggs
m log files (calling .split on a string, then grabbing certain segments) Thanks, Mark -- Mark Triggs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojur

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Mark Triggs
An artifact of not running my code from a clean REPL before posting ;) It should just read `frames'. Cheers, Mark artg writes: > What is "group-frames"? > > --art > > On Jul 21, 12:00 am, Mark Triggs wrote: [...] >>   (defn score-game [r

Re: Uncle Bob: bowling meets Clojure

2009-07-21 Thread Mark Triggs
(take 10 (group-frames rolls) Cheers, Mark -- Mark Triggs --~--~-~--~~~---~--~~ 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 Not

Re: Algorithm help

2009-07-17 Thread Mark Triggs
quot;ACACG" => ("ACC"), whereas the Python version returns > all the LCSes found (for the same strings => set(['ACC', 'AAC'])). I > have tried to find out why this is, but cannot identify the cause. > > On Jul 17, 12:16 am, Mark Triggs wrote: &

Re: Algorithm help

2009-07-16 Thread Mark Triggs
Hi there, I had a bit of a go at converting the Python version into Clojure and removed the need to mutate an array. Because the 'lcs' function was basically just mapping over a list of i/j pairs and accumulating the resulting matrix, it seemed like a good candidate for reduce: (defn lcs [x y]

Re: Adding type hint causes compiler error

2009-07-05 Thread Mark Triggs
Hi Phil, Part of me hopes there's a nicer way of doing this, but I was able to get it working using: (defn bi-get-pixels [#^BufferedImage bi] (let [raster (.getData bi) pixels (.getPixels raster 0 0 (.getWidth bi) (.getHeight bi) (cast (Class/forName "[I")

SLIME/elisp hack to generate import lines

2009-04-25 Thread Mark Triggs
Hi all, I just thought I'd write to share a terrible (but maybe useful!) hack for SLIME. I've written some code that sniffs around the classpath to find libraries matching some regexp, then inserts the appropriate `import' sexps into the current buffer. For example: M-x clj-import [RET] Inde

Re: Nested loops

2009-04-04 Thread Mark Triggs
Hi David, Quite a few times when I've felt the need for this sort of thing I've found that laziness comes to the rescue. Would something like this sort of approach work for you? (defn possibilities [word pos] "All variations of `word' with letters from 'a' to 'z' inserted at `pos'" (let [[b

Re: Quick slime/emacs questions

2009-03-29 Thread Mark Triggs
Something like this in your ~/.emacs might do the job: (define-key global-map (kbd "C-x C-b") (lambda () (interactive) (select-window (call-interactively 'list-buffers Cheers, Mark On Mar 30, 7:41 am, Mark Engelberg wrote: > When I have two windows open, and hit C-x-C-b, it

Re: Calling `str' on a LazySeq

2009-03-22 Thread Mark Triggs
Hi David, On Mar 22, 5:01 pm, David Sletten wrote: > On Mar 21, 2009, at 1:44 PM, Mark Triggs wrote: > > >   user=> (str (filter even? (range 1 10))) > >   "clojure.lang.lazy...@f1005" > > > Previously this would readably print the contents of the seq and

Calling `str' on a LazySeq

2009-03-21 Thread Mark Triggs
Hi all, Moving my existing code across to the new lazy trunk, I noticed a very small change: user=> (str (filter even? (range 1 10))) "clojure.lang.lazy...@f1005" Previously this would readably print the contents of the seq and some of my code was relying on this. Obviously it's not diffic

Re: doall vs. dorun

2009-01-20 Thread Mark Triggs
In addition to what others have said, I also tend to use doall when working with agent actions that return sequences (i.e. to force any computation to happen in the agent's thread and not in the caller's) Cheers, Mark On Wed, Jan 21, 2009 at 7:32 AM, Mark Volkmann wrote: > > Can someone descri

Re: java.lang.IncompatibleClassChangeError: [class] and [inner class] disagree on InnerClasses attribute

2009-01-13 Thread Mark Triggs
Aha! I notice that this problem goes away if I run the JVM the way I'm supposed to (with -cp lucene-core.xxx.jar) instead of using (add- classpath ...) to load the jar in the first place. This probably isn't a big deal, then :o) Thanks, Mark On Jan 13, 11:06 am, Mark Triggs wrote

java.lang.IncompatibleClassChangeError: [class] and [inner class] disagree on InnerClasses attribute

2009-01-12 Thread Mark Triggs
Hi all, I've just been fiddling with Lucene indexing from Clojure, and wanted to access a static field of this inner class: http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/index/IndexWriter.MaxFieldLength.html I'm importing IndexWriter$MaxFieldLength with no problems, but attempts

Re: what does -> mean?

2009-01-11 Thread Mark Triggs
I've also found this useful for accessing members in nested maps. For example: (let [me {:person {:name {:first "Mark" :last "Triggs"} :email "mark.h.tri...@gmail.com"}}] (-> me :person :name :first)) => "Mark" On Jan 12, 1:04 pm, kkw w

Re: Memory usage when iterating over lazy sequences

2008-10-31 Thread Mark Triggs
On Oct 31, 1:57 pm, Mark Triggs <[EMAIL PROTECTED]> wrote: > When I ran my code it very quickly ran out of memory and fell over. > After thinking about it for a while I've realised it must be because my > 'do-something' function call is hanging on to the head of

Memory usage when iterating over lazy sequences

2008-10-31 Thread Mark Triggs
my diagnosis is right, is there some sort of idiomatic way of dealing with this sort of issue? I suppose that if the JVM allowed for true tail recursion then this problem wouldn't arise? Many thanks, Mark -- Mark Triggs <[EMAIL PROTECTED]> --~--~-~--~~~--