Skip to main content

All Questions

0 votes
1 answer
46 views

function returning None (functional programming) [duplicate]

I'm trying to make an functional function and I want it to return an array (ndarray). I don't know why, but my code is returning None. Here's my code: def upgrade_array(array:np.ndarray, max_value:int,...
MarnieGrenat's user avatar
5 votes
2 answers
413 views

Vector of functions in APL

What is the syntax for a vector (array) of functions in APL? I have tried the following but these are interpreted as a 3-train and a 2-train, respectively: {1},{2} {1} {2} PS. I am looking to do ...
P Varga's user avatar
  • 20.3k
0 votes
1 answer
321 views

Array Assignment in Functional Programming JS [closed]

When declaring a new local variable inside a function and assigning it to a global variable that is equal to an array, what is better? Option 1: Using the Spread Operator: let globalArray = [1, 2, 4]; ...
Egor Ulybin's user avatar
-1 votes
2 answers
123 views

List self nesting in Javascript

Question I am trying to achieve a function that transforms a list into a second list with two sublist of itself. This function must do so by being called in a chain i.e [1,2,3] => [[1,2,3],[1,2,3]]...
cstml's user avatar
  • 390
1 vote
2 answers
326 views

what is the difference between filtering on accumulator/current in reduce method

When chaining the Array.prototype.reduce with Array.prototype.filter what is the difference (conceptually and under the hood) when filtering on the current value instead of the accumulator value? // ...
securethebags's user avatar
-1 votes
1 answer
67 views

Why doesn't JS complier recognize this call to Array.prototype.filter

I am trying to figure out why my call to .prototype.filter is giving me a TypeError: curr.filter is not a function. const intersection = (arrays) => { return arrays.reduce((acc, curr) => { ...
securethebags's user avatar
1 vote
1 answer
48 views

Typescript array of function traversal question

My program has a place where many conditions are checked. As opposed to writing a big if(conditionOne || conditionTwo || ...) type of expressions, I decided to define an array of filters like so: ...
saæ's user avatar
  • 193
0 votes
4 answers
86 views

How does this functional Javascript example work?

I just don't seem to be able to wrap my head around this snippet of code. Could you give me a hint or two on it? var filteredList = watchList.map(function(e) { return {title: e["Title"], rating: ...
user avatar
1 vote
1 answer
627 views

Receive array of either Int or Double in Scala function

I have the following normalization function: ... private def NormalizeValues(dataValues: Array [Double]): Array[Double] = { val min = dataValues.min val max = dataValues.max dataValues.map(v => (...
Cristina HG's user avatar
0 votes
4 answers
92 views

How to make my JS solution functional?

I've got some data that came from classy service in Angular that looks like this (briefly): const obj = { field: [ { id: 1, items: [] }, { id: 2, items: [ { ...
impregnable fiend's user avatar
2 votes
4 answers
121 views

Why passing function reference is failing while using function declaration is not?

Following code fails: array.map(String.prototype.toLowerCase) Throws Uncaught TypeError: String.prototype.toLowerCase called on null or undefined. Indeed, this is not set, I got it. But what's weird ...
sp00m's user avatar
  • 48.9k
0 votes
1 answer
902 views

2D array in F Sharp

I have just started learning f# and developed a basic game however, at the moment you specify the cell to play on using a single array. For example to place an X or O on the middle cell, you would ...
NaNaNiii's user avatar
0 votes
2 answers
201 views

JavaScript function composition from 3 functions

I'm using Vue and trying to filter an array of results using a JS function composition. My Vue computed values are like so, but can't get filteredByAll to accept a third option getByThing. Right now ...
Steven Grant's user avatar
  • 1,325
0 votes
0 answers
34 views

Why Doesn't Copied Array Equal Original Array? [duplicate]

I've been learning more about functional programming and the idea of keeping functions pure. So I experimented with taking an array and making a copy of it with the slice function like so... var ...
Reginald Davis's user avatar
12 votes
6 answers
1k views

An alternative to an array of functions?

I'm programming an app (php) which requires a very long list of similar yet different functions, which are being called by a set of keys: $functions = [ "do this" => function() { // ...
Roy's user avatar
  • 987