Skip to content

Instantly share code, notes, and snippets.

View devcrafting's full-sized avatar

Clément Bouillier devcrafting

  • DevCrafting
  • France
View GitHub Profile
@devcrafting
devcrafting / Tennis.fsx
Last active September 1, 2020 12:47
TDD: Type Driven Development with F# on Tennis Kata, with focus on reducing types cardinality
// STEP 1
// cardinality = 36
// type PlayerScore =
// | Love
// | Fifteen
// | Thirty
// | Forty
// | Game
// | Advantage
@devcrafting
devcrafting / gist:d729a5db514d237998212ebf8728baaf
Last active March 27, 2017 05:53
Fable.io - Bug repro for Seq.collect with Option
type CellShape = Cell | Empty
let createCell shape =
seq {
yield! Seq.map (fun _ -> shape) [1..10]
}
let generate () =
seq {
yield! Seq.map (fun _ -> createCell Cell) [1..10]
@devcrafting
devcrafting / gist:df5174f38775e49fd7c2
Last active August 29, 2015 14:23
Tirage de tombola école
let ticketsVendus souches = List.concat souches
let filtrerLotsDéjàTirés lots ticketsTirés =
lots
|> List.filter (fun x ->
not (ticketsTirés
|> List.exists (fun y -> fst y = x)))
let filtrerTicketsDéjàTirés tickets ticketsTirés =
tickets
@devcrafting
devcrafting / gist:95416cd1c9c52a6fc6d7
Created June 13, 2015 12:05
Awful legacy F# written at CodeRetreatLyon
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
open System.IO
let nothing filtered item previousItem position =
Seq.append filtered [item]
let reverse filtered item previousItem position =
Seq.append [item] filtered
@devcrafting
devcrafting / gist:5b37585100aee6fd8ff1
Created May 28, 2015 13:44
F# Codingame Game of Drones refactored & first impl
open System
type Payer = { Num: int }
type GameParameters = { PlayersNb : int; CurrentPlayerId: int; DronesNb: int; ZonesNb: int }
type ZoneCoordonne = { Num: int; CenterX: int; CenterY: int }
type ControlledZone = { Coordonne: ZoneCoordonne; Player: int }
type FreeZone = { Coordonne: ZoneCoordonne }
type Zone =
| FreeZone of FreeZone