Skip to content

Instantly share code, notes, and snippets.

@natebenes
Created March 28, 2010 00:42
Show Gist options
  • Save natebenes/346463 to your computer and use it in GitHub Desktop.
Save natebenes/346463 to your computer and use it in GitHub Desktop.
INTEGER FUNCTION caseDifference(string)
IMPLICIT NONE
CHARACTER (LEN=*), INTENT(IN) :: string
INTEGER :: stringLength = LEN_TRIM(string)
INTEGER :: i, caseDifference
INTEGER :: uppercase = 0, lowercase = 0
DO i = 1, stringLength, 1
IF (LLE("a",string(i:i)) .AND. LGE(string(i:i), "z")) THEN
! Its lowercase
lowercase = lowercase + 1
END IF
IF (LLE("A",string(i:i)) .AND. LGE(string(i:i), "Z")) THEN
! Its uppercase
uppercase = uppercase + 1
END IF
END DO
caseDifference = ABS(lowercase-uppercase)
END FUNCTION caseDifference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment