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 best solutions below
Related Questions in FUNCTIONAL-PROGRAMMING
- Access into a Binary Search Tree via a bound function in a function template
- Convert loop to Maybe monad
- Lazy concat in Immutable.js?
- Erlang syntax error unclear
- What is the type of the variable in do-notation here in Haskell?
- Lazy functions evaluation in swift
- Standard ML / NJ: Loading in file of functions
- First Object in Set<Future<Object>> that satisfies a predicate
- How to write a type that is isomorphic to Tree without nested lists?
- Functional way of doing a loop of operations on an array
- Good practice on how to store the result of a function for later use in R
- Apply a list of Functions to a Java stream's .map() method
- First word of binary string erlang
- Easier way to apply multiple arguments in Haskell
- scala : use of braces for a function when the parameter is a predicate
Related Questions in DEFINITION
- check function definition php
- "Multiple definition", "first defined here" errors
- F# Circular Type Definition Loop
- Why does my compiler insist on unused function definitions only for virtual?
- Declaring functions and variables multiple times in C++
- How can I implement my explicit override outside the class declaration?
- Can you define a static method outside of a class?
- What does it mean to 'trace' something in Java?
- definition of the term "syntactic form"
- Understanding the Instruments Time Profiler column headings
- Cscope output all parameters
- Curry-Howard isomorphism definitions in Coq using fun
- Why is a typedef declaration not called a typedef definition?
- How to get SpecFlow to change step definition when renaming step in feature file?
- SOAP request deconstruction
Related Questions in HIGHER-ORDER-FUNCTIONS
- JS - Calling an Object by one of it's properties
- Having trouble stepping through function that reduces an array of functions
- Using the reduce method to eliminate any duplicated numbers
- How to effectively get indices of 1s for given binary string using Scala?
- How to fix a higher-order function to simulate a joint bank account?
- Tail-Recursive Function (Coursera Issues)
- Scala Option higher order functions instead of pattern matching
- Scala: Higher order function to return the union of sets
- How does lazy-evaluation allow for greater modularization?
- Scala / Lists - any way to refer to current filtered list to get size of current (not size of original)
- React: Is it possible to call a higher-order component within a container component?
- Strange behaviour of list comprehensions
- splitAt '-' in scala
- Is applyTwice a well-known Haskell idiom?
- How to wait for the result of a nested asynchronous function before returning the main function
Related Questions in COMBINATORS
- mathematical calculations for larger values in c++
- How to Merge two Observables so the result completes when the any of the Observables completes?
- How does Data.MemoCombinators work?
- Designing a monadic type
- What is the difference between a combinator and a higher order function?
- for fixed point combinator Y, what is \x.f(xx)
- Combining two strings into one string which eliminates the same letters in C
- "updateDet" shouldnt recognize as keyword "update"
- What does Haskell's Data.Function.on do?
- How to create a K combinator in the enchanted forest? (To Mock a Mockingbird)
- Combinatory method like tap, but able to return a different value?
- F# return list of list lengths
- Getting the length of a list using combinators f#
- How does foldr work?
- Short circuiting (&&) in Haskell
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)
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?
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!