How to resolve the algorithm Filter step by step in the EasyLang programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Filter step by step in the EasyLang programming language

Table of Contents

Problem Statement

Select certain elements from an Array into a new Array in a generic way.

To demonstrate, select all even numbers from an Array. As an option, give a second solution which filters destructively, by modifying the original Array rather than creating a new Array.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Filter step by step in the EasyLang programming language

Source code in the easylang programming language

a[] = [ 1 2 3 4 5 6 7 8 9 ]
for i = 1 to len a[]
  if a[i] mod 2 = 0
    b[] &= a[i]
  .
.
print b[]


  

You may also check:How to resolve the algorithm Sum digits of an integer step by step in the Action! programming language
You may also check:How to resolve the algorithm Comments step by step in the PASM programming language
You may also check:How to resolve the algorithm Determine if a string has all the same characters step by step in the Julia programming language
You may also check:How to resolve the algorithm Sort three variables step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Memory allocation step by step in the Rust programming language