This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lista = [1..10] |> List.filter(fun x -> x % 2 = 0) | |
match lista with | |
| [] -> printfn "Lista vazia" | |
| _ -> printfn "Head = %i" y.Head |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//C# | |
public T FindInList<T>(IEnumerable<T> source, IEnumerable<T> target) | |
{ | |
return source.First(target.Contains) | |
} | |
//F# | |
let FindInList (source : seq<_>) (target : seq<_>) = source.First(Func<_,bool>(target.Contains)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Color | |
{ | |
private readonly int red; | |
private readonly int green; | |
private readonly int blue; | |
public Color(int red, int green, int blue) | |
{ | |
this.red = red; | |
this.green = green; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
Console.WriteLine("--System.String é imutável"); | |
string linguagem = "F#"; | |
string outraLinguagem = linguagem; | |
outraLinguagem = "Boo"; | |
Console.WriteLine(linguagem); | |
Console.WriteLine(outraLinguagem); | |
Console.WriteLine("--StringBuilder é mutável"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nome = "Rodrigo Vidal" | |
let nome = "Don Syme" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nome = "Rodrigo Vidal" | |
nome = "Don Syme" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let nome = "Rodrigo Vidal" | |
nome <- "Don Syme" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let numerosExtenso = ["Um"; "Dois"; "Três"] | |
let numeros = [1;2;3] | |
let tupla = List.zip numeros numerosExtenso | |
for i, j in tupla do | |
printfn "Numero: %d - Numero por extenso: %s" i j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sumAllMultiplesOf3Or5 list = | |
let mutable total = 0 | |
for i in list do | |
if i % 3 = 0 || i % 5 = 0 then | |
total <- total + i | |
total | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isMultipleOf3Or5 x = x % 3 = 0 || x % 5 = 0 | |
let sumAllMultiplesOf3Or5 list = List.sum (List.filter isMultipleOf3Or5 list) |
OlderNewer