Help:Programming Example Prototypes: Difference between revisions

From Rosetta Code
Content added Content deleted
m (Call Back Array: Ada moved to Help:Programming Example Prototypes: Moved BACK where it belongs. Need to revert to previous version of the page.)
(Reverted to correct version of the page. Be Careful! Please!)
Line 1: 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]]==

Use the one which supplies the most information possible.

=Prototypes=
----

''When using a [[compiler]] and a [[library]], with illustrative text:

==[[Your Language Here]]==
[[Category:Your Language Here]]
[[Category:Your Language Here]]
'''Compiler:''' [[Gnat]] (GPL 2005)
'''Compiler:''' [[Your Compiler Here]] (Your version here)
[[Category:GNAT GPL 2005]]
[[Category:Your Compiler Here]]


'''Library:''' [[Your Library Here]]
with Ada.Text_Io;
[[Category:Your Library Here]]
with Ada.Integer_text_IO;

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 and a library, but without illustrative text:

==[[Your Language Here]]==
[[Category:Your Language Here]]
'''Compiler:''' [[Your Compiler Here]] (Your version here)
[[Category:Your Compiler Here]]

'''Library:''' [[Your Library Here]]
[[Category: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 an [[interpreter]] and a library, with illustrative text:

==[[Your Language Here]]==
[[Category:Your Language Here]]
'''Interpreter:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]

'''Library:''' [[Your Library Here]]
[[Category: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:

==[[Your Language Here]]==
[[Category:Your Language Here]]
'''Interpreter:''' [[Your Interpreter Here]] (Your version here)
[[Category:Your Interpreter Here]]

'''Library:''' [[Your Library Here]]
[[Category: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:

==[[Your Language Here]]==
[[Category: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:

==[[Your Language Here]]==
[[Category: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:

==[[Your Language Here]]==
[[Category: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:

==[[Your Language Here]]==
[[Category: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:

==[[Your Language Here]]==
[[Category:Your Language Here]]
'''Library:''' [[Your Library Here]]
[[Category: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:

==[[Your Language Here]]==
[[Category:Your Language Here]]
'''Library:''' [[Your Library Here]]
[[Category: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:

==[[Your Language Here]]==
[[Category: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:

==[[Your Language Here]]==
[[Category:Your Language Here]]


Some code.
procedure Call_Back_Example is
Notice how each line begins with at least one space.
-- Purpose: Apply a callback to an array
Multiple spaces are fine; Please use proper indentation in your code.
-- Output: Prints the squares of an integer array to the console
-- Define the callback procedure
procedure Display(Location : Positive; Value : Integer) is
begin
Ada.Text_Io.Put("array(");
Ada.Integer_Text_Io.Put(Item => Location, Width => 1);
Ada.Text_Io.Put(") = ");
Ada.Integer_Text_Io.Put(Item => Value, Width => 1);
Ada.Text_Io.New_Line;
end Display;
-- Define an access type matching the signature of the callback procedure
type Call_Back_Access is access procedure(L : Positive; V : Integer);
-- Define an unconstrained array type
type Value_Array is array(Positive range <>) of Integer;
-- Define the procedure performing the callback
procedure Map(Values : Value_Array; Worker : Call_Back_Access) is
begin
for I in Values'range loop
Worker(I, Values(I));
end loop;
end Map;
-- Define and initialize the actual array
Sample : Value_Array := (5,4,3,2,1);
begin
Map(Sample, Display'access);
end Call_Back_Example;

Revision as of 03:54, 3 February 2007

These are prototypes of well-formed programming examples conforming to curring Rosetta Code formatting style. View this page's source to see how to construct your own programming examples.

Use the one which supplies the most information possible.

Prototypes


When using a compiler and a library, with illustrative text:

Your Language Here

Compiler: Your Compiler Here (Your version here)

Library: 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 a compiler and a library, but without illustrative text:

Your Language Here

Compiler: Your Compiler Here (Your version here)

Library: 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 an interpreter and a library, with illustrative text:

Your Language Here

Interpreter: Your Interpreter Here (Your version here)

Library: 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:

Your Language Here

Interpreter: Your Interpreter Here (Your version here)

Library: 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:

Your Language Here

Compiler: 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:

Your Language Here

Compiler: Your Compiler Here (Your version 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:

Your Language Here

Compiler: Your Interpreter Here (Your version 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:

Your Language Here

Interpreter: Your Interpreter Here (Your version 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:

Your Language Here

Library: 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:

Your Language Here

Library: 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:

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:

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.