Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
ALGOL
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Code sample comparisons=== ====ALGOL 60==== (The way the bold text has to be written depends on the implementation, e.g. 'INTEGER'—quotation marks included—for integer. This is known as [[stropping (programming)|stropping]].) '''procedure''' Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); '''value''' n, m; '''array''' a; '''integer''' n, m, i, k; '''real''' y; '''comment''' The absolute greatest element of the matrix a, of size n by m, is copied to y, and the subscripts of this element to i and k; '''begin''' '''integer''' p, q; y := 0; i := k := 1; '''for''' p := 1 '''step''' 1 '''until''' n '''do''' '''for''' q := 1 '''step''' 1 '''until''' m '''do''' '''if''' abs(a[p, q]) > y '''then''' '''begin''' y := abs(a[p, q]); i := p; k := q '''end''' '''end''' Absmax Here is an example of how to produce a [[Table (information)|table]] using Elliott 803 ALGOL.<ref>[http://www.billp.org/ccs/A104/ "803 ALGOL"] {{webarchive|url=https://web.archive.org/web/20100529063048/http://www.billp.org/ccs/A104/ |date=29 May 2010}}, the manual for Elliott 803 ALGOL</ref> FLOATING POINT ALGOL TEST' BEGIN REAL A,B,C,D' READ D' FOR A:= 0.0 STEP D UNTIL 6.3 DO BEGIN PRINT {{abbr|PUNCH(3)|sends output to the teleprinter rather than the tape punch.}},££L??' B := SIN(A)' C := COS(A)' PRINT PUNCH(3),{{abbr|SAMELINE|suppresses the carriage return + line feed normally printed between arguments.}},{{abbr|ALIGNED(1,6)|controls the format of the output with one digit before and six after the decimal point.}},A,B,C' END END' ====ALGOL 68==== The following code samples are ALGOL 68 versions of the above ALGOL 60 code samples. ALGOL 68 implementations used ALGOL 60's approaches to [[stropping (programming)|stropping]]. In ALGOL 68's case tokens with the bold typeface are reserved words, types (modes) or operators. '''proc''' abs max = ([,]'''real''' a, '''ref''' '''real''' y, '''ref''' '''int''' i, k)'''real''': '''comment''' The absolute greatest element of the matrix a, of size ⌈a by 2⌈a is transferred to y, and the subscripts of this element to i and k; '''comment''' '''begin''' '''real''' y := 0; i := ⌊a; k := 2⌊a; '''for''' p '''from''' ⌊a '''to''' ⌈a '''do''' '''for''' q '''from''' 2⌊a '''to''' 2⌈a '''do''' '''if''' '''abs''' a[p, q] > y '''then''' y := '''abs''' a[p, q]; i := p; k := q '''fi''' '''od''' '''od'''; y '''end''' # abs max # Note: lower (⌊) and upper (⌈) bounds of an array, and array slicing, are directly available to the programmer. floating point algol68 test: ( '''real''' a,b,c,d; # ''printf'' – sends output to the '''file''' ''stand out''. # # ''printf($p$);'' – selects a ''new page'' # printf(($pg$,"Enter d:")); read(d); '''for''' step '''from''' 0 '''while''' a:=step*d; a <= 2*pi '''do''' printf($l$); # ''$l$'' - selects a ''new line''. # b := sin(a); c := cos(a); printf(($z-d.6d$,a,b,c)) # formats output with 1 digit before and 6 after the decimal point. # '''od''' )
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
ALGOL
(section)
Add topic