Re: Do I need to refactor this code?
- Posted by useless_ Jul 03, 2013
- 1377 views
DerekParnell said...
<snip>
You might want to try this approach, depending on how you automate the code generation ...
sequence temp temp = {a,b,c,d,e,f,g,h,i,x} switch temp do case {0,1,2,3,4,5,6,7,8,9} then return 1 end case case {0,1,2,3,4,5,6,7,8,10} then return 2 end case case {0,1,2,3,4,5,6,7,8,11} then return 3 end case end switch
Pretty in many ways. Is there a "don't care" value, or a helpful hint to catch a error or fall-thru in the Eu source code, such that
sequence temp temp = {0,1,2,3,4,5,6,7,"<12",9} switch temp do -- "" = type sequence flag = "don't care" (yeas, aka an error) case {0,1,2,3,4,5,6,7,"",9} then return {1,temp} end case end switch
So while Eu didn't process the "<12", temp is otherwise tested and returned to the user in a sequence for extra processing?
Or praps this:
type P_1(integer x) return x >= 0 and x <= 23 end type sequence temp temp = {atom,atom,atom,atom,atom,atom,atom,atom,P_1,atom} switch temp do case {0,1,2,3,4,5,6,7,12,9} then return 1 end case end switch
Or praps there is some way to push a list of types into the case comparisons internally on a case-by-case basis?
I have also had a situation where this would have been extremely valuable in optical pattern recognition or extracting details about motion. It would also be handy in resolving tags in content addressable data, or misspelling, or ?
useless