OE update using_euphoria 2

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...


... back to index page OE documentation

end procedure 
print_sorted_list()     -- this command starts the program 

The above example contains a number of statements that are processed in order.

include std/console.e
This tells Euphoria that this application needs access to the public symbols declared in the file 'std/console.e'. This is referred to as a library file. In our case here, the application will be using the display routine from
sequence original_list
This declares a variable that is not public but is accessible from anywhere in this file. The datatype for the variable is a sequence, which is a variable-length "array," and whose symbol name is original_list.
function merge_sort(sequence x) ... end function
This declares and defines a function routine. Functions return values when called. This function must be passed a single parameter when called -- a sequence.
procedure print_sorted_list() ... end procedure
This declares and defines a procedure routine. Procedures never return values when called. This procedure must not be passed any parameters when called.
This calls the routine called print_sorted_list.
The output from the program will be:
Number 10 was at position  2, now at  1 
Number 19 was at position  1, now at  2 
Number 23 was at position  3, now at  3 
Number 32 was at position 10, now at  4 
Number 41 was at position  4, now at  5 
Number 55 was at position  6, now at  6 
Number 67 was at position  8, now at  7 
Number 76 was at position  9, now at  8 
Number 84 was at position  5, now at  9 
Number 98 was at position  7, now at 10 

Note that merge_sort will just as easily sort any list of data items:

{1.5, -9, 1e6, 100} 
{"oranges", "apples", "bananas"} 

This example is stored as euphoria\tutorial\example.ex. This is not the fastest way to sort in Euphoria. Go to the euphoria\demo directory and type

eui allsorts 

to compare timings on several different sorting algorithms for increasing numbers of objects.

For a quick tutorial example of Euphoria programming, see euphoria\demo\bench\filesort.ex.

What to Do?

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu