Skip to content

Instantly share code, notes, and snippets.

View ElemarJR's full-sized avatar
🏠
Working from home

Elemar Rodrigues Severo Junior ElemarJR

🏠
Working from home
View GitHub Profile
type Expr =
| X
| Const of value: double
| Add of Expr * Expr
| Sub of Expr * Expr
| Mult of Expr * Expr
| Div of Expr * Expr
| Pow of Expr * Expr
| Neg of Expr
let e numberStr =
match numberStr with
| "" -> numberStr
| _ -> numberStr + " e "
let writeNumber nr : string =
let unity = ["zero"; "um"; "dois"; "três"; "quatro"; "cinco"; "seis"; "sete"; "oito"; "nove"; "dez"; "onze"; "doze"; "treze"; "quatorze"; "quinze"; "dezesseis"; "dezessete"; "dezoito"; "dezenove"]
let decimals = [""; "cem"; "vinte"; "trinta"; "quarenta"; "cinquenta"; "sessenta"; "setenta"; "oitenta"; "noventa"]
let hundreds = [""; "cento"; "duzentos"; "trezentos"; "quatrocentos"; "quinhentos"; "seissentos"; "setecentos"; "oitocentos"; "novecentos"]
let e numberStr =
match numberStr with
| "" -> numberStr
| _ -> numberStr + " e "
let writeNumber nr : string =
let unity = ["zero"; "um"; "dois"; "três"; "quatro"; "cinco"; "seis"; "sete"; "oito"; "nove"; "dez"; "onze"; "doze"; "treze"; "quatorze"; "quinze"; "dezesseis"; "dezessete"; "dezoito"; "dezenove"]
let decimals = [""; "cem"; "vinte"; "trinta"; "quarenta"; "cinquenta"; "sessenta"; "setenta"; "oitenta"; "noventa"]
let hundreds = [""; "cento"; "duzentos"; "trezentos"; "quatrocentos"; "quinhentos"; "seissentos"; "setecentos"; "oitocentos"; "novecentos"]
let inline solution n =
[1UL..(n - 1UL)]
|> List.filter (fun f -> (f % 3UL = 0UL) || (f % 5UL = 0UL))
|> List.sum
let rec iterate count =
if count > 0
then
System.Console.ReadLine()
|> (uint64)
@ElemarJR
ElemarJR / euler.fs
Last active September 3, 2015 18:48
(* --- 0001 --- *)
[1..999]
|> List.where (fun f -> (f % 3 = 0) || (f % 5 = 0))
|> List.sum
(* --- 0002 --- *)
let fib =
let rec f a b = seq {
yield a
yield! f b (a + b)
root@ubuntu:/home/elemarjr# mvn archetype:create -DgroupId=com.elemarjr.simpleMath -DartifactId=SimpleMath -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-archetype-plugin:2.4:create (default-cli) @ standalone-pom ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[Test]
public void ExpressionsWithChildrenShouldOverrideVisitMethod()
{
var expressionTypes = typeof(IExpression)
.Assembly.GetTypes()
.Where(t => typeof(IExpression).IsAssignableFrom(t))
.Where(t => !t.IsInterface);
var withChildren = expressionTypes
.Where(t => t.GetFields(BindingFlags.Instance |
#include <string>
#include <iostream>
class Envelope
{
private:
std::string _value;
public:
Envelope(const std::string value):
_value(value)
#include <iostream>
template <unsigned long N>
struct binary {
static unsigned const value =
binary<N/10>::value * 2
+ N % 10;
};
template <>
__declspec ( no_refcount ) inline long __stdcall :: WinRTComponentCpp :: Calculator ::
__abi_WinRTComponentCpp___ICalculatorPublicNonVirtuals____abi_Add ( int a , int b , int * __abi_returnValue )
{
long __hr = 0 ;
* __abi_returnValue = 0 ;
try
{
auto __tempValue = Add ( a , b ) ;
* __abi_returnValue = __tempValue ;
}