Re: Tight programming exercise, using bad programming practices
- Posted by Spock Jun 21, 2015
- 2584 views
petelomax said...
And yet there is also this, which loses points for having no real trickery of any note at all
procedure tiny(sequence s) integer l=length(s),n for i=1 to l do n=0 for j=i to l do n=n*10+s[j]-'0' if remainder(n,3)=0 then printf(1,"%d, ",n) end if end for end for end procedure
Pete
PS I am a bit surprised Orac does not have "for i ~s do"
Dang! It should have, eh? In fact, keywords like do and then are also redundant since the parser knows exactly where the expression ends. This would give us stuff like:
for i ~s for i ~s to 1 -- reverse direction while x if x = CASE1 elsif x = CASE2 proc myproc() func myfunc()
BTW, using eg proc instead of procedure could be done seamlessly [ie, without breaking existing stuff] since the parser can easily know the difference between the keyword proc at the top-level versus a variable called proc at the routine level.
Putting it all together we get:
proc tiny2(seq s) for i ~s int n = 0 for j ~s n += s.j if n%3 = 0 puts(1,s[i to j]&", ") end end end end
But we can't really have stuff like that because that would make Euphoria even easier to use.
Spock