Re: Closures and environments

2010-02-04 Thread Sean Devlin
You can take a look at the IFn, AFn & Fn files in the clojure.lang package to get a better understanding of what is going on. Sean On Feb 4, 8:33 am, Ludovic Kuty wrote: > Hello, > > I was wondering if symbol resolution in local scope (in a let or > function body) works the same

Re: Pattern Matching

2010-02-04 Thread Sean Devlin
Pattern matching On Feb 4, 12:12 pm, Jon Harrop wrote: > On Thursday 04 February 2010 14:08:44 Sean Devlin wrote: > > > Do we have a concise way of doing this?  Is it actually useful? > > >http://www.artima.com/weblogs/viewpost.jsp?thread=281160 > > Are you talking ab

Re: Full Disclojure - I Need Topics!

2010-02-04 Thread Sean Devlin
On Feb 4, 9:54 pm, Seth wrote: > Sean, > > The new installation videos look great -- I have linked to them from > my company's intranet. Any plans for an installation video for > Counterclockwise for Eclipse? > Eclipse is on the to-do list. Keep your eyes open. > I

Re: newbie question: splitting up source files

2010-02-05 Thread Sean Devlin
What development environment are you using? On Feb 5, 1:57 pm, Mike Jarmy wrote: > I'm writing a clojure program which is getting sort of large, so I'd > like to split it up into separate source files.  However, I'm having > trouble figuring out how to tell the files about each other's > existenc

Re: newbie question: splitting up source files

2010-02-05 Thread Sean Devlin
e: > winXP, java 1.6 > > On Fri, Feb 5, 2010 at 3:31 PM, Sean Devlin wrote: > > What development environment are you using? > > > On Feb 5, 1:57 pm, Mike Jarmy wrote: > >> I'm writing a clojure program which is getting sort of large, so I'd > >&

Re: newbie question: splitting up source files

2010-02-05 Thread Sean Devlin
?  Can you suggest what sort of diagnostic > info I can print out inside my script so clojure can tell me what it > thinks the classpath is? > > On Fri, Feb 5, 2010 at 3:46 PM, Sean Devlin wrote: > > You're running into a classpath issue.  You'll need to have both files

Re: newbie question: splitting up source files

2010-02-05 Thread Sean Devlin
, 2010, at 4:38 PM, Mike Jarmy wrote: > > >>> That yields ".;lib/clojure.jar", just as we'd expect.  I also tried, > >>> "java -cp foo.clj;foo-util.clj;lib/clojure.jar clojure.main foo.clj", > >>> but that gave the same error.  Al

Re: Parallel version of list comprehension

2010-02-08 Thread Sean Devlin
Do you have a specific example, some code you could paste? On Feb 7, 11:53 pm, Tim Snyder wrote: > Is there a straight-forward way to get parallelization when using list > comprehension? > The form of "for" syntax is much preferable to the closest I could > come up with using pmap.  I also was ha

Re: groovy builders equivalent

2010-02-08 Thread Sean Devlin
Perhaps I have an incomplete grasp of the problem domain, but wouldn't a map stored in a ref let you do this? On Feb 8, 9:12 am, Laurent PETIT wrote: > 2010/2/8 Chouser : > > > > > On Mon, Feb 8, 2010 at 5:29 AM, Laurent PETIT > > wrote: > >> Hello, > > >> Did anybody create a functionally equi

Re: scope of binding

2010-02-08 Thread Sean Devlin
The problem is that map returns a lazy seq, and the lazy seq is evaluated outside of the binding by the REPL. If you add a doall inside the binding, it behaves as you expect. user=> (binding [*v* 2] (doall (map f [1 1 1]))) (3 3 3) Sean On Feb 8, 5:47 am, Alex wrote: > Hi, > &

Re: Inheriting from IDeref - good idea or bad practise?

2010-02-08 Thread Sean Devlin
I've got no clue, so I would just do the experiment. If it works out well, tell us why. If it's a disaster, tell us what didn't work. Sean On Feb 7, 3:57 pm, James Reeves wrote: > Hi folks, > > Would those more knowledgable about Clojure care to weigh in on > w

Re: How would I write an emitter/collector?

2010-02-10 Thread Sean Devlin
than using when/if directly. Now, these are finite examples. If you wanted an infinite lazy seq, you could substitute (interate inc 1) for (range 10). Just be very careful evaluating this at a REPL. Unless I missed the point of your post entirely. Sean On Feb 10, 7:23 am, Mark Carter wrote

