Skip to main content

All Questions

-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
0 votes
1 answer
46 views

How to evaluate datatype and true_of_all_constants functions?

I am a beginner of sml and I'm taking programming language courses at Coursera. There's a datatype and function that I don't know how to evaluate: datatype exp = constant of int | Negate of exp ...
Vivian Miller's user avatar
0 votes
1 answer
84 views

Higher order functions scala

Suppose we have this function definition and invocation: def sayHello(prefix:String):(String => String) = { n => s"$prefix $n" } val greeting = sayHello("Hello") greeting("Gio") Using ...
Giorgio's user avatar
  • 1,103
0 votes
1 answer
422 views

How to create a function that returns a function of the product of a list of functions

I would like to create a function that returns a function of the product of a list of functions. The list of functions should be of variable length and the functions should have different parameters. ...
Frits's user avatar
  • 89
1 vote
2 answers
56 views

Higher Order Function invocation strange behavior

I have been playing with the code above and still don't know why is it behaving like this: function myforEach(arr, func){ for(var i=0; i<arr.length; i++){ func(); } } var arr = [1,2,3]; ...
Alonso's user avatar
  • 43
0 votes
1 answer
40 views

Higher Order Function invocation behavior is very confusing

I am trying to invoke a function within a function which is not a big deal but for some reason i don't understand why i can't invoke a function through this logic: function func1(futurefunc){ ...
Alonso's user avatar
  • 43
6 votes
3 answers
359 views

Functional programming axioms

I'm learning functional programming with Clojure, and want to deepen my theoretical understanding of functional paradigm (not just the syntax of Clojure). I'm looking for axioms or formulas how each ...
Tuomas Toivonen's user avatar
0 votes
1 answer
55 views

R: closure can't find object until called

I have a problem with a higher order function in R: power <- function(x , modify){ return( function(y){ return( modify( y^x ) ) } ) } mod <- function(z){z+1} sq <-...
David Heckmann's user avatar
3 votes
1 answer
4k views

Calling curried functions in Scala?

So I am a bit confused as to how curried functions in Scala work. I have the following code which compiles, but I am not sure how! def fixedPoint(f: Double => Double, initialGuess: Double) = { /...
user1974753's user avatar
  • 1,467
1 vote
3 answers
150 views

Can somebody help me write and understand the partial application pattern?

I'm trying to write a function utilizing callback that will mimic this behavior: var fullName = function (firstName, lastName) { return firstName + ' ' + lastName; }; var michaelName = partial(...
phizzy's user avatar
  • 956
6 votes
2 answers
396 views

Different brackets style on Scala function definition parameter list

What is the difference of the following two function definitions in Scala: 1) def sum(f: Int => Int)(a: Int, b: Int): Int = { <code removed> } 2) def sum(f: Int => Int, a: Int, b: Int): ...
user67321's user avatar
7 votes
5 answers
2k views

Haskell Programmatically/Dynamically Define Functions

I'm looking for a way to dynamically define functions in Haskell, or for Haskell's idiomatic equivilent of which I'm clearly not aware. The scenario is as follows: I have a tagWithAttrs function that ...
Louis Jackman's user avatar
1 vote
4 answers
2k views

How do I create Haskell functions that return functions?

I would like to create three Haskell functions: a, b, and c. Each function is to have one argument. The argument is one of the three functions. I would like function a to have this behavior: if the ...
Roger Costello's user avatar
3 votes
3 answers
117 views

How do some programming languages distinguish between a function and a function pointer?

I'm talking mostly about functional programming languages. For example, the wikipedia article for map has this example in a Haskell-ish language: map square [1,2,3,4,5] How does the parser/compiler ...
user avatar
33 votes
14 answers
7k views

What are some interesting uses of higher-order functions?

I'm currently doing a Functional Programming course and I'm quite amused by the concept of higher-order functions and functions as first class citizens. However, I can't yet think of many practically ...
Manuel Araoz's user avatar
  • 16.4k