GoConqr has a new look! Let us know what you think.

Mind map

Higher order functions

carlos marin Spanish

Map content

Higher order functions

  1. Haskell functions can take functions as parameters and return functions as return values

  2. Curried functions

    • Putting a space between two things is simply function application.
  3. partially applied function

    • that takes as many parameters as we left out
  4. Infix functions

    • To section an infix function, simply surround it with parentheses and only supply a parameter on one side
      • That creates a function that takes one parameter and then applies it to the side that's missing an operand
  5. Functions can take functions as parameters and also return functions.

    • applyTwice :: (a -> a) -> a -> a applyTwice f x = f (f x)
      • They indicate that the first parameter is a function that takes something and returns that same thing.
  6. The body of the function is pretty simple. We just use the parameter f as a function, applying x to it by separating them with a space and then applying the result to f again.

  7. zipWith

    • takes a function and two lists as parameters and then joins the two lists by applying the function between corresponding elements
  8. Functional programming

    • uses higher order functions to abstract away common patterns, like examining two lists in pairs and doing something with those pairs or getting a set of solutions and eliminating the ones you don't need.
  9. flip

    • takes a function and returns a function that is like our original function, only the first two arguments are flipped.
  10. Maps and filters

    • map
      • takes a function and a list and applies that function to every element in the list, producing a new list.
      • chain function
        • numLongChains :: Int
          • because length returns an Int instead of a Num a
    • filter
      • takes a predicate (a predicate is a function that tells whether something is true or not, so in our case, a function that returns a boolean value) and a list and then returns the list of elements that satisfy the predicate.
      • && function.
  11. Lambdas \

    • anonymous functions that are used because we need some functions only once
      • we make a lambda with the sole purpose of passing it to a higher-order function.
        • lambdas can take any number of parameters:
  12. Only folds and horses

    • A fold takes a binary function, a starting value (I like to call it the accumulator) and a list to fold up.

Information

Description
Mind Map on Higher order functions, created by carlos marin on 27/02/2018.
Created by
carlos marin
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?