Re: StackOverflowError Question

2009-04-22 Thread jleehurt
Hi Chrisophe, You are correct, the doall also solves the problem. Based on that, I moved the doall out of matrixMultiply and into the computeActualResponse function, so that the caller can decide whether they want lazy evaluation for matrixMultiply or not: (defn computeActualResponse

Re: StackOverflowError Question

2009-04-21 Thread Dimiter malkia Stanev
I blindly tried printing out stuff from matrixMultiply, and found out that if I print matrixA and matrixB it doesn't run out of stack, so I guess I was forcing them to work, here is a version with (dorun) that has the same side effect, without printing: (defn matrixMultiply [matrixA matrixB]

Re: StackOverflowError Question

2009-04-21 Thread jleehurt
Hi Dimiter, Thank you! I'm still a bit confused as to why this was happening. Does lazy evaluation not work well with recursion? On Apr 20, 11:06 pm, Dimiter \malkia\ Stanev mal...@gmail.com wrote: I blindly tried printing out stuff from matrixMultiply, and found out that if I print matrixA

Re: StackOverflowError Question

2009-04-21 Thread Dimiter malkia Stanev
Hi Jleehurt, I'm still newbie and don't know, but you have at least two recursive functions - matrixAdd, and matrixMultiplyScalar. I've modified them to work with loop/recur, but I can't tell whether they are with same efficiency (at least no stack problem). Still if I remove the dorun from

Re: StackOverflowError Question

2009-04-21 Thread Christophe Grand
Hello, (def lazy-identity [x] (lazy-seq x)) (nth (iterate lazy-identity [1 2]) 10) ; returns (1 2) (nth (iterate lazy-identity [1 2]) 1000) ; returns (1 2) (nth (iterate lazy-identity [1 2]) 10) ; (with my JVM settings) throws a StackOverflowException Each time that you are building a lazy

StackOverflowError Question

2009-04-20 Thread jleehurt
Hi all, I have the following code that trains a perceptron with the given inputs and corresponding desired inputs. For input/output vectors, when the size gets to about 2000, I am getting a java.lang.StackOverflowError in the following function: (defn trainPerceptron [beginningWeightVector

Re: StackOverflowError Question

2009-04-20 Thread David Nolen
You have two other function calls getAdaptedWeightVector computeActualResponse Are these recursive as well? On Sun, Apr 19, 2009 at 11:26 PM, jleehurt jleeh...@gmail.com wrote: Hi all, I have the following code that trains a perceptron with the given inputs and corresponding desired inputs.

Re: StackOverflowError Question

2009-04-20 Thread jleehurt
Hi David, Those two are not recursive, but they call into other recursive functions. Do I need to make sure all recursive functions use the loop/ recur pattern? Or maybe not nest recursive calls like this? Here is the whole source: ;threshold (defn threshold [x] (if (= x 0) 1 0)) ;signum

Re: StackOverflowError Question

2009-04-20 Thread jleehurt
Hi David, Those two are not recursive, but they call into other functions that are. Do I need to make sure that all recursive functions use the loop/ recur pattern? Or should I not nest recursive calls like this? Here is the whole source: ;; Neuron Activation Functions ;threshold (defn