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
- Imports and Language Extensions - | |
> {-# LANGUAGE LambdaCase #-} | |
Enables the 'LambdaCase' language-extension which introduces new syntactic sugar | |
example :: Double -> Double | |
example = \case | |
0 -> 0 | |
x -> 1/x |
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
{-# LANGUAGE PolyKinds, PartialTypeSignatures #-} | |
module GameOfLife where | |
import Control.Comonad (extract, extend) | |
import Control.Comonad.Representable.Store (Store, peek, store, experiment) | |
import Data.Functor.Rep (Rep, index) | |
import Data.Finite (Finite, strengthen, shift, unshift, weaken) | |
import Data.Functor.Compose (Compose) | |
import GHC.TypeLits (Nat, KnownNat, type (<=)) |
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
SELECT | |
ColumName = col.name, | |
DataType = typ.name, | |
[Precision] = col.precision, | |
[Scale] = col.scale, | |
[MaxLength] = col.max_length, | |
IsPrimaryKey = ISNULL(ix.is_primary_key, 0), | |
ReferencedTableName = tbl.name, | |
ReferencedColumnName = refcol.name | |
FROM |
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
Imports System.Data.Entity.Design.PluralizationServices | |
Imports System.Globalization | |
Imports System.Runtime.CompilerServices | |
Imports Sprache | |
Public Module Program | |
Public Sub Main(args As String()) | |
Dim identifier = "Sage200HTMLPerson" | |
PascalCase.ToKebabCase("FooBaa") |
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 Edge a b = Edge { source ∷ a, sink ∷ a, label ∷ b } | |
deriving (Eq, Show) | |
-- Directed, edge-labelled graph represented as an adjacency list | |
type Graph a b = [(a, [Edge a b])] | |
-- A path is a contigious sequence of edges | |
type Path a b = [Edge a b] | |
-- Get all the edges of a graph |
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
import Test.QuickCheck | |
import Data.Map (Map) | |
import qualified Data.Map as Map | |
import Data.Ord (comparing) | |
import Data.List (sortBy, maximumBy) | |
main :: Int -> IO () | |
main n = do | |
lifespans <- generate $ arbitrary_lifespans n | |
print $ maximumPopulationYear lifespans |
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
mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] | |
mergeBy _ [] [] = [] | |
mergeBy _ xs [] = xs | |
mergeBy _ [] ys = ys | |
mergeBy cmp xs@(x:xs') ys@(y:ys') | |
| cmp x y <= EQ = x:(mergeBy cmp xs' ys) | |
| otherwise = y:(mergeBy cmp xs ys') | |
merge :: Ord a => [a] -> [a] -> [a] | |
merge = mergeBy compare |
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
mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] | |
mergeBy _ [] [] = [] | |
mergeBy _ xs [] = xs | |
mergeBy _ [] ys = ys | |
mergeBy cmp xs@(x:xs') ys@(y:ys') | |
| cmp x y <= EQ = x:(mergeBy cmp xs' ys) | |
| otherwise = y:(mergeBy cmp xs ys') | |
merge :: Ord a => [a] -> [a] -> [a] | |
merge = mergeBy compare |
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
mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a] | |
mergeBy _ [] [] = [] | |
mergeBy _ xs [] = xs | |
mergeBy _ [] ys = ys | |
mergeBy cmp xs@(x:xs') ys@(y:ys') | |
| cmp x y <= EQ = x:(mergeBy cmp xs' ys) | |
| otherwise = y:(mergeBy cmp xs ys') | |
merge :: Ord a => [a] -> [a] -> [a] | |
merge = mergeBy compare |
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 Tree a = Empty | Node a [Tree a] | |
deriving Show | |
dft :: Tree a -> [a] | |
dft Empty = [] | |
dft (Node x xs) = x:(concatMap dft xs) | |
bft :: Tree a -> [a] | |
bft Empty = [] | |
bft (Node x xs) = x:(catMaybes $ map value xs) ++ (concatMap bft (concatMap children xs)) |
OlderNewer