Re: Clojure at JavaOne

2009-05-22 Thread Brian Doyle
I have a one pagish program that you pass in your screen resolution and it randomly picks out a new desktop image from ftp.gnome.org, downloads the image and updates your desktop. This assumes your using Gnome. http://github.com/heyZeus/clojure-stuff/blob/0c81123fcb3dc4bafa0df94b6e32dc49729595d3/

Re: HTTP clients in clojure

2009-05-06 Thread Brian Doyle
I wrote clj-web-crawler which wraps the Apache commons client library and made it suck a little bit less. I haven't tested it out with the Clojure 1.0 release just yet, but I'll do that tonight. http://github.com/heyZeus/clj-web-crawler/tree/master On Wed, May 6, 2009 at 7:16 PM, Chris Dean wr

Clojure Library

2009-04-20 Thread Brian Doyle
I posted this a couple of weeks ago and haven't seen it updated on the clojure website. Maybe it got lost in the shuffle. Name: clj-web-crawler URL: http://github.com/heyZeus/clj-web-crawler/tree/master Author: Brian Doyle Categories: Web, Automation License: MIT Dependencies: clojure, cl

Re: Got a Clojure library?

2009-04-09 Thread Brian Doyle
Name: clj-web-crawler URL: http://github.com/heyZeus/clj-web-crawler/tree/master Author: Brian Doyle Categories: Web, Automation License: MIT Dependencies: clojure, clojure-contrib, Apache commons-client 3.1 Description: clj-web-crawler is a wrapper around the Apache commons-client Java library

Re: [ANN] clojuredev 0.0.30 released

2009-04-05 Thread Brian Doyle
If I wanted to download and play with clojuredev where would I find it? On Sat, Apr 4, 2009 at 3:58 PM, Laurent PETIT wrote: > > New release, with a lot of changes! > > I would particularly like to thank Stephan Mühlstrasser for his > contributions ! > The clojure symbols omni-completion feature

Re: advice needed converting large files to xml

2009-03-16 Thread Brian Doyle
On Mon, Mar 16, 2009 at 4:29 PM, Mark Volkmann wrote: > > On Mon, Mar 16, 2009 at 4:56 PM, Brian Doyle > wrote: > > I've been using Clojure for about 6 months now and really like it. I am > > somewhat new to multi-threading > > and using any of the parallel feat

Re: advice needed converting large files to xml

2009-03-16 Thread Brian Doyle
ne ; process line ; write line ) ["input-file1", "input-file2", "input-file3", ]) Thanks. > > > On Mon, Mar 16, 2009 at 5:56 PM, Brian Doyle wrote: > >> I've been using Clojure for

advice needed converting large files to xml

2009-03-16 Thread Brian Doyle
I've been using Clojure for about 6 months now and really like it. I am somewhat new to multi-threading and using any of the parallel features in Clojure though. I have a situation where I need to convert 7 files from CSV to XML. Each one of these files is about 180MB apiece in size. I have d

clj-web-crawler

2009-03-09 Thread Brian Doyle
I wrote a Clojure script that wraps the Apache commons-client library for crawling the web. It's a simple 125 line script and I also wrote some test cases for it as well. I was wondering if this is something that could/should be included in clojure.contrib or if it should be a standalone Clojure

Re: sequences from Enumerations

2009-03-02 Thread Brian Doyle
That makes sense now. Thanks for the link to the thread. On Mon, Mar 2, 2009 at 5:01 PM, Stephen C. Gilardi wrote: > > On Mar 2, 2009, at 6:37 PM, Brian Doyle wrote: > > I had the same issue and ended up having to use enumeration-seq function. >> Seems >> strange b

Re: sequences from Enumerations

