O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Cap 4 Syntax in Functions

MENESES CHAVARRIA XUASY SANTIAGO Espanhol

Cap 4 Syntax in Functions

Conteúdo do mapa

Cap 4 Syntax in Functions

  1. Pattern matching

    • consists of specifying patterns to which some data should conform and then checking to see if it does and deconstructing the data according to those patterns.
      • When defining functions, you can define separate function bodies for different patterns.
        • the order is important when specifying patterns and it's always best to specify the most specific ones first and then the more general ones later.
          • example
            • length' :: (Num b) => [a] -> b length' [] = 0 length' (_:xs) = 1 + length' xs
              • First we defined the result of a known input — the empty list.
              • Then in the second pattern we take the list apart by splitting it into a head and a tail.
        • we should always include a catch-all pattern so that our program doesn't crash if we get some unexpected input.
  2. Guards

    • guards are a way of testing whether some property of a value are true or false
      • A guard is basically a boolean expression.
      • the last guard is otherwise. otherwise is defined simply as otherwise = True and catches everything
      • no use = right after the function name and its parameters, before the first guard.
    • Guards are indicated by pipes that follow a function's name and its parameters.
  3. Where

    • Is a condition
      • and we put the keyword where after the guards
        • and then we define several names or functions
          • The names we define in the where section of a function are only visible to that function
        • we usualy aligned at a single column
      • where bindings can also be nested
  4. Let

    • are a syntactic construct
      • Let bindings let you bind to variables anywhere and are expressions themselves
        • it can also put let bindings inside list comprehensions
      • The form is let <bindings> in <expression>
    • are very local, so they don't span across guards
  5. Case expressions

    • blocks of code for specific values of that variable
    • we can do pattern matching
      • evaluating pieces of code based on its value

Imagens e arquivos do mapa

  • Cap 4 Syntax in Functions
  • Cap 4 Syntax in Functions

Informações

Descrição
Mapa Mental sobre Cap 4 Syntax in Functions, criado por MENESES CHAVARRIA XUASY SANTIAGO em 19-02-2018.
Criado por
MENESES CHAVARRIA XUASY SANTIAGO · fev 2018
Atualizado
7 mar 2018
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?