get destination point
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=ip), | intent(in), | dimension(2) | :: | initial | ||
| character(len=1), | intent(in) | :: | direction | |||
| integer(kind=ip), | intent(in) | :: | steps |
x,y of desination point
pure function destination(initial, direction, steps) result(final) !! get destination point integer(ip),dimension(2),intent(in) :: initial character(len=1),intent(in) :: direction integer(ip),intent(in) :: steps integer(ip),dimension(2) :: final !! x,y of desination point select case (direction) case('R'); final = [initial(1), initial(2)+steps] case('L'); final = [initial(1), initial(2)-steps] case('D'); final = [initial(1)+steps, initial(2)] case('U'); final = [initial(1)-steps, initial(2)] end select end function destination