2009-03-02 Thread Brian Doyle
I had the same issue and ended up having to use enumeration-seq function. Seems strange but it worked. On Mon, Mar 2, 2009 at 4:22 PM, Mark Volkmann wrote: > > Should I be able to do something like this? > > (doseq [table-column (-> jtable .getColumnModel .getColumns)] > > javax.swing.JTable has

Re: Importing lots of Java classes at once

2009-02-24 Thread Brian Doyle
I wrote something similar to what you are asking about. My code does not import java class files but calls 'use' on clojure files that live in the clojure-contrib.jar file. I load this when I start the REPL only. (defn name-to-symbol [lib-name] "Converts the lib-name to a symbol" (-> lib

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread Brian Doyle
>From the original question it looked like there was a vector of unknown length of vectors [[a0 a1 a2] [b0 b1 b2] ...] So my solution is something like: 1:12 user=> (def vecs [[:a0 :a1 :a2] [:b0 :b1 :b2]]) #'user/vecs 1:13 user=> (partition (count vecs) (interleave (flatten vecs))) ((:a0 :a1) (:

Re: why fn key doesn't do what I want?

2009-02-14 Thread Brian Doyle
On Sat, Feb 14, 2009 at 2:24 PM, wubbie wrote: > > Hi, > > a quick question: > > user=> (keys {:a 1 :b 2}) > (:a :b) > > But > user=> (key {:a 1}) > java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot > be cast to java.util.Map$Entry (NO_SOURCE_FILE:0) > > I see defn key in core.

Re: Denver/Boulder Clojure users

2009-02-05 Thread Brian Doyle
I live in southeast Denver and have been doing some Clojure on my own for a few months now. On Thu, Feb 5, 2009 at 12:39 PM, chris wrote: > > Are there any existing clojure users in the Denver/Boulder area (other > than me)?. > > Chris > > > --~--~-~--~~~---~--~~

Re: symbols, vars and namespaces

2009-01-27 Thread Brian Doyle
On Tue, Jan 27, 2009 at 7:43 AM, Chouser wrote: > > On Tue, Jan 27, 2009 at 8:51 AM, Mark Volkmann > wrote: > > > > Are these statements correct? Actually, I know some are correct > > because I just looked though the source. Hopefully others that haven't > > will find this interesting. > > > > S

Re: *1 *2 isn't working properly

2009-01-14 Thread Brian Doyle
Here's an example of *1 *2 *3 1:1 user=> (str "gavin") "gavin" 1:2 user=> (str "teri") "teri" 1:3 user=> (str "brian") "brian" 1:4 user=> (str-join " " [*1 *2 *3]) "brian teri gavin" On Wed, Jan 14, 2009 at 2:29 AM, Stephen C. Gilardi wrote: > > By the time you evaluated *2, the second most rec

Re: How to create and read from a stream of random characters?

2009-01-12 Thread Brian Doyle
Chouser's solution works well, but I found that you can end up with an empty string sometimes or never getting the maxlength that you passed in. 1:2 user=> (take 3 (seq-of-rand-strings 10)) ("ngene" "" "dwlbzndqx") I added an inc before calling the take and that clears things up. (defn seq-of-ra

Re: Setting a value inside a map of map of maps...

2009-01-11 Thread Brian Doyle
I think you can just use the update-in function like: 1:1 user=> (def m {:a {:b {:c {:d 3) #'user/m 1:2 user=> (update-in m [:a :b :c :d] - 5) {:a {:b {:c {:d -2 On Sun, Jan 11, 2009 at 11:08 AM, CuppoJava wrote: > > Hi, > I'm just wondering if there's a clever way of creating a new ma

Re: How can I find all files ending with .clj, for example

2009-01-08 Thread Brian Doyle
This works: (filter #(re-find #"\.clj$" (str %)) (file-seq(java.io.File. "."))) On Thu, Jan 8, 2009 at 7:16 PM, wubbie wrote: > > I tried > > (filter #(re-find #"\.clj$" %) (seq (file-seq(java.io.File. "." > -> java.lang.ClassCastException: java.io.File cannot be cast to > java.lang.CharSe

Re: How can I find all files ending with .clj, for example

2009-01-08 Thread Brian Doyle
Here's one of many ways to do this: (filter #(.endsWith (.getName %1) ".clj" ) (file-seq (java.io.File. "."))) On Thu, Jan 8, 2009 at 5:48 PM, wubbie wrote: > > Hi all, > > I can use file-seq > (file-seq (File. ".")) > But how can I filter out all files ending with .clj? > Do we use re-find, r

Re: writing bytes to a file

2009-01-08 Thread Brian Doyle
On Thu, Jan 8, 2009 at 12:36 PM, Brian Doyle wrote: > > > On Thu, Jan 8, 2009 at 11:34 AM, James Reeves > wrote: > >> >> On Jan 8, 5:05 pm, "Brian Doyle" wrote: >> > I incorporated most of James ideas but I don't like the name >> pipe

Re: writing bytes to a file

2009-01-08 Thread Brian Doyle
On Thu, Jan 8, 2009 at 11:34 AM, James Reeves wrote: > > On Jan 8, 5:05 pm, "Brian Doyle" wrote: > > I incorporated most of James ideas but I don't like the name pipe-stream. > > Then wouldn't copy-stream be better? write-stream isn't specific > e

Re: writing bytes to a file

2009-01-08 Thread Brian Doyle
istream #^String filename] (write-stream-to-file istream filename 4096))) On Thu, Jan 8, 2009 at 2:28 AM, James Reeves wrote: > > On Jan 7, 7:14 pm, "Brian Doyle" wrote: > >(defn write-bytes > > "Writes the bytes from the in-stream to the given fil

Re: writing bytes to a file

2009-01-07 Thread Brian Doyle
Looks like spit is for printing just text. On Wed, Jan 7, 2009 at 12:20 PM, Paul Barry wrote: > clojure.contrib.duck_streams/spit? > > > On Wed, Jan 7, 2009 at 2:14 PM, Brian Doyle wrote: > >> I couldn't find anything in core or contrib that wrote out >> bytes t

writing bytes to a file

2009-01-07 Thread Brian Doyle
I couldn't find anything in core or contrib that wrote out bytes to a file so I wrote something to do it. Is this functionality already implemented and I just couldn't find it? If there isn't anything already, would this be something good to put in contrib somewhere? Thanks. (defn write-by

Re: Very noob file reading and printing question

2009-01-06 Thread Brian Doyle
On Tue, Jan 6, 2009 at 4:47 PM, Tom Ayerst wrote: > Its not the println, nor getting a reader (duckstreams is fine, I can do > that). Its the converting it to a seq and stepping through it printing each > element (which should be a line). Its the loopy, steppy bit, just for a side > effect; that

Re: Some code review for clj-record?

2009-01-04 Thread Brian Doyle
iveRecord model. On Sun, Jan 4, 2009 at 2:22 PM, Brian Doyle wrote: > Looks good. I didn't know about the *file* var. > > On Sun, Jan 4, 2009 at 11:22 AM, John D. Hume wrote: > >> >> Brian, >> I incorporated your changes and then made changes to load and run all

finding all vars starting with *

2009-01-04 Thread Brian Doyle
Today I found out about the var *file*. I looked it up *file* on clojure.com/api and couldn't find anything. Is there some place where all of these vars are defined? Is there some way programatically I can find them all? Thanks. --~--~-~--~~~---~--~~ You receive

Re: Some code review for clj-record?

2009-01-04 Thread Brian Doyle
Looks good. I didn't know about the *file* var. On Sun, Jan 4, 2009 at 11:22 AM, John D. Hume wrote: > > Brian, > I incorporated your changes and then made changes to load and run all > clj_record/test/*-test.clj files. Thanks again. > -hume. > > > > --~--~-~--~~~---

Re: Some code review for clj-record?

2009-01-02 Thread Brian Doyle
espace was just misspelled. On Wed, Dec 31, 2008 at 9:39 AM, John D. Hume wrote: > > Hi Brian, > > On Tue, Dec 30, 2008 at 11:41 AM, Brian Doyle > wrote: > > (ns com.example.user) > > (clj-record.core/init-model) > > > > but when I do that I get the error: &

Re: Understanding how to use namespaces

2008-12-30 Thread Brian Doyle
On Tue, Dec 30, 2008 at 11:25 PM, Mark Engelberg wrote: > > Thanks, that helps dramatically. It took me a while to figure out how > to edit the SLIME startup to include my clojure files directory in the > classpath, but I got it working. > > So it seems like you have to make sure the namespace al

Re: Some code review for clj-record?

2008-12-30 Thread Brian Doyle
On Mon, Dec 29, 2008 at 10:20 PM, John D. Hume wrote: > > On Mon, Dec 29, 2008 at 7:15 PM, Brian Doyle > wrote: > > I noticed that in the init-model macro you are creating a 'defn table [] > > ...' function in the > > model namespace and was wondering why you

Re: Some code review for clj-record?

2008-12-29 Thread Brian Doyle
Hume > wrote: > > The db configuration isn't reasonable at the moment. You can run > > clj_record/test/main.clj as a script but not load it from the REPL. > > Let me see if I can get it to work both ways and push an update. > > > > On Sun, Dec 28, 2008 at 6:2

Re: making code readable

2008-12-29 Thread Brian Doyle
Looking at this code the uppercase variables stands out. This isn't idiomatic is it? (def GRID_SIZE 10) (def HEIGHT 600) (def MARGIN 50) On Mon, Dec 29, 2008 at 12:19 PM, Mark Volkmann wrote: > > On Mon, Dec 29, 2008 at 11:11 AM, lpetit wrote: > > > > You should consider using docstrings for d

Re: Some code review for clj-record?

2008-12-28 Thread Brian Doyle
Having used Rails myself I wanted to check this out and play with it. I'm having some trouble just loading the clj_record/core.clj file though: 1:1 user=> (load-file "clj_record/core.clj") java.lang.Exception: Unable to resolve symbol: db in this context (core.clj:19) I'm sure it's something I'

ns references clarification

2008-12-22 Thread Brian Doyle
It would appear that using (:import ...) and (import ...) with the ns function work the same (svn rev 1172.) 1:1 user=> (ns blah (import (java.net URL))) nil 1:2 blah=> (URL. "http://www.clojure.org";) #http://www.clojure.org> and 1:1 user=> (ns blah2 (:import (java.net URL))) nil 1:2 blah2=> (U

Re: Exercise: how to print multiplication table?

2008-12-22 Thread Brian Doyle
2008/12/22 J. McConnell > On Mon, Dec 22, 2008 at 10:23 AM, Piotr 'Qertoip' Włodarek > wrote: > > > > Being new to Clojure, to Lisp and to functional programming in > > general, I have some trouble wraping my head around it. > > > > As the first exercice, I would like to print multiplication tab

Re: How to encapsulate local state in closures

2008-12-21 Thread Brian Doyle
I haven't been following the new atom stuff, so I was wondering why atom would be best in this situation, vs a ref? Thanks. On Sun, Dec 21, 2008 at 1:03 PM, Parth Malwankar wrote: > > > > On Dec 21, 11:47 pm, chris wrote: > > I would like to be able to encapsulate local state in a closure. > >

Re: multiple sets on one item - is this a good idea?

2008-12-20 Thread Brian Doyle
Instead of require call use and should get you what you want. On Dec 20, 2008 9:15 AM, "chris" wrote: That helped, thanks Christophe. I have one more problem: I put it in a util file, under a util namespace: (ns lambinator.util) (defmacro sets! [vars & rest] `(do ~@(map (fn [flds] `(set! (.

Re: for FAQ: what are use/require/import/refer?

2008-12-20 Thread Brian Doyle
This would make an excellent FAQ question and answer! On Sat, Dec 20, 2008 at 9:53 AM, Stuart Sierra wrote: > > This might make a good FAQ question: > > On Dec 20, 11:25 am, chris wrote: > > I am unclear as to the difference between refer, import use, and require. > > Hi Chris, > > require: Load

Re: running Gorilla

2008-12-18 Thread Brian Doyle
LocalLeader usually means \ On Thu, Dec 18, 2008 at 3:36 PM, Mark Volkmann wrote: > > On Thu, Dec 18, 2008 at 4:10 PM, Meikel Brandmeyer wrote: > > Hi, > > > > Am 18.12.2008 um 23:06 schrieb Mark Volkmann: > >> > >> Error detected while processing /Users/Mark/.vim/plugin/gorilla.vim: > >> line

Re: doall and dorun

2008-12-15 Thread Brian Doyle
I'll take a crack at this. It may appear that the doall and dorun return something different with subsequent calls but they don't actually. The doall always returns the sequence (1 2) and dorun always returns nil. The first time (doall x) is called the for loop executes and prints 1 2 (a side e

Re: understanding quoting

2008-12-15 Thread Brian Doyle
On Mon, Dec 15, 2008 at 9:43 PM, Daniel Eklund wrote: > > > Looks like an if then else version of the map lookup?? > > ie: (if (%1 %2) (%1 %2) %3) > > Is this a special feature of maps in general, such that you can look > > up a key but return something else if it doesn't exist? > > I hadn't come

Re: possible bug with seq and Enumeration?

2008-12-15 Thread Brian Doyle
Using enumeration-seq does the trick! Thanks. user=> (enumeration-seq (.entries (java.util.zip.ZipFile. ""))) On Mon, Dec 15, 2008 at 5:14 PM, Rich Hickey wrote: > > > > On Dec 15, 6:01 pm, "Brian Doyle" wrote: > > According to the docs t

possible bug with seq and Enumeration?

2008-12-15 Thread Brian Doyle
According to the docs the seq function should be able to take an enumeration, but here is what I see: user=> (seq (.elements (doto (java.util.Vector.) (.add "hello") (.add "world" java.lang.IllegalArgumentException: Don't know how to create ISeq from: (NO_SOURCE_FILE:0) SVN 1160, thanks. --

Re: calling use with a seq of strings

2008-12-15 Thread Brian Doyle
p symbol (list "clojure.contrib.str-utils" > "clojure.contrib.duck-streams"))) > -Stuart Sierra > > On Dec 15, 3:51 pm, "Brian Doyle" wrote: > > I have a seq of strings that are namespaces like, > > ("clojure.contrib.str-utils", "clojure.contri

calling use with a seq of strings

2008-12-15 Thread Brian Doyle
I have a seq of strings that are namespaces like, ("clojure.contrib.str-utils", "clojure.contrib.duck-streams"). I wanted to call the use function on this seq. I can't seem to do that though. Any way I can do this or is this just a bad idea? Thanks. --~--~-~--~~~-

Re: Updated 'show' and 'source'

2008-12-15 Thread Brian Doyle
This is great stuff. Thanks Chouser! On Fri, Dec 12, 2008 at 10:37 PM, Chouser wrote: > > I've added updated versions of 'show' and 'source' to a new lib named > clojure.contrib.repl-utils > > 'show' is for exploring classes at the REPL. What's new is that it > now displays the modifiers of th

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Brian Doyle
Thanks Meikel, removing the ~'s worked. Oh and thanks for vimclojure and gorilla! On Sat, Dec 13, 2008 at 9:28 AM, Meikel Brandmeyer wrote: > Hi, > > Am 13.12.2008 um 17:17 schrieb Brian Doyle: > > Here is my script: >> >> java -cp >> ~/share/clojure.j

Re: Gorilla: Release of Version 1.1.0

2008-12-13 Thread Brian Doyle
I'm sure I'm doing something stupid but I can't start up gorilla. Exception in thread "main" java.lang.NoClassDefFoundError: de/kotka/gorilla Caused by: java.lang.ClassNotFoundException: de.kotka.gorilla at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessContr

Re: Java interop question

2008-12-11 Thread Brian Doyle
This article has a good example using the proxy function. http://gnuvince.wordpress.com/2008/11/18/fetching-web-comics-with-clojure-part-2/ On Thu, Dec 11, 2008 at 1:22 PM, Randall R Schulz wrote: > > On Thursday 11 December 2008 11:31, Mark Engelberg wrote: > > I understand how Clojure lets yo

Re: why can't I set! stuff in user.clj?

2008-12-09 Thread Brian Doyle
Steve, Could you post your bash shell script that starts Clojure? I would like to see what you have concerning the new options that can be passed to the updated clojure.jar. Thanks. On Tue, Dec 9, 2008 at 1:59 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote: > user.clj is loaded before threa

Re: why can't I set! stuff in user.clj?

2008-12-09 Thread Brian Doyle
Stuart, I have a ~/.cljrc file that has this stuff in there and in my bash (clj) script to start clojure I do: $JAVA -cp $CLOJURE_JARS clojure.lang.Repl ~/.cljrc On Tue, Dec 9, 2008 at 1:12 PM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > Why can't I call set! in user.clj? (And what is the idi

unsupported binding form for cond-let

2008-12-05 Thread Brian Doyle
I started to play with cond-let in the contrib.cond package and got an unexpected error: user=> (cond-let [x (zero? 0)] (println "hello world")) java.lang.Exception: Unsupported binding form: (zero? 0) (NO_SOURCE_FILE:11) user=> (cond-let x (zero? 0) (println "hello world")) hello world Maybe it

Re: Bug: recur won't work in tail position within cond

2008-12-03 Thread Brian Doyle
This seems to work for me: (defn sub-til-0 [n] (cond (zero? n) 0 :else (recur (dec 1 I'm not sure what those extra ['s are for in your example. On Wed, Dec 3, 2008 at 9:39 PM, puzzler <[EMAIL PROTECTED]> wrote: > > (defn sub-til-0 [n] > (if (zero? n) 0 (recur (dec 1 > >

Re: A try on condp (was: Re: proposal: match multimethod)

2008-12-03 Thread Brian Doyle
Can you include an example usage of this function? Thanks. On Wed, Dec 3, 2008 at 12:51 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hi Stuart and Rich, > > Am 03.12.2008 um 19:00 schrieb Stuart Sierra: > >> I'm pretty sure I don't like the sound of that at all. We had a nice >>> discussio

Re: randomize a collection?

2008-12-02 Thread Brian Doyle
4f?lnk=gst&q=shuffle#0e19ab338452c64f > The recommendation was to use java.util.Collections/shuffle and an > example was given: > > (defn shuffle [coll] > (let [l (java.util.ArrayList. coll)] >(java.util.Collections/shuffle l) >(seq l))) > > user=> (shuffle [1

randomize a collection?

2008-12-01 Thread Brian Doyle
Is there a function that takes a collection and randomizes, or shuffles, the items? --~--~-~--~~~---~--~~ 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 To uns

Re: Newbie: Flattening any collection

2008-11-30 Thread Brian Doyle
As long as you have the clojure.contrib jar in your path you can do: (use 'clojure.contrib.seq-utils) (flatten [1 2 3 '(4 5 6)]) => (1 2 3 4 5 6) On Sun, Nov 30, 2008 at 9:36 PM, samppi <[EMAIL PROTECTED]> wrote: > > For any given collection [3 2 [3 5 1] 1 [3 4 1] 0], how may I get [3 2 > 3 5 1

Re: update a ref struct

2008-11-24 Thread Brian Doyle
Yep, that's just a typo in the email. Something was wrong with my browser and I couldn't just paste the code in :( On Mon, Nov 24, 2008 at 3:33 PM, Shawn Hoover <[EMAIL PROTECTED]>wrote: > On Mon, Nov 24, 2008 at 5:17 PM, Brian Doyle <[EMAIL PROTECTED]>wrote: > &

Re: update a ref struct

2008-11-24 Thread Brian Doyle
ink about > using reduce to walk the line-seq. the nature of reduce lets you have > access to the line-seq, two lines at a time no need for a ref. > > On Mon, Nov 24, 2008 at 2:17 PM, Brian Doyle <[EMAIL PROTECTED]> > wrote: > > I am parsing a file and to compare the cu

update a ref struct

2008-11-24 Thread Brian Doyle
I am parsing a file and to compare the current line with the previous line of the file. I am using line-seq to go thru the file and I thought I would create a ref to store the previous line. When I want to update the previous line value I can't seem to do it. I've never used refs before so I'm

Re: offtopic - where are you come from? (poll)

2008-11-21 Thread Brian Doyle
Denver, CO Brian Doyle On Wed, Nov 19, 2008 at 4:09 AM, liu chang <[EMAIL PROTECTED]> wrote: > > Singapore +1. > > On Wed, Nov 19, 2008 at 5:24 PM, walterc <[EMAIL PROTECTED]> wrote: > > > > taipei, taiwan

Re: (Newbie) simple tack

2008-11-19 Thread Brian Doyle
I like this solution as well. You have to pull in the seq-utils for the indexed function though. (use 'clojure.contrib.seq-utils) (defn nonzero-idxs [s] (for [[i n] (indexed s) :when (and n (not (zero? n)))] i)) On Wed, Nov 19, 2008 at 10:39 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > >

Re: Getting a flat sequence from a map (and vice versa)

2008-11-14 Thread Brian Doyle
Another way to create a map is: user=> (apply hash-map [:a 1 :b 2 :c 3]) {:a 1, :c 3, :b 2} On Fri, Nov 14, 2008 at 9:42 PM, samppi <[EMAIL PROTECTED]> wrote: > > Excellent! I must remember about the apply function. Thank you very > much. > > On Nov 14, 9:35 pm, "Kevin Downey" <[EMAIL PROTECTED

Re: multi-method dispatch for structs

2008-11-14 Thread Brian Doyle
I wonder if it would good to have something indicating the struct name put in the metadata when creating a struct? On Fri, Nov 14, 2008 at 1:42 PM, Chouser <[EMAIL PROTECTED]> wrote: > > On Fri, Nov 14, 2008 at 2:11 PM, Jeff Rose <[EMAIL PROTECTED]> wrote: > > Does my dispatch function have to in

Re: chunk-file function

2008-11-12 Thread Brian Doyle
I did try the line-seq and it didn't run out of memory and I used a surrounding with-open and it works great now. Thanks Stephen! On Wed, Nov 12, 2008 at 4:14 PM, Brian Doyle <[EMAIL PROTECTED]> wrote: > In your example using line-seq, should really surround it with the > with

Re: chunk-file function

2008-11-12 Thread Brian Doyle
In your example using line-seq, should really surround it with the with-open function so that it will close the reader? Thanks. On Wed, Nov 12, 2008 at 4:02 PM, Stephen C. Gilardi <[EMAIL PROTECTED]>wrote: > > > On Nov 12, 2008, at 5:20 PM, Brian Doyle wrote: > > > It

chunk-file function

2008-11-12 Thread Brian Doyle
I had to process each line of a very large file, 120MB, and did not want to read in the whole file at once. I wrote this function, chunk-file, that allows me to pass in a function and args that will process each line. It works great for me, but hoping to get any feedback about coding style or the

Re: (string?) bug

2008-11-11 Thread Brian Doyle
Yep, I'm going that route. Thanks On Tue, Nov 11, 2008 at 2:27 PM, Dave Newton <[EMAIL PROTECTED]> wrote: > > --- On Sun, 11/9/08, Brian Doyle wrote: > > Yes, it is a StringBuilder so technically yes. I guess you > > since the only thing you ever do with

Re: (string?) bug

2008-11-09 Thread Brian Doyle
if this is a repeat; hotel networking is sketchy.) > > On Nov 9, 12:07 am, "Brian Doyle" <[EMAIL PROTECTED]> wrote: > > This seems like a bug returning false for StringBuilder. > > > > user=> (string? (new java.lang.String "hello")) >

(string?) bug

2008-11-08 Thread Brian Doyle
This seems like a bug returning false for StringBuilder. user=> (string? (new java.lang.String "hello")) true user=> (string? (new java.lang.StringBuilder "hello")) false --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Grou

slurp accepting an encoding parameter

2008-11-07 Thread Brian Doyle
I had a file that was not encoded using the default file encoding so I modified slurp to accept an optional encoding parameter. (defn slurp "Reads the file named by f into a string and returns it. Uses the given encoding when opening the file." ([#^String f encoding] (with-open r (if enc

Re: lancet: Clojure controlling Ant

2008-11-06 Thread Brian Doyle
On Thu, Nov 6, 2008 at 11:48 AM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > Hi all, > > I am playing around with using Clojure to control Ant, something along > the lines of Groovy's Gant. I don't know how far I will take this-- > right now it is serving as a code example for the book. > > Two

Clojure Maven integration

2008-11-06 Thread Brian Doyle
Does anyone know of any Clojure maven integration? What I'd like to see is something that will modify Clojure's classpath updated based upon a given pom.xml file. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: offtopic - where are you come from? (poll)

2008-10-17 Thread Brian Doyle
Denver, CO USA On Fri, Oct 17, 2008 at 3:27 AM, Rastislav Kassak <[EMAIL PROTECTED]>wrote: > > Hello Clojurians, > > I think after 1st year of Clojure life it's good to check how far has > Clojure spread all over the world. > > So wherever are you come from, be proud and say it. > > I'm from Slov

Re: max

2008-10-16 Thread Brian Doyle
The complement would work in terms of "opposite" of filter like: (filter (complement nil?) [1 2 nil]) -> (1 2) but I like remove since it is a bit more clear and less typing. On Thu, Oct 16, 2008 at 2:57 PM, Paul Stadig <[EMAIL PROTECTED]> wrote: > More options: I was browsing through the docs

Re: remainder function

2008-10-15 Thread Brian Doyle
The function is 'rem'. user=> (rem 5 2) 1 On Wed, Oct 15, 2008 at 3:35 PM, Islon <[EMAIL PROTECTED]> wrote: > Is there a remainder (rest of the division) function in closure? (as java > '%' operator). > I browse the docs but couldn't find one. > > > > --~--~-~--~~~-

Re: followup on struct inheritance

2008-10-09 Thread Brian Doyle
On Tue, Oct 7, 2008 at 2:57 PM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > This is a tangent from Brian's question about struct inheritance: > While I am not sure that I want struct inheritance, it seems > unnecessarily hard to write the macro for it. Structs are not first > class citizens, in

Re: equality and struct inheritance

2008-10-07 Thread Brian Doyle
On Tue, Oct 7, 2008 at 2:32 PM, Stuart Halloway <[EMAIL PROTECTED]>wrote: > > Hi Brian, > > (1) What does it mean to be equal on id and not equal on the other > fields? If two fields claim the same id but a different name, how > would you know which one to keep? I guess it could depend on the si

equality and struct inheritance

2008-10-07 Thread Brian Doyle
I'm attempting to learn Clojure with a long history of OO and have some questions.I've created a defstruct for a place type object like: (defstruct place :id :name :street :city :state :zip) I want to write a function that would take a list of places and remove the duplicates. Duplicates ar