Re: Project Euler problem in clojure

2013-06-20 Thread John Holland
OK, with a coding improvement (defn factors-sqrt [n] (filter #(= 0 (mod n %)) (range 1 (+ 1 (Math/sqrt n ) (defn num-of-factors [n] (* 2 (count (factors-sqrt n it works for 499. (Idea being factors come in pairs, each factor > sqrt(x) corresponds to one > sqrt(x)) Was it just runnin

Project Euler problem in clojure

2013-06-20 Thread John Holland
I'm working on problems at projecteuler.net in Clojure. There is a particular problem that my code doesn't seem to work for. The problem is: == The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 +

Test please ignore

2013-03-23 Thread John Holland
testing gmane interface -- -- 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. To unsubscribe from thi

Testing gmane please ignore

2013-03-23 Thread John Holland
This is just a test of the gmane gateway please ignore. -- -- 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 fi

Re: atom with metadata

2012-09-09 Thread John Holland
sorry, figured it out after I posted - to get at the meta have to deref the atom On Sunday, September 9, 2012 10:50:34 AM UTC-4, John Holland wrote: > > Can I perform a swap! on an atom and have the metadata survive? Or else > reapply it somehow? The only way I seem to be able

atom with metadata

2012-09-09 Thread John Holland
Can I perform a swap! on an atom and have the metadata survive? Or else reapply it somehow? The only way I seem to be able to apply metadata is with the reader macro. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: webnoir on openshift (Paas by RedHat), little guide

2012-08-31 Thread John Holland
This is awesome! On Friday, August 31, 2012 4:31:38 PM UTC-4, Simone Mosciatti wrote: > > A little guide to use webnoir on openshift > > http://sisciatech.tumblr.com/post/29614188595/webnoir-in-openshift > > English is not my first language, if you find any mistake please let me > know. > > I ho

Re: problem 58 on 4clojure

2012-08-25 Thread John Holland
omp but it will be fun to see. On Sat, Aug 25, 2012 at 2:46 PM, John Holland wrote: > Thanks to a for the replies. I will study them later when I am free. > > On Aug 25, 2012 2:37 PM, "nicolas.o...@gmail.com" > wrote: >> >> Here's my take: >> &g

Re: problem 58 on 4clojure

2012-08-25 Thread John Holland
Thanks to a for the replies. I will study them later when I am free. On Aug 25, 2012 2:37 PM, "nicolas.o...@gmail.com" wrote: > > Here's my take: > > We want to define a function my-comp. It takes n functions and return > their composition. > We want to return a function of any number of argum

problem 58 on 4clojure

2012-08-25 Thread John Holland
This problem is really confusing me. I found a solution online, but I can't understand the solution. Can anyone explain to me why this works? The problem is stated as: Write a function which allows you to create function compositions. The parameter list should take a variable number of function

Re: recursion question

2012-08-14 Thread John Holland
Ended up with the following wondering if loop/recur is possible in this case? (defn groupSum [a x] (cond (= (count a) 0) false (= (first a) x) true (> (first a) x) (if (> (count a) 1) (groupSum (rest a) x) false)

Re: recursion question

2012-08-14 Thread John Holland
y of at least > N bits, where N is the target. > > Andy > > On Aug 14, 2012, at 4:17 PM, John Holland wrote: > > I thought of doing something like that, but part of the requirements is > that the sum could be achieved with *some" of the numbers in the vector. >

Re: recursion question

2012-08-14 Thread John Holland
if the remaining #s can sum to the now-lesser goal. > lather rinse repeat. > don't forget a base case. > watch your cpu heat very quickly up on even slightly longer lists. > ? > > On Tue, Aug 14, 2012 at 4:13 PM, John Holland > > > wrote: > > I've

recursion question

2012-08-14 Thread John Holland
I've been doing some programming exercises in Clojure, I've run into one I don't know how to approach. If anyone can just give me the strategy to use on this that'd be great. Here is the problem statement: Given an array of ints, is it possible to choose a group of some of the ints, such that t

Re:

2012-07-29 Thread John Holland
Thanks! On Sun, Jul 29, 2012 at 9:22 AM, Moritz Ulrich wrote: > Also, take a look at `partition'. > > On Sun, Jul 29, 2012 at 3:19 PM, Mark Rathwell > wrote: > > In your has22 definition, (by-pairs [a]) should be (by-pairs a) > > > > On Sun, Jul 29, 201

[no subject]

2012-07-29 Thread John Holland
[1 2 2 2 ]))) true user> (has22 [1 2 2 2]) false John Holland -- 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 pati

Re: a newbie question

2012-07-04 Thread John Holland
Thanks everybody On Wed, Jul 4, 2012 at 2:16 PM, Tassilo Horn wrote: > John Holland writes: > > Hi John, > > > If I want to get the last n elements of a list or vector I am doing > > the following: > > > > (reverse (take n (reverse thelist))) > > >

a newbie question

2012-07-04 Thread John Holland
If I want to get the last n elements of a list or vector I am doing the following: (reverse (take n (reverse thelist))) Is there a better way to do this? I'm going through some basic coding exercises which were meant for Java but I'm finding them educational to get started with Clojure. -- Yo

Re: General subsequence function

2012-06-29 Thread John Holland
But elisp vectors can't be accessed like lists, try running "car" on one. On Thu, Jun 28, 2012 at 1:55 PM, Warren Lynn wrote: > Here is "another language" elisp: > > Anybody who use Emacs can do this: > > (subseq (make-vector 5 10) 2 4) => [10 10] > (subseq '(10 10 10 10 10) 2 4) => (10 10) > >

another noob recursion question

2011-12-01 Thread John Holland
In clojure, would this be possible? Wouldn't it produce a stack overflow with big enough input? Would there be a way to define it in terms of recur, loop, etc? Apologies if this is too obvious... John Holland -- You received this message because you are subscribed to the Google Groups &