Re: math utilities question

2010-12-05 Thread Benny Tsai
Always nice to see a fellow Neal Stephenson fan! On Dec 5, 10:26 pm, Ken Wesson wrote: > On Mon, Dec 6, 2010 at 12:14 AM, Miki wrote: > > Have you looked at Incanter? (http://incanter.org/) > > Hmm, interesting. Is there a Rhetor too? -- You received this message because you are subscribed to

Re: Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Benny Tsai
When I saw the part about traversing an arbitrarily nested collection, I immediately thought of clojure.walk (http://clojure.github.com/ clojure/clojure.walk-api.html). I ended up with this: (use 'clojure.walk) (defn all-vals [k coll] (let [vals (atom []) find-val (fn [form]

Re: appengine-clj and appengine 1.4 SDK error

2010-12-05 Thread Miki
Seems like the problem was with lein 1.4, see https://github.com/technomancy/leiningen/issues#issue/142 On Dec 4, 8:21 am, Miki wrote: > Greetings, > > My toy application stopped working after an upgrade to appengine SDK > 1.4, does anyone else have the same experience? Any solutions? > > You can

Re: help with macro writing style

2010-12-05 Thread Sunil S Nandihalli
Really sorry about pasting the code in the email. It seems to have added 2-3 extra new-lines after every line .. :( .. but the same code is present in the github-gist. Sunil. On Mon, Dec 6, 2010 at 10:57 AM, Sunil S Nandihalli < sunil.nandiha...@gmail.com> wrote: > Hello everybody, > The followi

Re: math utilities question

2010-12-05 Thread Ken Wesson
On Mon, Dec 6, 2010 at 12:14 AM, Miki wrote: > Have you looked at Incanter? (http://incanter.org/) Hmm, interesting. Is there a Rhetor too? -- 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

Re: math utilities question

2010-12-05 Thread Miki
Have you looked at Incanter? (http://incanter.org/) On Dec 5, 3:27 pm, Robert McIntyre wrote: > I'm trying to use clojure for scientific data analysis but I keep > running into lacunas of functionality. > > I'd love to hear the community's recommendations and experiences with this: > > Is there a

Re: math utilities question

2010-12-05 Thread Robert McIntyre
Thanks for your input --- I'm hoping that some of this stuff is already written with performance optimizations and the like. I'm wondering if people have had experience with java libraries of that sort and might have some recommendations. Anyone use clojure for scientific data analysis? What do y

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > Ken & Alex, > Why you aren't calling empty? when you want to check if a collection > is empty? Here's the definition of empty? from clojure/core.clj: (defn empty? "Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > OMG, this is too much Clojure code for me to handle O.o > Alex, you just killed me :) Hehe, sorry. Just thought it might be helpful to show the progression of dealing with all the little edge cases. It perhaps looks much more fiddly, but you're doing more there than common lisp:

Re: Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 10:03 PM, Ken Wesson wrote: > On Sun, Dec 5, 2010 at 9:12 PM, Alex Baranosky > wrote: >> Hi guys, >> I would like a function to be able to take an arbitrarily nested collection >> and return a sequence of all values of a given key, such as :name, that >> appears anywhere in

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 6:55 PM, HB wrote: > Ken & Alex, > Why you aren't calling empty? when you want to check if a collection > is empty? > > Isn't (if s) supposed to return true if s is empty ? If coll is empty, (seq coll) and (next coll) are both nil, which is logical false. -- You received

Re: Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 9:12 PM, Alex Baranosky wrote: > Hi guys, > I would like a function to be able to take an arbitrarily nested collection > and return a sequence of all values of a given key, such as :name, that > appears anywhere in the nested collection. > Does anything like this already ex

Re: Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Alex Baranosky
The above is using Midje syntax: https://github.com/marick/Midje -- 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

Re: Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Alex Baranosky
Here's my first attempt: (defn all-vals [key coll] (let [all-vals-w-key (partial all-vals key)] (cond (map? coll) (concat [(key coll)] (all-vals-w-key (vals coll))) (or (vector? coll) (seq? coll)) (apply concat (map all-vals-w-key coll) Call it like so: (fact

Re: parameters destructuring & sets?

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 8:26 PM, Robert McIntyre wrote: > If sets don't have a set ordering, then why should seq on a set always > return the same order for the same set? > > If seq doesn't always return the a seq with the same order, then (nth > set 5) might be different than a future call to (nth

Re: math utilities question

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 6:27 PM, Robert McIntyre wrote: > I'm trying to use clojure for scientific data analysis but I keep > running into lacunas of functionality. > > I'd love to hear the community's recommendations and experiences with this: > > Is there a standard way to do things like: > 1. ta

Get sequence of values in arbitrarily nested collection

2010-12-05 Thread Alex Baranosky
Hi guys, I would like a function to be able to take an arbitrarily nested collection and return a sequence of all values of a given key, such as :name, that appears anywhere in the nested collection. Does anything like this already exist? Thanks for the help, Alex -- You received this message

Re: parameters destructuring & sets?

2010-12-05 Thread Robert McIntyre
If sets don't have a set ordering, then why should seq on a set always return the same order for the same set? If seq doesn't always return the a seq with the same order, then (nth set 5) might be different than a future call to (nth set 5), because the underlying sequence returned by the set migh

Re: parameters destructuring & sets?

2010-12-05 Thread Sunil S Nandihalli
+1 to what Ken said Sunil On Mon, Dec 6, 2010 at 4:04 AM, Ken Wesson wrote: > On Sun, Dec 5, 2010 at 4:14 PM, jweiss wrote: > > That's totally different than nth for a set being undefined. It's > undefined > > on purpose. > > > > Now, if you are using a sorted-set, then you have a point there,

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread HB
Ken & Alex, Why you aren't calling empty? when you want to check if a collection is empty? Isn't (if s) supposed to return true if s is empty ? On Dec 6, 12:27 am, Ken Wesson wrote: > On Sun, Dec 5, 2010 at 5:16 PM, Robert McIntyre wrote: > > Your function never actually ends  because even the

math utilities question

2010-12-05 Thread Robert McIntyre
I'm trying to use clojure for scientific data analysis but I keep running into lacunas of functionality. I'd love to hear the community's recommendations and experiences with this: Is there a standard way to do things like: 1. take the convolution of two vectors 2. work with imaginary numbers, qu

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread HB
OMG, this is too much Clojure code for me to handle O.o Alex, you just killed me :) Do you previous Lisp knowledge? or Clojure is your first Lisp? you are so good. I will spend the next couple of hours studying it. Thanks all, you are awesome. On Dec 6, 12:47 am, Alex Osborne wrote: > HB write

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Nadeem Vawda
In Clojure, empty sequences are not considered logically false, so your code continues going after reducing col to an empty list. You need to explicitly check whether the collection is empty, like so: (defn list-length [col] (if (empty? col) 0 (+ 1 (list-length (rest col) Cheers, N

Re: Broken MacPorts setup on OS X 10.5?

2010-12-05 Thread Phil Hagelberg
On Sun, Dec 5, 2010 at 10:05 AM, Philip Hudson wrote: > Anyone willing & able to help troubleshoot a Mac 10.5 MacPorts setup? I've heard other bug reports with the MacPorts packaging of Leiningen. I'd recommend installing as per the Leiningen readme or using Homebrew until the packaging gets fixe

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > I'm trying to write a function that calculates the length of a list: > > (defn list-length [col] > (if col > (+ 1 (list-length(rest col))) > 0)) > > > (list-length '(Java, Clojure, Scala)) > > Upon running it in the REPL, I got the error: > java.lang.StackOverflowError (tes

Re: Fixing minmax algorithm

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 7:46 AM, Timo Myyrä wrote: > Thank you, this solved the issues I was having as far as I can tell. > > Now I can focus on getting rest of my chess engine working properly. Chess? Then you've got a problem. I didn't see any pruning or even depth bounding in your algorithm. An

Re: parameters destructuring & sets?

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 4:14 PM, jweiss wrote: > That's totally different than nth for a set being undefined.  It's undefined > on purpose. > > Now, if you are using a sorted-set, then you have a point there, I > would expect that nth means something then.  But yeah, clojure doesn't > let you call

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread HB
What is the difference between rest and next? I'm confused, should I use empty? or not? when to use it? Robert, Your code is working but if I use empty? , it returns 0 instead of the actual count. Why? Why Clojure decided to handle an empty list as a not false? this is a big (if not) departure f

Re: parameters destructuring & sets?

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 1:29 PM, jweiss wrote: > I'm no expert on this, but i'll take a crack at it. > > I think it's because sets don't (necessarily) impose any order, so > there's no concept of "first" or "nth".  So destructuring would > essentially be assigning a random item to x, or for join, j

There is no such thing as IAtom

2010-12-05 Thread Pepijn de Vos
tl;dr: Please add an interface to clojure.lang.Atom. kthxbye I had the brilliant idea of using CouchDB for something equally brilliant, and if possible implement a Clojure view server. Turns out Clutch fits the bill perfectly, except that I would like to use Aleph, and Couch is using something

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Ken Wesson
On Sun, Dec 5, 2010 at 5:16 PM, Robert McIntyre wrote: > Your function never actually ends  because even the empty list > evaluates to true :) > > rlm.dna-melting> (if (rest '()) true false) > true > > rlm.dna-melting> (if (next '()) true false) > false > > so, changing your list length function t

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Robert McIntyre
Your function never actually ends because even the empty list evaluates to true :) rlm.dna-melting> (if (rest '()) true false) true rlm.dna-melting> (if (next '()) true false) false so, changing your list length function to use next will work rlm.dna-melting> (defn list-length [col] (if col (+

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Danny Woods
On Dec 5, 9:52 pm, HB wrote: > Hi, > I'm trying to write a function that calculates the length of a list: > > (defn list-length [col] >   (if col >     (+ 1 (list-length(rest col))) >     0)) > > (list-length '(Java, Clojure, Scala)) > > Upon running it in the REPL, I got the error: > java.lang.St

Re: Pre-expansion macro form

2010-12-05 Thread Brian Marick
On Dec 5, 2010, at 3:32 PM, Alex Osborne wrote: >> >> Is there any way to get the original call form? Something like &env? Some >> hook into the reader? > > Try &form I should have guessed. Thanks. - Brian Marick, Artisanal Labrador Contract programming in Ruby and Clojure Author of /Ri

Why I'm getting StackoverflowError?

2010-12-05 Thread HB
Hi, I'm trying to write a function that calculates the length of a list: (defn list-length [col] (if col (+ 1 (list-length(rest col))) 0)) (list-length '(Java, Clojure, Scala)) Upon running it in the REPL, I got the error: java.lang.StackOverflowError (test.clj:3) What is going wron

Re: outlining for clojure files in emacs+slime?

2010-12-05 Thread Alan D. Salewski
On Sun, Dec 05, 2010 at 07:35:35AM -0700, Eric Schulte spake thus: > Also, I often see ^L characters in lisp files inside of Emacs, I believe > these characters are used for in-file navigation, but I don't know how, > so that might be another avenue of investigation (I'd be interested to > hear wha

Re: Pre-expansion macro form

2010-12-05 Thread Alex Osborne
Brian Marick writes: > Is there any way to get the original call form? Something like &env? Some > hook into the reader? Try &form -- 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 t

Re: parameters destructuring & sets?

2010-12-05 Thread jweiss
On Dec 5, 2:10 pm, Alex Ott wrote: > Re > > jweiss  at "Sun, 5 Dec 2010 10:29:41 -0800 (PST)" wrote: >  j> I'm no expert on this, but i'll take a crack at it. > >  j> I think it's because sets don't (necessarily) impose any order, so >  j> there's no concept of "first" or "nth".  So destructurin

Pre-expansion macro form

2010-12-05 Thread Brian Marick
Suppose that 'future-fact' is a macro. Its declaration is this: (defmacro future-fact [& forms] ... Here's a use of the macro: (future-fact "some text" (+ 1 2)) The metadata on the (+ 1 2) form will contain the line number. However, consider this: (future-fact "some text") Strings don't get

Re: parameters destructuring & sets?

2010-12-05 Thread Alex Ott
Re jweiss at "Sun, 5 Dec 2010 10:29:41 -0800 (PST)" wrote: j> I'm no expert on this, but i'll take a crack at it. j> I think it's because sets don't (necessarily) impose any order, so j> there's no concept of "first" or "nth". So destructuring would j> essentially be assigning a random item

Re: parameters destructuring & sets?

2010-12-05 Thread jweiss
I'm no expert on this, but i'll take a crack at it. I think it's because sets don't (necessarily) impose any order, so there's no concept of "first" or "nth". So destructuring would essentially be assigning a random item to x, or for join, joining them in random order. I'm curious what the use c

Broken MacPorts setup on OS X 10.5?

2010-12-05 Thread Philip Hudson
Anyone willing & able to help troubleshoot a Mac 10.5 MacPorts setup? Here's what I get: % sudo port -R -u -c install clojure clojure-contrib leiningen % lein self-install That's not a task. Use "lein help" to list all tasks. % lein help install That's not a task. Use "lein help" to list al

parameters destructuring & sets?

2010-12-05 Thread Alex Ott
Hello all I have following question to Rich and other core developers of Clojure - why parameters destructuring requires presence of 'nth' implementation for destructuring of sequences? The [[x & more]] idiom is very popular and could make code more concise, but it doesn't work for sets and some

Message to Rich Hickey: Post Hammock-driven development slides

2010-12-05 Thread Ralph
Rich- Could you post the slides from your "Hammock-driven development" talk? Most excellent! Awesome in fact :-). 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

Re: Fixing minmax algorithm

2010-12-05 Thread Timo Myyrä
Thank you, this solved the issues I was having as far as I can tell. Now I can focus on getting rest of my chess engine working properly. Timo Jason Wolfe writes: > You're looking for "apply". > > user2> (max 1 2 3) > 3 > user2> (max [1 2 3]) > [1 2 3] > user2> (apply max [1 2 3]) > 3 > > -Jas

Re: Tailing a file in Clojure

2010-12-05 Thread Miki
http://jnotify.sourceforge.net/ ? On Dec 3, 11:20 am, Stuart Sierra wrote: > On Dec 2, 10:55 pm, patrickdlogan wrote: > > > Java has a file watch API to avoid polling. Stuart Sierra uses it to > > good effect in lazytest. > > No, there is no such Java API that I am aware of.  Lazytest watches >

Re: outlining for clojure files in emacs+slime?

2010-12-05 Thread Eric Schulte
Hi Sunil, This is not quite what your asking for, but Org-mode [1] (an Emacs outlining mode) has support for embedded code blocks which can be executed, tangled etc... [2] in a number of languages including Clojure. Also, I often see ^L characters in lisp files inside of Emacs, I believe these ch