This file contains hidden or 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
newtype Position = (Integer, Integer) | |
data Replacement = { | |
rStart :: Position, | |
rEnd :: Position, | |
rText :: [Char] | |
} | |
data Intersect = BEFORE | INSIDE | AFTER | |
replace :: [Replacement] -> [Char] -> State Position [Char] | |
replace _ [] = return [] |
This file contains hidden or 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 currentScores = { | |
'arg': 0, | |
'mex': 1, | |
'pol': 1, | |
'ara': 3 | |
} | |
function updateScores(scores, {home, away, result}) { | |
scores = {...scores} | |
This file contains hidden or 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
type Score = Int | |
type Rank = Int | |
climbingLeaderboard :: [Score] -> [Score] -> [Rank] | |
climbingLeaderboard scores alice = let scoreRank = denseRank scores | |
aliceDesc = reverse alice | |
in reverse (rankSeries scoreRank aliceDesc) | |
denseRank :: [Score] -> [(Rank, Score)] | |
denseRank scores = go scores 1 |
This file contains hidden or 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
// Building with Types | |
// Lets imagine we have two types, for example Number and String. | |
// In which ways could we combine them, just one of each, to create a different type? | |
// How could we do this? | |
// Well... we could create an object: | |
type Person = {name: string, age: number}; |
This file contains hidden or 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
// Types as Sets, containing Values | |
// Union and Intersection Types can be thought as unions and intersections of the underlying Sets | |
// Type Compatibility can be thought of a subset relationship between the underlying Sets | |
// | |
// Usual Set concepts apply, such as: | |
// cardinality (the number of possible values of a given type) | |
// ø (empty set) | |
// unions, intersections, subsets, supersets, sums, products | |
// | |
// Lets look at some types... |
This file contains hidden or 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
[profile target-account] | |
role_arn = arn:aws:iam::123456789012:role/RoleInTargetAccount | |
source_profile = instance-role | |
region = eu-central-1 |
This file contains hidden or 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
set nocompatible | |
set noswapfile | |
set number | |
set cursorline | |
set encoding=utf-8 | |
syntax enable | |
filetype plugin indent on | |
set tabstop=4 | |
set shiftwidth=4 |
This file contains hidden or 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
data Player = Player | |
{ _name :: String | |
, _hitPoints :: Integer | |
, _attackPoints :: Integer | |
} | |
type Game = [Player] | |
playerTurn :: Player -> State Game () | |
playerTurn p = do |
This file contains hidden or 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
result = foo . bar . baz $ value | |
result1 = foo $ bar $ baz $ value | |
result2 = foo $ bar . baz $ value | |
result3 = foo (bar . baz $ value) | |
result4 = (foo . bar) (baz value) |
This file contains hidden or 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
data Position = Position | |
{ _x :: Integer | |
, _y :: Integer | |
} deriving (Show, Eq) | |
-- We want to sort by Y first, and then by X, so we need a custom Ord instance | |
instance Ord Position where | |
Position x0 y0 <= Position x1 y1 = | |
if y0 /= y1 | |
then y0 <= y1 |
NewerOlder