Euphoria (programming language)
Euphoria is a programming language and interpreter that was developed by Robert Craig for Rapid Deployment Software . The first version of Euphoria appeared in 1993 for the Atari ST , the current version 4.0.5 (as of January 25, 2013) is available for Windows , Linux , FreeBSD and MS-DOS . From version 3.0.0 onwards, Euphoria is under an open source license.
The goal when developing Euphoria was to develop a programming language that was particularly easy to learn, but powerful, and which should also keep up with compiled languages in terms of speed . This goal has now been achieved. In addition, the manufacturer offers a tool with which Euphoria code can be translated into the programming language C and then compiled. Euphoria comes with a simple database.
The website also contains a user-contributed collection of more than 1,600 programs in source code for a wide variety of applications.
example
Here is a code example from the manual:
sequence list, sorted_list
function merge_sort(sequence x)
integer n, mid
sequence merged, a, b
n = length(x)
if n = 0 or n = 1 then
return x -- trivial case
end if
mid = floor(n/2)
a = merge_sort(x[1..mid]) -- sortiert die erste Hälfte von x
b = merge_sort(x[mid+1..n]) -- sortiert die zweite Hälfte von x
merged = {}
while length(a) > 0 and length(b) > 0 do
if compare(a[1], b[1]) < 0 then
merged = append(merged, a[1])
a = a[2..length(a)]
else
merged = append(merged, b[1])
b = b[2..length(b)]
end if
end while
return merged & a & b
end function
procedure print_sorted_list()
list = {9, 10, 3, 1, 4, 5, 8, 7, 6, 2}
sorted_list = merge_sort(list)
? sorted_list
end procedure
print_sorted_list()
The program then gives
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
out.
The central data type of Euphoria are so-called sequences. Here's an example:
{2, 3, 5, 7, 11, 13, 17, 19}
{1, 2, {3, 3, 3}, 4, {5, {6}}}
{{"jon", "smith"}, 52389, 97.25}
{}
{x+6, 9, y*w+2, sin(0.5)}
Sequences can be nested within one another as required. This makes it very easy to display trees , for example .