Skip to content

Instantly share code, notes, and snippets.

View fpellet's full-sized avatar

Florent Pellet fpellet

View GitHub Profile
(ns card-game-war.game)
;; feel free to use these cards or use your own data structure
(def suits [:spade :club :diamond :heart])
(def ranks [2 3 4 5 6 7 8 9 10 :jack :queen :king :ace])
(def cards
(for [suit suits
rank ranks]
[suit rank]))
const Categories = {
Pop: 'Pop',
Science: 'Science',
Sports: 'Sports',
Rock: 'Rock',
}
var Game = function () {
var players = new Array();
var playerPositions = new Array(6);
@fpellet
fpellet / assert.fs
Last active April 30, 2020 15:52
F# asserts
// Proposal 1
[| 1; 2; 3; 4; 5; 666 |] |> Should.contain [3; 5; 666]
[| 1; 2; 3; 2 |] |> Should.isOnlyMadeOf [3; 2; 1]
Some 1 |> should [
Should.hasAValue
Which.IsPositive
And.IsEqualTo 1
]
module CommandParser
type Argument =
| Verbose
| Url of string
| Port of int
type Parser = string list -> Argument list
let private apply parsersRunner parsers =

Keybase proof

I hereby claim:

  • I am fpellet on github.
  • I am florentpellet (https://keybase.io/florentpellet) on keybase.
  • I have a public key whose fingerprint is D868 04D5 D41C 1A42 E18A BB57 533E 3F0C C29B 941B

To claim this, I am signing this object:

@fpellet
fpellet / example.fs
Created June 26, 2016 14:57
F# without if
type Direction = {
pivotLeft : Direction
pivotRight: Direction
move: Position -> Position
}
and Position = { X: int; Y: int; Direction: Direction }
let rec N =
{
pivotLeft = W
open System
type Player = { Num: int }
type GameParameters = { PlayersNb : int; CurrentPlayer: Player; DronesNb: int; ZonesNb: int }
type Position = { X: int; Y: int }
type Zone =
| FreeZone of ZoneCoordonne
| ControlledZone of ZoneCoordonne * Player