Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

communitycreator
euphoria

# How to get the largest value from a set of values in Euphoria

NDUKWE CHIDERA K.

### Introduction

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.

### What is 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.

An illustration of how the largest() method works

### Syntax

largest(array_value)


### Parameters

array_value: This is a set of integer values from which the largest value should be returned.

### Return value

The function will return the largest value from the set.

### Example

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)
Functionality of the largest() function

### Explanation

• Line 1: We import the statistics module stats.e from the standard library.
• Line 3–4: We declare some variables, an output and a my_seq, respectively.
• Line 5: We assign a value to the sequence declared earlier.
• Line 7: We save the outcome of the largest() method as the value of the variable output.
• Line 8–9: We print some result to the output.

Note: This function only works on a set of numbers and not a set of any other characters.

RELATED TAGS

communitycreator
euphoria

CONTRIBUTOR

NDUKWE CHIDERA K.
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time