Re: processing two collections

2010-02-15 Thread Glen Rubin
Thank you so much This is really wonderful advice...saved me months of learning. I have rewritten my code as follows: ;definition of a palindrome (defn palindrome? [s] (= s (apply str (reverse s ;list of palindromes for range of numbers (defn palindromes [start end]

Re: processing two collections

2010-02-15 Thread Steve Purcell
On 15 Feb 2010, at 13:50, Glen Rubin wrote: Thank you so much This is really wonderful advice...saved me months of learning. I have rewritten my code as follows: You'll want to use let in place of all of those def declarations. -Steve -- You received this message because you are

Re: processing two collections

2010-02-15 Thread Meikel Brandmeyer
Hi, On Feb 15, 2:50 pm, Glen Rubin rubing...@gmail.com wrote:   ;definition of a palindrome   (defn palindrome? [s]     (= s (apply str (reverse s You might want to call vec on the string and then rseq instead of reverse. reverse walks the string twice, while rseq just walks the string

Re: processing two collections

2010-02-15 Thread Steve Purcell
On 15 Feb 2010, at 13:58, Steve Purcell wrote: On 15 Feb 2010, at 13:50, Glen Rubin wrote: Thank you so much This is really wonderful advice...saved me months of learning. I have rewritten my code as follows: You'll want to use let in place of all of those def declarations.

Re: processing two collections

2010-02-15 Thread Glen Rubin
I tried using your alternate definition for palindromes? , but an exception was thrown: java.lang.NullPointerException [Thrown class java.lang.RuntimeException] On Feb 15, 7:02 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Feb 15, 2:50 pm, Glen Rubin rubing...@gmail.com wrote:  

Re: processing two collections

2010-02-15 Thread Meikel Brandmeyer
Hi, On Mon, Feb 15, 2010 at 01:07:15PM -0800, Glen Rubin wrote: I tried using your alternate definition for palindromes? , but an exception was thrown: java.lang.NullPointerException [Thrown class java.lang.RuntimeException] Works for me. However one has to wrap the first string into a

Re: processing two collections

2010-02-15 Thread ataggart
I think it'd be a good exercise to do this all without using strings. -- 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

processing two collections

2010-02-14 Thread Glen Rubin
howdy clojure folks! I am a noob and trying to do the following: Suppose I have 2 collections of numbers: (range 1000 2000) (range 100 150) How do I take an element from one collection and test for no remainder (e.g. (zero? (mod x y)), when dividing by every element of the second collection,

Re: processing two collections

2010-02-14 Thread Meikel Brandmeyer
Hi, On Sun, Feb 14, 2010 at 06:57:41AM -0800, Glen Rubin wrote: howdy clojure folks! I am a noob and trying to do the following: Suppose I have 2 collections of numbers: (range 1000 2000) (range 100 150) How do I take an element from one collection and test for no remainder (e.g.

Re: processing two collections

2010-02-14 Thread Steven E. Harris
Glen Rubin rubing...@gmail.com writes: How do I take an element from one collection and test for no remainder (e.g. (zero? (mod x y)), when dividing by every element of the second collection, before processing the next item in the first collection? This form checks if every element of the

Re: processing two collections

2010-02-14 Thread Stuart Sierra
On Feb 14, 9:57 am, Glen Rubin rubing...@gmail.com wrote: How do I take an element from one collection and test for no remainder (e.g. (zero? (mod x y)), when dividing by every element of the second collection, before processing the next item in the first collection? The 'for' macro does

Re: processing two collections

2010-02-14 Thread Glen Rubin
Thank you for the advice! Just for reference I am working on project euler question #4 (Find the largest palindrome made from the product of two 3-digit numbers.) I have a solution, but am hoping somebody can clarify some things for me: First, I define a panlindrome tester: (defn palindrome?

Re: processing two collections

2010-02-14 Thread ataggart
On Feb 14, 5:49 pm, Glen Rubin rubing...@gmail.com wrote: Thank you for the advice!  Just for reference I am working on project euler question #4 (Find the largest palindrome made from the product of two 3-digit numbers.) I have a solution, but am hoping somebody can clarify some things for