Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

euphora
communitycreator

What is the equal() method in Euphoria?

NDUKWE CHIDERA K.

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

In Euphoria, equal() is a built-in routine of the standard library, which is used to draw an equality comparison between two variables, and return either 0 or 1 depending on the outcome of the comparison.

Syntax

equal(left_val,right_val)

Parameters

This method takes two parameters left_val and right_val. These represent the values for which we’re checking equality. They can be of atom, sequence, or object data type.

Return Value

The function returns the value 1 if both right_val and left_val are equal. Otherwise it returns 0.

sequence month ="JULY"
atom age = 20
--look to check equality of two sequences
if equal(month, "JUly") or equal(month, "JULY") then
printf(1, "month is: %s \n", {month})
end if
--loop to check age
if equal(age, 30) or equal(month, 40) then
printf(1, "month is: %s", {month})
else
puts(1,"age not matched")
end if

Explanation

  • Lines 1 and 2: We define two variables age and month in the atom data type.
  • Lines 5–7: The if statement uses the equal() method to check for equality of the defined sequence in its condition.
  • Lines 10–14: We repeat the same function as we did in lines 5–7. However, we execute an else block if the equal() method finds no equality between the atoms being compared.

RELATED TAGS

euphora
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring