Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Fortran
module foo
  implicit none
contains
  function square(i) result(res)
    integer, intent(in) :: i
    integer :: res
    res = i * i
  end function square
end module foo

Modern Fortran code should use modules, so I put the function into one.
function Square (X : Integer) return Integer is
begin
   return X * X;
end Square;

New implementation...
< >
programming-idioms.org