Introduction

Seja bem-vindo à

Destaques

Utilize pattern matching com valores opcionais e valores Either

Option<int> optionalValue = 10;
int value = optionalValue.Match(
        methodWhenSome: number => number,
        methodWhenNone: () => 0);

Either<bool, int> eitherValue = 10;
int value = eitherValue.Match(
        methodWhenRight: number => number,
        methodWhenLeft: boolean => 0);

Crie processos contínuos utilizando Then e Catch

Continuation<string, int> continuation = 5;

continuation.Then(value => value + 4)
            .Then(value => 
                  {
                    if( value % 2 == 0)
                        return value + 5;
                    else
                        return "ERROR";
                  })
            .Then(value => value + 10)
            .Catch(fail => $"{fail} catched");

Crie processos contínuos utilizando pipeline!

continuation 
    >  (value => value + 4)
    >  (value => 
       {
          if( value % 2 == 0)
              return value + 5;
          else
              return "ERROR";
       })
    >  (value => value + 10)
    >= (fail => $"{fail} catched")

Utilize Poderosas Funções de alta ordem!

//IEnumerable<int> source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
IEnumerable<IEnumerable<int>> result = source.ChunkBySize(3);

//result = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9},  {10} }

var (resultEvens, resultOdds) = 
    source.Partition(value => value % 2 == 0)

//resultEvens = { 2, 4, 6, 8, 10 }
//resultOdds = { 1, 3, 5, 7, 9 }

Utilize operações para redução!

int result = source.Scan(10, IntegerOperations.Add);
//result = {11, 13, 16, 20, 25, 31, 38, 46, 55, 65}

Utilize Curry e Aplicação Parcial!

Func<int, int, int> add =
    (value, value2) => value + value2;

Func<int, Func<int, int>> addCurried = add.Curry();
curriedResult = addCurried(2)(3);

Func<int, int> addPartial = add.PartialApply(2);
int partialResult = addPartial(3);

Aproveite o QuickDelegateCast!

using static Tango.Functional.QuickDelegateCast;

int SampleAdd(int value1, int value2)
    => value1 + value2;

F<int, int, int>(SampleAdd).Curry();
F<int, int, int>(SampleAdd).PartialApply(1);

Totalmente Gratuita

A Tango é completamente gratuita, tanto a biblioteca quanto sua documentação, além disso, você pode baixar seu PDF para ler offline!

Faça download do livro da documentação :

Índice

Aqui você encontra todos os tópicos disponíveis nesta documentação.

Começando

Instalação

Conceitos

Funcional

Operações

Tipos

Módulos

Extensões

Last updated