Content deleted Content added
→The algorithm: insert <source lang="pascal"> tag </source> for ALGOL 60 wiith some pre-ascii characters. |
Quuxplusone (talk | contribs) use <code> where proper (<source> doesn't support ALGOL; coloring is wrong for Perl); rm Ruby examples as repetitive |
||
Line 6:
==The algorithm==
In [[ALGOL
<
'''begin integer''' i; '''real''' y; '''real array''' a[0:10];
'''real procedure''' f(t); '''real''' t; '''value''' t;
f := sqrt(abs(t))+
'''for''' i := 0 '''step''' 1 '''until''' 10 '''do''' read(a[i]);
'''for''' i := 10 '''step''' -1 '''until''' 0 '''do'''
'''begin''' y := f(a[i]);
'''if''' y > 400 '''then''' write(i, "TOO LARGE")
'''else''' write(i,y);
'''end'''
'''end'''
</
The algorithm reads eleven numbers from an input device, stores them in an array, and then processes them in reverse order, applying a user-defined function to each value and reporting either the value of the function or a message to the effect that the value has exceeded some threshold.
Line 28:
The following [[Perl]] implementation is 79 [[byte]]s.
<
map print(($_>400?"TOO LARGE":$_).$/),reverse map 5*($x=<>)**3+sqrt abs$x,1..11
</
==Python version==
Line 46:
else:
print i, y
</source>
|