Seems to work for me. I changed it a bit (I believe you meant 'len ar' on the first line, with the following defintion of 'len': len = (1+) . uncurry (flip (-)) . bounds , but other than that, I left your code as it is).
Can you provide input on which it fails? It works for me on large input like: *Main> ind 1 "foo" $ listArray (1,10000) (concat $ repeat "abcfoodefgfooa") even in ghci. -- Hal Daume III | [EMAIL PROTECTED] "Arrest this man, he talks in maths." | www.isi.edu/~hdaume > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ketil Z. Malde > Sent: Friday, June 20, 2003 7:05 AM > To: [EMAIL PROTECTED] > Subject: stack space overflow > > > > Hi, > > I have a small function to find all indices in an array where a given > subword can be found, looking like this: > > > ind i ws ar > > | i+length ws-1 > len e = [] > > | and [ar!(i+j) == ws!!j | j<-[0..length ws-1]] = i : ind > (i+1) ws ar > > | otherwise = ind (i+1) ws ar > > (i::Int is the position, ws::[a] is the word to look for, while > ar::Array Int a is the array wherein to look) > > This occasionally blows up with a stack overflow, perhaps I'm being > dense, but I'm not sure why. Any suggestions? > > BTW, is there a general way to track down stack overflows? I use the > -xc option, are there any other tricks I should know about? And does > heap profiling (GHC) imply more stack usage -- I seem to get overflows > much more easily when profiling. > > -kzm > -- > If I haven't seen further, it is by standing in the > footprints of giants > _______________________________________________ > Haskell mailing list > [EMAIL PROTECTED] > http://www.haskell.org/mailman/listinfo/haskell > _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
