Jump to content

Apply a callback to an array: Difference between revisions

Line 354:
 
=={{header|Fortran}}==
In ISO Fortran 95 or later, use elemental functions:
ELEMENTAL FUNCTION CUBE( X )
IMPLICIT NONE
Line 365:
IMPLICIT NONE
INTEGER :: I, J
REAL, DIMENSION(203,4) :: B, &
A = RESHAPE( (/ ((0.1 * I + J, I = 1, 20), J = 1, 4) /), (/ 203,4 /) )
DO I = 1, 3
WRITE(*,*) A(I,:)
END DO
B = CUBE( A ) ! Applies CUBE to every member of A,
! and stores each result in the equivalent element of B
DO I = 1, 203
WRITE(*,*) B(I,:)
END DO
END PROGRAM EXAMPLE
 
 
ANSI FORTRAN 77 (with MIL-STD-1753 structured DO) Example:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.