Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

methods
euphoria
communitycreator

What is the store() 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.

Answers Code

Overview

The store() method is used to store a value in any location in another value. With the store() method, we can place a value at a selected position in another sequence using an index.

Syntax

store(target,indexes, obj_value)

Parameters

Below are the parameters of this function:

  • target: This is the sequence variable into which we want to store some variables at the indicated index location.

  • indexes: This is a sequence of integers, the path to follow to reach the index where we want to store the variable. This is simply the index position in the target where the new value will be inserted, replacing the old value there.

  • obj_value: This is the object variable to be stored. This value will be inserted at the specified location in the target.

Return value

It returns a modified form of the target, which has obj_value inserted at the specified position on successful execution.

Note: The function can throw an illegal sequence operation error if we provide an invalid index.

Example

include std/sequence.e
--declare a sequence variable
sequence stores1, stores2
--apply the store()
stores1 = store( {5,6,7,8,9,{1,2,3,4,{1,2,3,4,5}}},{6}, 120)
--apply the store()
stores2 = store( {5,6,7,8,9,{1,2,3,4,{1,2,3,4,5}}},{6,5}, 120)
--print the output of the store method operation in stores.
print(1,stores1)
puts(1,'\n')
print(1,stores2)

Explanation

  • Line 1: We include the search.e module from Euphoria’s standard memory.

  • Line 4: We declare some sequence of the store operation.

  • Line 7–10: We declare some sequences of the store operation.

  • Line 11–13: We print the output of the value to display.

RELATED TAGS

methods
euphoria
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.

Answers Code
Keep Exploring