Last active
December 20, 2015 16:09
-
-
Save cleytonferrari/6159063 to your computer and use it in GitHub Desktop.
Exemplo de uso em F#, fui pesquisando e consegui chegar nisso, o meu helloWorld
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 somar (n1:int) (n2:int) = n1 + n2 | |
let subtrair = fun n1 n2 -> n1 - n2 | |
let multiplicar n1 n2 = n1 * n2 | |
module Calculadora = | |
let somar n1 n2 = n1 + n2 | |
let subtrair = fun n1 n2 -> n1 - n2 | |
let rec fatorial n = | |
if n = 0 | |
then 1 | |
else n * fatorial (n - 1) | |
System.Console.Write("Digite 1º número: ") | |
let n1 = System.Int32.Parse(System.Console.ReadLine()) | |
System.Console.Write("Digite 2º número: ") | |
let n2 = System.Int32.Parse(System.Console.ReadLine()) | |
System.Console.WriteLine("Somar: {0}", somar n1 n2) | |
System.Console.WriteLine("Subtrair: {0}", subtrair n1 n2) | |
System.Console.WriteLine("Multiplicar: {0}", multiplicar n1 n2) | |
System.Console.WriteLine("Somar: {0}", Calculadora.somar n1 n2) | |
System.Console.WriteLine("Subtrair: {0}", Calculadora.subtrair n1 n2) | |
System.Console.WriteLine("Fatorial: {0}", Calculadora.fatorial n1 ) | |
//exemplo de Class | |
type Pessoa(nome:string, email:string) = | |
member this.Nome = nome | |
member this.Email = email | |
let p = Pessoa ("Cleyton Ferrari","cleytonferrari@gmail.com") | |
System.Console.WriteLine("{0} {1}",p.Nome, p.Email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment