Help:Programming Example Prototypes: Difference between revisions

Added works with, lang tags
m (Help:Programming Example Prototypes moved to Call Back Array: Ada: Should not take the place of the prototypes.)
(Added works with, lang tags)
 
(9 intermediate revisions by 3 users not shown)
Line 1:
These are prototypes of well-formed [[Help:Programming example|programming examples]] conforming to curring Rosetta Code formatting style. View this page's source to see how to construct your own programming examples.
==[[Ada]]==
[[Category:Your Language Here]]
'''Compiler:''' [[Gnat]] (GPL 2005)
[[Category:GNAT GPL 2005]]
 
Use the one which supplies the most information possible.
with Ada.Text_Io;
with Ada.Integer_text_IO;
 
=Prototypes=
procedure Call_Back_Example is
----
-- Purpose: Apply a callback to an array
 
-- Output: Prints the squares of an integer array to the console
''When using a [[compiler]] and a [[library]], with illustrative text:''
 
-- Define the callback procedure
=={{header|Your Language Here}}==
procedure Display(Location : Positive; Value : Integer) is
'''Compiler:''' [[Your Compiler Here]] (Your version here)
begin
[[Category:Your Compiler Here]]
Ada.Text_Io.Put("array(");
 
Ada.Integer_Text_Io.Put(Item => Location, Width => 1);
{{libheader|Your Library Here}}
Ada.Text_Io.Put(") = ");
 
Ada.Integer_Text_Io.Put(Item => Value, Width => 1);
Some code.
Ada.Text_Io.New_Line;
Notice how each line begins with at least one space.
end Display;
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
-- Define an access type matching the signature of the callback procedure
Now I'm typing more code, with the spaces again at the beginning of the line.
type Call_Back_Access is access procedure(L : Positive; V : Integer);
Now I'm talking about the next bit of code again.
And here's that final bit of code...
-- Define an unconstrained array type
 
type Value_Array is array(Positive range <>) of Integer;
----
 
-- Define the procedure performing the callback
''When using a compiler and a library, but without illustrative text:''
procedure Map(Values : Value_Array; Worker : Call_Back_Access) is
 
begin
=={{header|Your Language Here}}==
for I in Values'range loop
'''Compiler:''' [[Your Compiler Here]] (Your version here)
Worker(I, Values(I));
[[Category:Your Compiler Here]]
end loop;
 
end Map;
{{libheader|Your Library Here}}
 
-- Define and initialize the actual array
Some code.
Sample : Value_Array := (5,4,3,2,1);
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
begin
 
Map(Sample, Display'access);
----
end Call_Back_Example;
 
''When using an [[interpreter]] and a library, with illustrative text:''
 
=={{header|Your Language Here}}==
'''Interpreter:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]
 
{{libheader|Your Library Here}}
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
Now I'm typing more code, with the spaces again at the beginning of the line.
Now I'm talking about the next bit of code again.
And here's that final bit of code...
 
----
 
''When using an interpreter and a library, but without illustrative text:''
 
=={{header|Your Language Here}}==
'''Interpreter:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]
 
{{libheader|Your Library Here}}
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
 
----
 
''When using a compiler, with illustrative text:''
 
=={{header|Your Language Here}}==
'''Compiler:''' [[Your Compiler Here]]
[[Category:Your Compiler Here]]
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
Now I'm typing more code, with the spaces again at the beginning of the line.
Now I'm talking about the next bit of code again.
And here's that final bit of code...
 
----
 
''When using a compiler, but without illustrative text:''
 
=={{header|Your Language Here}}==
'''Compiler:''' [[Your Compiler Here]] (Your version here)
[[Category:Your Compiler Here]]
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
 
----
 
''When using an interpreter, with illustrative text:''
 
=={{header|Your Language Here}}==
'''Compiler:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
Now I'm typing more code, with the spaces again at the beginning of the line.
Now I'm talking about the next bit of code again.
And here's that final bit of code...
 
----
 
''When using an interpreter, but without illustrative text:
 
=={{header|Your Language Here}}==
'''Interpreter:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
 
----
 
''When you don't know the compiler or interpreter, but you're using a library, and you are using illustrative text:''
 
=={{header|Your Language Here}}==
{{libheader|Your Library Here}}
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
Now I'm typing more code, with the spaces again at the beginning of the line.
Now I'm talking about the next bit of code again.
And here's that final bit of code...
 
----
 
''When you don't know the compiler or interpreter, but you're using a library, and you are not using illustrative text:''
 
=={{header|Your Language Here}}==
{{libheader|Your Library Here}}
 
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
 
----
 
''When you don't know the compiler or interpreter, and you are using illustrative text:''
 
=={{header|Your Language Here}}==
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
Here, I can talk a bit about the next bit of code.
Now I'm typing more code, with the spaces again at the beginning of the line.
Now I'm talking about the next bit of code again.
And here's that final bit of code...
 
----
 
''When you don't know the compiler or interpreter, and you are not using illustrative text:''
 
=={{header|Your Language Here}}==
Some code.
Notice how each line begins with at least one space.
Multiple spaces are fine; Please use proper indentation in your code.
=={{header|Your Language Here}}==
<lang c>int main(){
printf("this is highlighted code");
printf("there is no need for spaces at the start of lines");
return 0;
}</lang>
=={{header|Your Language Here}}==
{{works with|library/compiler/interpreter|Version Number}}
<lang c>int main(){
printf("this is highlighted code");
printf("there is no need for spaces at the start of lines");
return 0;
</lang>
Anonymous user