### 1a. Complete the function definition below. Write a *pure* function the filters a series. Filtering a series should work like filtering an array. Be sure to preserve the type of the series. That is, if the input series has a 'NUMBER' type, then the filtered series should also have a 'NUMBER' type. Example: filterSeries(s1, (x: number) => x > 1) = { type: 'NUMBER', entries: [ { id: 1, data: 2 }, { id: 2, data: 3 } } Example: filterSeries (s1, (x: number) => x === 2) = { type: 'NUMBER', entries: [ { id: 1, data: 2 } } Example: filterSeries (s1, (x: number) => x < 0) = { type: 'NUMBER', entries: [] } export function filterSeries(s: series, f: (arg: T) => boolean): series { throw Error("TODO"):

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 28SA
icon
Related questions
Question

TYPESCRIPT PLEASE

**
### 1a. Complete the function definition below.
Write a *pure* function the filters a series.
Filtering a series should work like filtering an array.
Be sure to preserve the type of the series. That is, if the input
series has a 'NUMBER' type, then the filtered series should also
have a 'NUMBER' type.
Example:
filterSeries(s1, (x: number) => x > 1) = {
type: 'NUMBER',
entries: [
{ id: 1, data: 2 },
{ id: 2, data: 3 }
}
Example:
filterSeries(s1, (x: number) => x === 2) = {
type: 'NUMBER',
entries: [
{ id: 1, data: 2 }
}
Example:
filterSeries (s1, (x: number) => x < 0) = {
type: 'NUMBER',
entries: []
}
**
export function filterSeries<T>(s: series<T>, f: (arg: T) => boolean): series<T> {
throw Error("TODO");
}
Transcribed Image Text:** ### 1a. Complete the function definition below. Write a *pure* function the filters a series. Filtering a series should work like filtering an array. Be sure to preserve the type of the series. That is, if the input series has a 'NUMBER' type, then the filtered series should also have a 'NUMBER' type. Example: filterSeries(s1, (x: number) => x > 1) = { type: 'NUMBER', entries: [ { id: 1, data: 2 }, { id: 2, data: 3 } } Example: filterSeries(s1, (x: number) => x === 2) = { type: 'NUMBER', entries: [ { id: 1, data: 2 } } Example: filterSeries (s1, (x: number) => x < 0) = { type: 'NUMBER', entries: [] } ** export function filterSeries<T>(s: series<T>, f: (arg: T) => boolean): series<T> { throw Error("TODO"); }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning