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

Mind map

Higher order functions

Diego Alvarez Informática English

Map content

Higher order functions

  1. Curried functions

    • functions that accepted several parameters
      • space = operator
        • has the highest precedence
    • max 4 5 = (max 4) 5
    • -> (a -> a)
      • a function that takes an a and returns an a
  2. Functions that:

    • take functions as parameters
      • applyTwice :: (a -> a) -> a -> a applyTwice f x = f (f x)
        • the first parameter is a function that takes something and returns that same thing
      • map
        • takes
          • function
            • &&
              • List
                • map :: (a -> b) -> [a] -> [b]
        • applies the function to every element in the list
          • producing a new list.
          • map _ [] = []
            • map f (x:xs) = f x : map f xs
      • filter
        • takes
          • predicate
            • &&
              • List
            • filter :: (a -> Bool) -> [a] -> [a]
        • returns the list of elements that satisfy the predicate
          • filter _ [] = []
            • filter p (x:xs)
              • | p x = x : filter p xs
                • | otherwise = filter p xs
    • return functions as return values
  3. Lambdas

    • anonymous functions
      • expressions too
    • need a function only once?
    • \
  4. Folders

    • reduce the list to some single value.
      • takes
        • binary function
          • takes 2 parameters
        • starting value
        • list
    • fold1
      • folds the list up from the left side
    • foldr
      • folds the list up from the right side
  5. function application

    • $
    • lowest precedence
    • right-associative.
  6. Function composition

    • (f o g) (x)
      • (f (g(x))
    • two functions produces a new function
      • when called with a parameter,
        • is like calling g with the parameter and then calling the f with that result.
    • .

Information

Description
Informática Mind Map on Higher order functions, created by Diego Alvarez on 04/03/2018.
Created by
Diego Alvarez
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?