I have always thought the definition of both of these were functions that take other functions as arguments. I understand the domain of each is different, but what are their defining characteristics?
What is the difference between a combinator and a higher order function?
1.2k views Asked by Tyler Gillies At
1
There are 1 answers
Related Questions in FUNCTIONAL-PROGRAMMING
- On Google Sheets (and only built-in functions allowed, no Google Apps Script) Is it possible to simulate pipe function?
- Why does Enum require to implement toEnum and fromEnum, if that's not enough for types larger than Int?
- Is there a functional way to map a list (N elements) to a list of sums of adjacent elements (N - 1 elements) in Kotlin?
- How to count the occurences of every element in a list in Haskell fast?
- Combine lists with absolute index in functional programming
- How to refactor a loop with iterator. (Returning from closure)
- In Haskell, what does `Con Int` mean?
- Setting up different Java class fields value by a single value on some counter value
- Why doesn't map read show (Integer) work to separate each value in a string of Integers?
- Grouping by multiple fields and counting using in Java 8
- Variable capture: How variables behave in function closures
- Composing React Providers with Value props in Typescript
- How can atomicModifyIORef cause leaks? And why does atomicModifyIORef' solve the problem?
- How can I change XMobar's Kbd monitor plugin such that clicking on it loops throught the layouts?
- How to get success or error data without folding the response while using fpdart in flutter?
Related Questions in DEFINITION
- Defining function in Python whose one argument is list
- VBA script to read values from one worksheet and write to another (set range problem)
- Class A declares Class B as a friend, but Class B has Class A as a member
- Forward declaration struct member access
- Authentication method detail - Password in the cloud
- How to correctly declare function with templated class as return type in header?
- How to define a seperate implementation of a template class constructor
- Go to Definition (F12) not taking you to the correct line in Visual Studio for C/C++ code
- How to check strength password with function and loop while checking off 3 criteria boxes in Python?
- How can i solve a problem by using the outcome of a function as a variable in the following?
- `\d` and `d+` got `relation "pg_catalog.pg_roles" does not exist` error on psql
- PHP empty array definition with starting or ending comma
- MOEA/D optimization
- ruby cucumber how to have different steps call same definition using cucumber expressions
- What is a "Scalar" in PowerShell
Related Questions in HIGHER-ORDER-FUNCTIONS
- Understanding use of closure in callback in javascript
- How do I pass a generic function as an argument to another function in golang?
- How to return withStyle function from another function
- How does combining higher-order functions work in JavaScript?
- SiCP Exercise 1.45
- Custom JVP and VJP for higher order functions in JAX
- How can I get strongly-typed higher order functions in Typescript?
- Linear combination of functions in C++
- Need help understanding whether internal state of viewModel is automatically updated along with ProtoDataStore
- How to access super function when overriding a function using a function passed as a parameter in Javascript?
- How to pass a function that takes an iterator as a function parameter in Rust?
- Replacing single elements in list
- understanding parameters in callbacks and recursion
- I don't understand about higher-order function parameter passed in example
- How to simplify argument templating in functions that return `nom` parsers?
Related Questions in COMBINATORS
- Haskell: Is there a simpler way to express the function (\f g x y -> f (g x) (g y))? Using Applicative ((->) r)?
- How can i affect all content within a tag except a specific child tag
- Is there a Haskell combinator of type `(a -> a -> b) -> (b -> b -> c) -> a -> a -> c`?
- Combining constraints?
- Type-safely Implementing an Arbitrary Degree Blackbird Combinator (B-n Combinator)
- What does Haskell's Data.Function.on do?
- How to unambiguously trim a string with parser combinators?
- Phi combinator in Scala
- Euler function of C(n, k)
- How C++ lambda move capture *this in rvalue reference member function?
- How to implement a fast type inference procedure for SKI combinators in Python?
- How to implement SKI combinators in Prolog?
- Point-free version of g(f(x)(y))
- foldl versus foldr for merge operator
- Creating something similar to a Zip or CombineLatest of IObservables that does not fire all outputs when one updates
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Well, let me try to kind of derive their defining characteristics from their different domains ;)
First of all, in their usual context combinators are higher order functions. But as it turns out, context is an important thing to keep in mind when talking about differences of these two terms:
Higher Order Functions
When we think of higher order functions, the first thing usually mentioned is "oh, they (also) take at least one function as an argument" (thinking of
fold, etc)... as if they were something special because of that. Which - depending on context - they are.Typical context: functional programming, haskell, any other (usually typed) language where functions are first class citizens (like when LINQ made C# even more awesome)
Focus: let the caller specify/customize some functionality of this function
Combinators
Combinators are somewhat special functions, primitive ones do not even mind what they are given as arguments (argument type often does not matter at all, so passing functions as arguments is not a problem at all). So can the identity-combinator also be called "higher order function"??? Formally: No, it does not need a function as argument! But hold on... in which context would you ever encounter/use combinators (like I, K, etc) instead of just implementing desired functionality "directly"? Answer: Well, in purely functional context!
This is not a law or something, but I can really not think of a situation where you would see actual combinators in a context where you suddenly pass pointers, hash-tables, etc. to a combinator... again, you can do that, but in such scenarios there should really be a better way than using combinators.
So based on this "weak" law of common sense - that you will work with combinators only in a purely functional context - they inherently are higher order functions. What else would you have available to pass as arguments? ;)
Combining combinators (by application only, of course - if you take it seriously) always gives new combinators that therefore also are higher order functions, again. Primitive combinators usually just represent some basic behaviour or operation (thinking of S, K, I, Y combinators) that you want to apply to something without using abstractions. But of course the definition of combinators does not limit them to that purpose!
Typical context: (untyped) lambda calculus, combinatory logic (surprise)
Focus: (structurally) combine existing combinators/"building blocks" to something new (e.g. using the Y-combinator to "add recursion" to something that is not recursive, yet)
Summary
Yes, as you can see, it might be more of a contextual/philosophical thing or about what you want to express: I would never call the K-combinator (definition:
K = \a -> \b -> a) "higher order function" - although it is very likely that you will never seeKbeing called with something else than functions, therefore "making" it a higher order function.I hope this sort of answered your question - formally they certainly are not the same, but their defining characteristics are pretty similar - personally I think of combinators as functions used as higher order functions in their typical context (which usually is somewhere between special an weird).
EDIT: I have adjusted my answer a little bit since - as it turned out - it was slightly "biased" by personal experience/imression. :) To get an even better idea about correctly distinguishing combinators from HOFs, read the comments below!
EDIT2: Taking a look at HaskellWiki also gives a technical definition for combinators that is pretty far away from HOFs!