array_list_nearest Function

private pure function array_list_nearest(this, item, subtraction)

Arguments

Type IntentOptional AttributesName
class(array_list), intent(in) :: this
class(*), intent(in) :: item

The value which those in the list are being compared to

procedure(subtraction_func) :: subtraction

A function determining the magnitude of the difference between two items

Return Value class(container), allocatable

The value from the list which, when passed to subtraction with item as the other argument, returns the smallest value

Description

Returns the value contained in the list for which the subtraction function returns the smallest absolute real number when comparing with the specified item.


Source Code

  pure function array_list_nearest(this, item, subtraction)
    !* Author: Chris MacMackin
    !  Date: March 2016
    !
    ! Returns the value contained in the list for which the subtraction
    ! function returns the smallest absolute real number when comparing
    ! with the specified `item`.
    !
    class(array_list), intent(in) :: this
    class(*), intent(in) :: item
      !! The value which those in the list are being compared to
    procedure(subtraction_func) :: subtraction
      !! A function determining the magnitude of the difference
      !! between two items
    class(container), allocatable :: array_list_nearest
      !! The value from the list which, when passed to `subtraction`
      !! with `item` as the other argument, returns the smallest value
  end function array_list_nearest