Skip to content

Instantly share code, notes, and snippets.

View tjaskula's full-sized avatar
🎸
C++

Tomasz Jaskula tjaskula

🎸
C++
View GitHub Profile

Recursion and Trampolines in Scala

Recursion is beautiful. As an example, let's consider this perfectly acceptable example of defining the functions even and odd in Scala, whose semantics you can guess:

def even(i: Int): Boolean = i match {
  case 0 => true
  case _ => odd(i - 1)
}

def odd(i: Int): Boolean = i match {

@tjaskula
tjaskula / steps.md
Last active June 17, 2017 23:16
Steps to set up solution on VS code for Fable
@tjaskula
tjaskula / cmd.md
Created June 14, 2017 20:52
Express and Backbone instructions

installation de express

npm install express -g npm install -g express-generator

generer une appli

express congo

lancer l'appli

npm install node app.js

@tjaskula
tjaskula / fableCmd.md
Last active June 14, 2017 21:07
Fable compilation steps

git config --list --show-origin

OPEN SSL

But it's better to check on Core SDK page

ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/pkgconfig/libcrypto.pc /usr/local/lib/pkgconfig/
ln -s /usr/local/opt/openssl/lib/pkgconfig/libssl.pc /usr/local/lib/pkgconfig/

@tjaskula
tjaskula / NesGateway.fs
Created May 7, 2017 13:42 — forked from bartelink/NesGateway.fs
Dump of ProtoBuf serialization spike for http://github.com/bartelink/FunDomain
module FunDomain.Persistence.NEventStore.NesGateway
open FunDomain.Persistence.Serialization
open NEventStore
open NEventStore.Persistence
open NEventStore.Persistence.Sql.SqlDialects
open Microsoft.FSharp.Reflection
open System
@tjaskula
tjaskula / PriorityQueue.fs
Created December 9, 2016 00:07
mutable priority queue in F#
open System
open Microsoft.FSharp.Core
// maybe there is a better way to simplify this
let private (|Greater|_|) descendent compareResult =
match compareResult with
| n when n < 0 && descendent -> None
| n when n < 0 && not descendent -> Some()
| 0 -> None
| n when n > 0 && descendent -> Some()
@tjaskula
tjaskula / Parsers.cs
Last active August 29, 2015 14:21
Defining SelectMany method's signature for Parser type
var p1 = startSriper.ToParser();
var p2 = endSriper.ToParser();
var composite = p1.Compose(p2);
var result2 = composite(content);
var parsers = from a in p1
from b in p2
select b;
@tjaskula
tjaskula / euler.fs
Last active August 29, 2015 14:16
Euler
let rec split<'T> (input: 'T array) size =
let rec loopOn (tail : 'T array) grouped =
let lastIndex = Array.length tail - 1
let endindx = min (size - 1) lastIndex
let arrWrapper = (fun e -> [|e|])
let newGroup = tail.[0..endindx]
|> List.ofArray
|> arrWrapper
|> Array.append grouped
@tjaskula
tjaskula / Steps2.fsx
Last active August 29, 2015 14:14
F# DAP
// 1 step.
type Order with
static member NewOrder = fun orderRef -> Order.Empty (NoItems orderRef)
// 2 step replace "=" with "with" in the first step
type Order =
| Empty of EmptyState
| PaymentExpected
| Payed
| Cancelled
// Udi style w Static Domain Events
var dispatcher = new RecordingDomainEventsDispatcher();
DomainEvents.Dispatcher = dispatcher;
var customer = new Customer(new Address());
customer.Move(new Address());
Console.WriteLine("Customer moved: " + dispatcher.RecordedDomainEvent(new CustomerMoved()));