Re: Contributing to Clojure.Contrib

2010-02-10 Thread Sean Devlin
Take a look here: http://clojure.org/contributing On Feb 10, 6:38 pm, Wardrop wrote: > I've written a function which I think would be a good inclusion into > the Clojure.Contrib library. I have two questions though, the first is > how? How do I go about adding a single function to an existing >

Re: Request for Feedback: Improve VimClojure's documentation

2010-02-11 Thread Sean Devlin
Here are some windows friendly options: http://vimeo.com/tag:install_clojure Sean On Feb 11, 1:11 pm, e wrote: > i can echo that last reply.  I wanted to use clojure and may return to it > ... awesome idea.  But haven't had ANY luck with dev environments ... VC, > included.  

Re: First program, in case you want to give hints

2010-02-13 Thread Sean Devlin
of 2. nil otherwise" (if (= (.bitCount (big-int n)) 1) (dec (.bitLength (big-int n Also, letfn is for mutually recursive fns (you know, the kind that swear at each other :). I would move big-int, step & power-of-2 into their own defns. That should clean up your definition of co

Re: PersistentTreeMap, seqFrom, subseq and range queries

2010-02-15 Thread Sean Devlin
If you are running Java 6 you could always use java.util.NavigatibleMap/Set. However, this is a workaround, and it would be great to see Clojure support these log(N) operations directly. On Feb 15, 8:45 am, "George ." wrote: > Currently, if you want to perform a range query on a sorted-seq (AKA

Re: newbie question: Please help me stop creating constructors

2010-02-15 Thread Sean Devlin
Let's start with what you've got. Could you post some of your code on github, or something similar? That would make it easier to help you along. Sean On Feb 15, 12:24 pm, Yaron wrote: > I am writing a calculator to figure out if I should sell or rent my > home using Clojure.

Re: First program, in case you want to give hints

2010-02-16 Thread Sean Devlin
ere's no mutual recursion, so let will do the job. * Wrote the producing fn in terms of iterate, so the result is now a lazy list. Sean On Feb 16, 6:38 am, Jarkko Oranen wrote: > On Feb 16, 12:26 pm, alux wrote: > > > Hello, > > > the current state of Conway's

Re: First program, in case you want to give hints

2010-02-16 Thread Sean Devlin
Interesting... could you add a few test cases? I want to make sure my implementation does what you expect. Thanks, Sean On Feb 16, 11:18 am, alux wrote: > I'm curious, but as you told me, I pasted my solution (with a lazy > stream), as annotation of my former progra

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

2010-02-17 Thread Sean Devlin
Also, you might want to check out clojure contrib for some string stuff. str-utils2 if you're running 1.1, string if you're on edge. Sean On Feb 17, 6:10 am, metaperl wrote: > The reference manual example implies that a list of chars is not a > string: > > (let [[a b &a

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Is the long term plan to include this multi-branch behavior in the lein pluggin too? Sean On Feb 17, 3:27 am, Tom Faulhaber wrote: > The autodoc robot that builds the API docs choked sometime after the > merge of the new branch into master and the clojure and  clojure- > contrib API

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Alux, That's what the doc macro is for. Here's an example. user=> (doc +) - clojure.core/+ ([] [x] [x y] [x y & more]) Returns the sum of nums. (+) returns 0. On Feb 17, 11:17 am, alux wrote: > Very nice! > > But another beginners question: Is there any prossibility t

Re: Clojure API doc updated with both master and 1.1 (finally)

2010-02-17 Thread Sean Devlin
Tom, I was just throwing an idea out there, not very high on my to-do list either. I agree with your prioritization. If I come across a project, I'll let you know. Sean On Feb 17, 11:59 am, Tom Faulhaber wrote: > Sean, > > Maybe, but it's not very high on my current priorit

Re: "hot swapping" + swing + repl?

2010-02-17 Thread Sean Devlin
Netbeans has a good swing gui building tool. Good for prototyping & understanding the feel of your app. Not sure how well it plays w/ Clojure, though. On Feb 17, 7:49 pm, Raoul Duke wrote: > hi, > > any pointers to learn up on how to get a nice environment for doing > swing app development w/ou

Re: side effects in fn passed to filter

2010-02-18 Thread Sean Devlin
ustom form of reduce, something that returned [your-filtered-seq last-element] HTH, Sean On Feb 18, 9:04 am, Rowdy Rednose wrote: > The filter documentation reads: > > "Returns a lazy sequence of the items in coll for which (pred item) > returns true. pred must be free of side

Re: side effects in fn passed to filter

2010-02-18 Thread Sean Devlin
Well, if it's golf... (use 'clojure.contrib.seq-utils) (map first (partition-by identity [1 2 3 4 5 5 5 6])) On Feb 18, 9:34 am, Stuart Halloway wrote: > Rowdy's question asks for less than what core/distinct delivers--he   > only wanted to remove *adjacent* duplicates. > > That said, core/dist

Re: side effects in fn passed to filter

2010-02-18 Thread Sean Devlin
Rowdy, Does your profiling test do any work? There aren't any duplicates in (range 100) Perhaps you should run a few more benchmarks to get a better idea of what is going on. Sean On Feb 18, 10:34 am, Rowdy Rednose wrote: > Various interesting approaches to this problem... tha

Re: side effects in fn passed to filter

2010-02-18 Thread Sean Devlin
e have some ideas on how to perform a more rigorous experiment? Sean On Feb 18, 12:44 pm, Rowdy Rednose wrote: > Yeah, the numbers depend a bit on the data, so distinct will look > better if there are many dupes, and running tests against > > (mapcat vector (range 50) (range 50)

Re: side effects in fn passed to filter

2010-02-18 Thread Sean Devlin
Wait... what's the problem we're trying to solve? On Feb 18, 1:56 pm, Meikel Brandmeyer wrote: > Hi, > > On Thu, Feb 18, 2010 at 09:44:52AM -0800, Rowdy Rednose wrote: > > Yeah, the numbers depend a bit on the data, so distinct will look > > better if there are many dupes, and running tests again

Re: Clojure box

2010-02-18 Thread Sean Devlin
Do you need to do a lot of Java work as well? If so, take a look at Enclojure (Netbeans) or Counter Clockwise (Eclipse). On Feb 18, 4:58 pm, Zeynel wrote: > Hello, > > I am totally new to Clojure. Do you recommend using Clojure Box for > windows installation? I am not an expert user or programme

Re: Map transmogrification functions?

2010-02-21 Thread Sean Devlin
Actually, a combination of into & empty does the trick amazingly well... http://fulldisclojure.blogspot.com/2010/01/12-fn-proposal-same-multisame.html On Feb 21, 10:56 pm, Mike Meyer wrote: > In working through a recent project, I realized that Clojure has a > nice collection of functions for wo

Re: generalize distinct

2010-02-22 Thread Sean Devlin
It sounds to me that you want to use c.c.seq-utils/group-by, not distinct. On Feb 22, 7:22 am, Eugen Dueck wrote: > Yes, for the reasons stated. > > First, and most important, clojure.core/distinct does not let me pass > in a keyfn, it's hard-coded. > > Second, and as mentioned that's debatable,

Re: generalize distinct

2010-02-22 Thread Sean Devlin
What does distinct-by return in case of a collision? (keys (group-by...)) (map first (vals (group-by ...))) (map other-fn (vals (group-by ...))) You're still better off w/ group-by, and manipulating the resulting map appropriately. Sean On Feb 22, 1:15 pm, Michał Marczyk wrote:

Re: generalize distinct

2010-02-22 Thread Sean Devlin
more idiomatic Clojure. (distinct (map f coll)) Sean On Feb 22, 1:39 pm, Michał Marczyk wrote: > On 22 February 2010 19:25, Sean Devlin wrote: > > > What does distinct-by return in case of a collision? > > I'm not sure what you mean by that. distinct-by would do precisely

Re: generalize distinct

2010-02-22 Thread Sean Devlin
ondary mapping operation was the only thing that gave me the flexibility I needed (manufacturing is fun!). Sean On Feb 22, 2:19 pm, Michał Marczyk wrote: > On 22 February 2010 19:59, Sean Devlin wrote: > > > Generally when you have a "*-by" fn, you return the a sequence of > &

Re: generalize distinct

2010-02-22 Thread Sean Devlin
Excellent points. +1 for orthogonality. Sean On Feb 22, 3:13 pm, Michał Marczyk wrote: > On 22 February 2010 20:28, Sean Devlin wrote: > > > Then is the seq (1 :a a) guaranteed?  How do I know that I won't get > > (2 :b b), (1 :b c), etc?  What if I want a specific

Re: generalize distinct

2010-02-23 Thread Sean Devlin
Take a look at sort/sort-by in core. That would be starting point for fn style. On Feb 23, 12:44 pm, Michał Marczyk wrote: > On 23 February 2010 00:17, Eugen Dück wrote: > > > Rather than having a separate fn 'distinct-by' in addition to the > > existing 'distinct', which, apart from the hard-c

Re: generalize distinct

2010-02-23 Thread Sean Devlin
t. This really obvious w/ fns like juxt & partial. It turns out that this is results in faster code. So I'd implement distinct like this. (def distinct ([coll] (lots-of-code)) ([f coll] (lot-of-similar-code))) That's all I was saying. Sean On Feb 23, 2:40 pm, Michał Marczyk wrote

Re: Strange reflection warning

2010-02-24 Thread Sean Devlin
uot; How does the reader know the difference between .hashCode and .reallyObsureMethod? It would need to keep a whitelist of everything in object, and know that these methods can be called directly. Maybe the reader should be upgraded to handle this? Could be totally wrong. Sean On Feb 24, 2:

Re: Strange reflection warning

2010-02-24 Thread Sean Devlin
Konrad, Okay, I was looking in the wrong place. Which leads me to suggest the following: Create a local fork of Clojure, make a new branch, and hack on the compiler. Run the experiment, see what happens :) Sean On Feb 24, 9:15 am, Konrad Hinsen wrote: > On 24.02.2010, at 14:43, Sean Dev

Re: getting a library listed on the library page?

2010-02-24 Thread Sean Devlin
IANAL. The standard seems to be EPL 1.0, because it's what Rich uses for Clojure & Contrib. My understanding is that this causes problems w/ the GPL, so you'll probably want to stay away from that. Sean On Feb 24, 1:36 pm, "Kyle R. Burton" wrote: > Thank you!

Re: clojure.lib

2010-02-24 Thread Sean Devlin
ns, but now doesn't seem to be the right time for adding features. Hopefully there will be time for this in the future. Sean On Feb 24, 5:51 pm, cej38 wrote: > I noticed a thread on the clojure developer's google group last > night,http://groups.google.com/group/clojure-dev/browse

Re: clojure.zip - throws exception

2010-02-25 Thread Sean Devlin
Hmm... what versions of Clojure (and other libs) are you using? Sean On Feb 24, 2:59 pm, Amitava Shee wrote: > I am getting the following exception while trying to use clojure.zip > > user=> (use '[clojure.zip :as zip]) > java.lang.IllegalStateException: ne

Re: possible errors in ns documentation

2010-02-25 Thread Sean Devlin
What Clojure version are you using? On Feb 24, 4:17 pm, j1n3l0 wrote: > Hi all, > > I'm not sure if this is the right place to raise this. I am new to > clojure and was going through the docs for namespaces here: > > http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co... > > In

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Sean Devlin
github.com/francoisdevlin/devlinsf-clojure-utils/blob/master/src/lib/sfd/equations.clj Hope this helps, Sean On Feb 25, 8:59 pm, joshua-choi wrote: > Yeah, I don’t really like the underscores either. But I have to work > with the set of currently allowed non-alphanumeric s

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Sean Devlin
use to infer behavior? Examples of this include JUnit 3.8 & the get/set Java Bean convention. If it's a, I made a mistake & my comments don't apply (as a matter of taste I like suffixes). If it's the behavior version, I think that a special macro is in order (e.g. deftes

Re: Prefixed or suffixed symbols?

2010-02-25 Thread Sean Devlin
green for a fn in the standard library (e.g. clojure.walk). You'll have to make your own customizations, of course. Sean On Feb 25, 10:50 pm, joshua-choi wrote: > Ah, yes, it is a. (The only thing that I anticipate a computer would > use this for is different syntax highlighting. Actually,

Re: Are there any plans for more allowed symbol characters?

2010-03-02 Thread Sean Devlin
While certainly legal unicode, it's a PITA with most western keyboards. I don't recommend straying far from ASCII-128 w/o a great, great, reason. Of course, someone from the east may disagree. On Mar 1, 5:24 pm, Joost wrote: > On 1 mrt, 23:02, Michael Wood wrote: > > > I don't know if the foll

Re: take-to-first & partition-when

2010-03-17 Thread Sean Devlin
Hey Greg, welcome to Clojure :) You might want to take a look at c.c.seq-utils and the clojure cheat sheet. Both of these already exist. See take-while & partition-by The cheat sheet can be found here: http://clojure.org/cheatsheet On Mar 16, 11:12 pm, Greg Fodor wrote: > Just saw that I ne

Re: position/index-of function

2010-03-17 Thread Sean Devlin
You want the positions fn in c.c.seq Sean On Mar 17, 10:43 am, "John R. Williams" wrote: > I'm looking for a function along the lines of java.util.List.indexOf, > and I'm having a hard time believing it's not there in the core or at > least contrib.  I was exp

Re: Simple functional programming lexicon?

2010-03-17 Thread Sean Devlin
Here's a collection of reading material: http://news.ycombinator.com/item?id=1033503 Personally, I'd recommend Programming Clojure as a good place to start. Sean On Mar 17, 8:28 am, Ben Armstrong wrote: > I am new to clojure and functional programming, but not to programming

Re: Java method call irritation

2010-03-18 Thread Sean Devlin
And upgrade the doc macro accordingly? That would make entirely too much sense. +1 On Mar 18, 2:36 pm, Seth wrote: > Would :deprecated be a reasonable thing to include in a function's > metadata? Just the presence of it seems good enough, but I guess > pairing it with some programmer friendly m

Re: Long post with some questions about getting started...

2010-03-19 Thread Sean Devlin
general ideas. 2. Get yourself a copy of Programming Clojure by Halloway. It's very accessible, and will walk you through the basics. 3. Walk through the Clojure cheat sheet ( http://clojure.org/cheatsheet ) , and force yourself to learn how to use every function listed at the REPL at least once.

Re: Sequential vs. "divide and conquer" algorithm

2010-03-19 Thread Sean Devlin
to an FFT? In this case, is there any theoretical reason the algorithm does less work? Are you making a time/memory trade off? This would make it easier to provide suggestions. Sean On Mar 19, 12:53 pm, Andrzej wrote: > I've been toying with various implementations of reduce-like >

Re: map-filter, is this in the API?

2010-03-19 Thread Sean Devlin
Nope. (map f (filter f ...)) is currently the way to go. On Mar 19, 1:54 pm, Greg Fodor wrote: > Very simple function: > > (defn map-filter [f coll] >   (map f (filter f (coll))) > > Is there an API function for this that I am missing? For example, it > is useful for pulling out all values in a

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Sean Devlin
Luc, Windows users should be good to go. Clojurebox, Enclojure & CCW are ready for use for any Java dev with some experience. As for the installation process, pick you poison: http://vimeo.com/tag:install_clojure Sorry to self-post, Sean On Mar 22, 7:31 am, Luc Préfontaine wrote: >

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Sean Devlin
Hmm... maybe something like this? http://hackage.haskell.org/platform/ Or this? http://www.openoffice.org/ Sean On Mar 22, 12:39 pm, Lee Spector wrote: > Yes, yes and yes: The videos are great, and all of the information is out > there, but it was hard for me to find as I first wa

Re: JColorChooser

2010-03-22 Thread Sean Devlin
I think the problem is that you are try to use a static method lake an instance method. I was able to get the following to work: (import javax.swing.JColorChooser) (JColorChooser/showDialog nil "Test" java.awt.Color/BLACK) Sean On Mar 22, 4:51 pm, WoodHacker wrote: > When

Re: Why I have chosen not to employ clojure

2010-03-22 Thread Sean Devlin
There are a ton of people who are ready for dabbling with Clojure but aren't ready for production systems. You'd be surprised how linearly independent system administration skills and software development skills really are. They aren't quite orthogonal, but it's amazingly close. On Mar 22, 5:36 

Re: Why I have chosen not to employ clojure

2010-03-23 Thread Sean Devlin
f you want the > full deal, throw the f-bomb in between each word and append a piece of > profanity that ends with "suckers". You're right, videos aren't documentation. Thanks for volunteering to fill this gap. Let me know when you're ready, and I'll give you ma

The % Schemer Series - are they worth the money?

2010-03-23 Thread Sean Devlin
Hey folks, I'm looking to add to my bookshelf. I was wondering what this groups experience with the Schemer series of books is? Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Re: Why I have chosen not to employ clojure

2010-03-23 Thread Sean Devlin
Lein is a command line tool that you can use independently of your environment. 99.9% sure you won't break anything by installing it. Is this right Phil? Sean On Mar 23, 2:53 pm, Lee Spector wrote: > I like where this is going but I would suggest that there's a significan

Re: Parsing parameters in clojure.core

2010-03-24 Thread Sean Devlin
It's a (drastic) performance improvement. The magic number of 3 appears to cover a lot of use cases. Once you get larger than three, it typically is a large number of inputs, i.e. the tail flattens off. On Mar 23, 5:00 pm, Thomas wrote: > Hi all, > > I've been reading through clojure.core to se

Re: Parsing parameters in clojure.core

2010-03-25 Thread Sean Devlin
ith greater > cleverness. In the mean time, some macros might be in order. > > I'd also like to add that clojure.core is not generally an exemplar of style. > :) > > -Per > > On Wed, Mar 24, 2010 at 11:58 PM, Sean Devlin > wrote: > > It's a (drastic) p

Re: Reorder a list randomly?

2010-04-05 Thread Sean Devlin
cause I don't think it's safe in the STM. Great work guys. Sean On Apr 5, 12:52 am, Per Vognsen wrote: > On Mon, Apr 5, 2010 at 11:33 AM, Lee Spector wrote: > > > Ah -- maybe that foiled my timings too. I didn't expect it to be fast -- > > just clear (at least

Re: \< \> \= are valid in symbols?

2010-04-05 Thread Sean Devlin
"Oh yeah, we should fix the reader page to acknowledge that we've used these characters in symbols already" The reader already has a macro associated with "\", the character literal. user=> (int \>) 62 user=> (str \>) ">" user=> (first &q

Re: let's all link to the "getting started" pages!

2010-04-07 Thread Sean Devlin
Anyone have instructions for CLR? On Apr 7, 2:50 pm, Meikel Brandmeyer wrote: > Hi, > > On Wed, Apr 07, 2010 at 01:53:47PM -0400, Wilson MacGyver wrote: > > I noticed there is no section or link on using clojure with gradle. What > > can I do to help make that happen? > > Will add it. > > Sincere

Re: question about "into"

2010-04-08 Thread Sean Devlin
The REPL is you best friend whenever you have a question like this. It's often useful to execute the offending form step by step, to see what the result of each computation is. Love the REPL. Sean On Apr 7, 8:45 pm, Per Vognsen wrote: > The second case is equivalent to (into [] [{:

Re: Clojure Concurrency Screencast Available

2010-04-09 Thread Sean Devlin
Awesome. I'll have to watch these tonight :) Sean On Apr 9, 2:53 pm, Craig Andera wrote: > I've recorded a screencast on Clojure concurrency primitives. It's available > athttp://link.pluralsight.com/clojure. Thought some here might find it > useful. It's in six p

Re: Understanding lazy-seq

2010-04-13 Thread Sean Devlin
How would one write a unit test to catch this type of thing? On Apr 12, 7:53 pm, Stuart Halloway wrote: > Hi Edmund, > > This is a regression since last Tuesday's commit   > f81e612cc9ff91ddefc1d86e270cd7f018701802. Thanks for catching it! > > Stu > > > Dear Clojurians, > > >    I have been tryin

CSV Lib

2010-04-13 Thread Sean Devlin
Anyone know where to start with parsing a csv file? -- 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.

Re: CSV Lib

2010-04-13 Thread Sean Devlin
I'll be greedy... is there a known Clojure wrapper? On Apr 13, 10:27 am, Meikel Brandmeyer wrote: > Hi, > > On Apr 13, 4:25 pm, Sean Devlin wrote: > > > Anyone know where to start with parsing a csv file? > > I found OpenCSV to be useful. > > Sincerely >

Re: CSV Lib

2010-04-13 Thread Sean Devlin
Challenge Accepted. Will work on this when Rich says 1.2 is ready for beta (i.e. API freeze). Sean On Apr 13, 10:33 am, Stuart Halloway wrote: > Here's a pure Clojure one:http://github.com/davidsantiago/clojure-csv > > And here's a challenge for you: Use protocols to

Re: Forms to strings

2010-04-14 Thread Sean Devlin
user=> (str '(is this what you mean?)) "(is this what you mean?)" On Apr 14, 11:08 am, Nicolas Buduroi wrote: > Hi, I've got a simple question: When converting a form to a string the > resolved symbols are fully qualified, is there a way to get the string > with just the symbols? > > Thanks > > -

Re: Forms to strings

2010-04-14 Thread Sean Devlin
Why are you using quasi-quote? On Apr 14, 11:23 am, Nicolas Buduroi wrote: > On Apr 14, 11:12 am, Sean Devlin wrote: > > > user=> (str '(is this what you mean?)) > > "(is this what you mean?)" > > No, more like this: > > user=> (str `(str &quo

Re: Forms to strings

2010-04-14 Thread Sean Devlin
Happens to all of us :) On Apr 14, 12:03 pm, Nicolas Buduroi wrote: > On Apr 14, 11:44 am, Sean Devlin wrote: > > > Why are you using quasi-quote? > > D'oh! For no reason at all, damn I feel stupid, lol! Thanks -- You received this message because you are subscrib

Re: multi project / multi library simultaneous development - best practice?

2010-04-14 Thread Sean Devlin
How many developers do you need to coordinate with? On Apr 14, 2:46 pm, Kevin Livingston wrote: > I have been reading through the newsgroup on how to set up and > maintain a build/development environment for a large set of projects. > Coming from a CommonLisp world of maintaining/developing multi

Re: help wanted: tests for c.c.io

2010-04-15 Thread Sean Devlin
There's a bonus to starting out providing tests as well: If you break the build, that means you're doing the job RIGHT :-p Who's got a bug? Sean On Apr 14, 9:50 pm, Stuart Halloway wrote: > clojure.contrib.io is one of the most used libraries in contrib, and   > it has f

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
everything is equal. PersistentTreeSet delegates a lot of work to PersistentTreeMap, so the object is happily replacing every element when the comparator is zero. I'm not sure if this is a bug or the intended behavior... I'm leaning toward the latter, even though it's confusing. Sean On Ap

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
I think the fns you're interested in are sort and sort-by, not sorted- set-by. I know you might not like it, but there is a convention in JavaLand that a comparator value of 0 is identical in a sorted collection. This causes orthogonal concepts of order & identity to be entwined. Sean

Re: sorted-set-by drops elements

2010-04-16 Thread Sean Devlin
CORRECTION, DON'T SHOOT!! I should have order & value, not order & identity. On Apr 16, 1:01 pm, Sean Devlin wrote: > I think the fns you're interested in are sort and sort-by, not sorted- > set-by. > > I know you might not like it, but there is a convention i

Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
Hey everyone, I've had to code these guys up a few times: (defn rotate "Take a collection and left rotates it n steps. If n is negative, the collection is rotated right. Executes in O(n) time." [n coll] (let [c (count coll)] (take c (drop (mod n c) (cycle coll) (defn rotate-while

Re: Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
for the feedback, though. Sean On Apr 21, 11:37 am, Michał Marczyk wrote: > On 21 April 2010 17:23, Sean Devlin wrote: > > > I've had to code these guys up a few times: > > Nice functions! > > I'd replace "collection" with "sequence" in the do

Re: Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
Hmmm... good point. Now that I think about it, cycle is an artifact of an early implementation. On Apr 21, 1:01 pm, Mark Engelberg wrote: > On Wed, Apr 21, 2010 at 8:46 AM, Sean Devlin wrote: > > You're right about changing the docstring to read ""sequence" >

Re: How do I destructure this?

2010-04-21 Thread Sean Devlin
Hmmm... I'm not sure destructuring is possible here. Would it be easier to put an extractor fn in place? (defn extract [arg] (apply hash-map (map (juxt :tag :content) (:content arg Just a thought. I'm sure someone will have a better idea, though. On Apr 21, 1:02 pm, Base wrote: > Hi All

Re: Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
I like that version :) On Apr 21, 1:11 pm, Michał Marczyk wrote: > One could also do > > (defn rotate [n s] >   (let [[front back] (split-at (mod n (count s)) s)] >     (concat back front))) > > I was hoping for a moment to avoid calculating (count s) up front, but > that definitely does interfer

Re: Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
If you're gonna over engineer use a protocol :-p On Apr 21, 1:43 pm, Michał Marczyk wrote: > On 21 April 2010 19:35, Sean Devlin wrote: > > > I like that version :) > > :-) > > In this case, rotate-while could be rewritten like so: > > (defn rotate-with [pr

Re: wget replacement code review

2010-04-21 Thread Sean Devlin
At first glance, you should be requiring c.c.string, and don't write your own blank? fn. That's the only low hanging fruit I see. On Apr 21, 1:47 pm, Brent Millare wrote: > Hey all, > > I wrote a clojure version of the simplest functionality of wget. I > basically translated the java version int

Re: Missing fns: rotate & rotate-while

2010-04-21 Thread Sean Devlin
Hmmm... we could talk about what's faster or measure it. Time to eat my own damn dog food, I guess :) Traveling now, I'll run the experiments in a few days when I get back to my normal setup. Sean On Apr 21, 2:09 pm, Mark Engelberg wrote: > In some languages, split-at is more pe

Re: Which version of Netbeans to use Compojure on OSX?

2010-04-21 Thread Sean Devlin
If you've got the HD space, grab the most inclusive options. I *think* the SE one will work, but I haven't tested it. Space is cheap and all that. On Apr 21, 7:55 pm, Sophie wrote: > I see downloads named >   - Java SE (45MB) >   - Java FX (76MB) >   - Java (146MB) - apparently includes Sun Gla

Re: Missing fns: rotate & rotate-while

2010-04-22 Thread Sean Devlin
Oh wow... totally would have :) On Apr 21, 8:16 pm, Harvey Hirst wrote: > > (defn rotate [n s] > >  (let [[front back] (split-at (mod n (count s)) s)] > >    (concat back front))) > > Don't forget (mod n 0) is an ArithmeticException. > > Harvey > > -- > You received this message because you are s

Re: Reading from file

2010-04-22 Thread Sean Devlin
(join " " %) raw-vec)) And then we just spit this into a file: (spit "output.txt" (join "\n" (map #(join " " %) raw-vec))) And that should do it :) HTH, Sean 1. http://richhickey.github.com/clojure-contrib/string-api.html 2. http://richhickey.github.com/cl

Insert into an indexed seq

2010-04-27 Thread Sean Devlin
Is there a built in to insert a value into an "indexed" seq? For example: user=> (insert [:a :b :c :d] 2 :q) (:a :b :q :c :d) Not sure if I'm missing something simple... Sean -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Insert into an indexed seq

2010-04-27 Thread Sean Devlin
Also, why does this work: user=> (assoc [:a :b :c :d] 2 :q) [:a :b :q :d] And this doesn't: user=> (dissoc [:a :b :c :d] 2) # Annoying. On Apr 27, 1:24 pm, Sean Devlin wrote: > Is there a built in to insert a value into an "indexed" seq? > > For example: > &g

Re: Insert into an indexed seq

2010-04-27 Thread Sean Devlin
ong tool for the job. However, there are still problems that require me to use an expensive operation. Maybe I'm too focused on my current project, and wrong about how much a typical person would use insert. Still, its absence seems like an oversight. Sean On Apr 27, 2:05 pm, Chouser wrote: &g

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Sean Devlin
(send contains-val? inc) On Apr 29, 9:06 am, Douglas Philips wrote: > On 2010 Apr 29, at 4:21 AM, ataggart wrote: > > > Functions named contains-key? and contains-val? would make a lot more > > sense to me than the current contains? and new seq-contains?.  Anyone > > looking at contains-val? shou

Agents, eval, quasi-quote & closures

2010-04-29 Thread Sean Devlin
largh. Why doesn't this work when I use send? I'm at a loss here. Sean -- 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 moderate

Re: Agents, eval, quasi-quote & closures

2010-04-29 Thread Sean Devlin
Right... Is there a way to force an agent thread to be evaluated in a certain namespace? You see, the current design accepts a string, and uses read-string to parse it. i.e. I call a form like this a lot (send test-query conj (read-string (get-input))) Sean On Apr 29, 4:40 pm, Laurent PETIT

Re: Agents, eval, quasi-quote & closures

2010-04-30 Thread Sean Devlin
Okay, found a fix do my own bug. You can use the with-ns namespace to solve this issue. I changed the form to be like this: (send test-result (fn [& args] (with-ns 'my-ns (eval `(->> ~@(deref test-query)) FYI On Apr 29, 5:09 pm, Sean Devlin wrote: > Right... > Is

Re: something stupid I'm trying to do

2010-04-30 Thread Sean Devlin
I'd use the built-in, partition user=> (partition 2 (range 1 9)) ((1 2) (3 4) (5 6) (7 8)) And add a mapping operation user=> (map vec (partition 2 (range 1 9))) ([1 2] [3 4] [5 6] [7 8]) Am I missing a requirement? On Apr 30, 11:55 am, "Mark J. Reed" wrote: > I think you want this: > >  

<    1   2   3   4   5   6   7   8   9   10   >