Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

euphoria
length()
communitycreator

What is the length() function 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

The length() function in Euphoria is used to return the size of a sequence.

The sequence length depends on how many members the sequence has and the number of whitespaces it includes.

Syntax

length(my_seq)
  • my_seq: This is the sequence variable whose size needs to be determined.

Return value

This function returns an atom, which is the length of the sequence.

Code example

The code written below returns the size of the sequence.

--declare atom variables
atom an_atom1, an_atom2, an_atom3
--check the length of different variables
an_atom1 = length({0,1,2,3,4,5,6,7,8,9})
an_atom2 = length({{1,2}, {3,4}, {5,6}})
an_atom3 = length("I am going to win it")
--print the result to output
print(1,an_atom1)
puts(1,"\n")
print(1,an_atom2)
puts(1,"\n")
print(1,an_atom3)

Code explanation

  • Line 2: We declare the atom variables.
  • Lines 5–7: We call the length() method on the sequence and hold the return value in the assigned value.
  • Lines 10, 13, and 16: We print the output values to the screen, using the printf() method.
  • In this code, the puts() methods is used to print new lines.

RELATED TAGS

euphoria
length()
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