Click here to Skip to main content
15,898,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
i want to match semicircle pattern of '1' using 8x8 array.
now problem is that when i execute this code for left and right semicircle i get stackoverflow exception.

Here is example for left semicircle that i want to match :

0 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

Below code is for left semicircle:

let MatchLeft aryLeft =
    match aryLeft with
    | [|[|_;1;_;_;_;_;_;_|];[|1;_;_;_;_;_;_;_|];[|1;_;_;_;_;_;_;_|];[|_;1;_;_;_;_;_;_|]|] 
    | [|[|_;_;1;_;_;_;_;_|];[|_;1;_;_;_;_;_;_|];[|_;1;_;_;_;_;_;_|];[|_;_;1;_;_;_;_;_|]|] 
    | [|[|_;_;_;1;_;_;_;_|];[|_;_;1;_;_;_;_;_|];[|_;_;1;_;_;_;_;_|];[|_;_;_;1;_;_;_;_|]|] 
    | [|[|_;_;_;_;1;_;_;_|];[|_;_;_;1;_;_;_;_|];[|_;_;_;1;_;_;_;_|];[|_;_;_;_;1;_;_;_|]|] 
    | [|[|_;_;_;_;_;1;_;_|];[|_;_;_;_;1;_;_;_|];[|_;_;_;_;1;_;_;_|];[|_;_;_;_;_;1;_;_|]|]
    | [|[|_;_;_;_;_;_;1;_|];[|_;_;_;_;_;1;_;_|];[|_;_;_;_;_;1;_;_|];[|_;_;_;_;_;_;1;_|]|] 
    | [|[|_;_;_;_;_;_;_;1|];[|_;_;_;_;_;_;1;_|];[|_;_;_;_;_;_;1;_|];[|_;_;_;_;_;_;_;1|]|] -> true
    | _ -> false


kindly help me out...
if there are other simple ways to math this then plz let me know asap....
Posted

1 solution

Stack overflow is usually pretty easy to detect.

Nearly 100% of such cases is when you use recursion or mutual recursion (of more than one methods calling each other in cycle). In such cases, your bug is not providing a condition when this recursion ever finishes.

See http://en.wikipedia.org/wiki/Recursion[^].

It needs your code of course, but you can do it yourself.

In my solution to this question I explain how this condition occurs and how to solve this problem:
System.StackOverflowException' occurred in sample.DLL[^].

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900