A sequence in Euphoria contains data which can be of different data types. These values can be checked in search of different results, like to get a match, the index of values, the smallest and even the largest value in the sequence. In this shot, we’ll look at a simple function to obtain the largest value.
largest()
?The members of a sequence can be searched through in order to get the largest value amongst the set using the largest()
method. This method is inbuilt into the standard library search
module/package in Euphoria. It requires just a single parameter, which is the array to be searched.
From the image below, we can see how a sequence was queried and the largest value among them returned. It is a simple illustration of how the largest
method works.
largest(array_value)
array_value
: This is a set of integer values from which the largest value should be returned.
The function will return the largest value from the set.
include std/stats.e atom output sequence my_seq my_seq = {1,2,4,40,8,10,50} output = largest(my_seq) printf(1,"this will output empty because it is a text value \n", largest({"This is a text","Another text"})) printf(1,"This is the largest value from {1,2,4,40,8,10,50}: %d",output)
stats.e
from the standard library.output
and a my_seq
, respectively.largest()
method as the value of the variable output
.Note: This function only works on a set of numbers and not a set of any other characters.
RELATED TAGS
CONTRIBUTOR
View all Courses