Euphoria v4
Version of implementation Open Euphoria of programming language EuphoriaFirst open source edition. A major upgrade to the language with a much enlarged functionality and standard library.
Examples:
Hello, World! - Euphoria (84):
The routine puts() writes the second argument (a string) to the device identified by the first argument. There are three predefined devices: 0 is STDIN, 1 is STDOUT, and 2 is STDERR.
puts(1, "Hello, World!\n")
Factorial - Euphoria (85):
This example uses recursive factorial definition.
function factorial(integer n)
atom result
if n <= 1 then
result = 1
else
result = n * factorial(n-1)
end if
return result
end function
for i = 0 to 16 do
printf(1, "%d! = %d\n", {i, factorial(i)})
end for
Factorial - Euphoria (86):
This example uses iterative factorial definition.
function factorial(integer n)
atom result = 1
if n < 1 then
return 1
end if
for i = 2 to n do
result *= i
end for
return result
end function
for i = 0 to 16 do
printf(1, "%d! = %d\n", {i, factorial(i)})
end for
Fibonacci numbers - Euphoria (87):
This example uses recursive definition of Fibonacci numbers.
function fibonacci(integer n)
atom result = 1
if n <= 2 then
result = 1
else
result = fibonacci(n-1) + fibonacci(n-2)
end if
return result
end function
for i = 1 to 16 do
printf(1, "%d, ", fibonacci(i))
end for
puts(1, "...\n")
Fibonacci numbers - Euphoria (88):
This example uses iterative definition of Fibonacci numbers.
function fibonacci(integer n)
sequence result
result = repeat(1, n)
for i = 3 to n do
result[i] = result[i-1] + result[i-2]
end for
return result
end function
sequence ans = fibonacci(16)
for i = 1 to length(ans) do
printf(1, "%d, ", ans[i])
end for
puts(1, "...\n")
Comments
]]>blog comments powered by Disqus
]]>