APL Hacking: Project Euler Daily (#12)
I also took this opportunity to come up with a decent way to give feedback that indicates a not found error.
This is the class that I wrote for the system;
Twelve; D;R;Match { D←0⍴0 R←0⍴0∇X←Match N
X←D<2×+/0=(⍳⌊N*0.5)|N
∇∇Twelve A
(D R)←A
∇∇X←Solve;Y;⎕IO
⎕IO←1
X←(⊃(Y,(⊂'Not found'))[(Match¨Y)⍳1])⊣Y←+⍳R
∇
}
And this is my function that uses it for Problem #12:
∇R←PETWELVE;T⍝ What is the value of the first triangle number
⍝ to have over five hundred divisors?T←⎕NEW 'Twelve' 500 13000
R←T.Solve
∇