This file contains 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 OverloadedStrings, ViewPatterns, GADTs #-} | |
import qualified Data.Set as S | |
import qualified Data.Text as T | |
data Fucky = Fucky { fuckyNum :: Maybe Double | |
, fuckyString :: Maybe T.Text | |
, fuckyFancyString :: Maybe T.Text | |
, fuckyBoolean :: Maybe Bool | |
} deriving (Eq, Show) |
This file contains 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
-- https://kata.geosci.ai/challenge/boreholes | |
import Text.Read (readMaybe) | |
import Data.Array -- Array sucks, but I want to stay inside the standard library | |
import Data.List (sort) | |
{- terrible hack! the problem syntax just happens to look | |
- like the innards of a Haskell list. | |
-} | |
parseBoreholes :: String -> Maybe [(Double, Double)] |
This file contains 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 poly_fn = { f : 'a. 'a -> 'a } | |
let ap_poly : poly_fn -> int -> bool -> int * bool = fun pf x y -> | |
(pf.f x, pf.f y) | |
let ap_poly_obj (obj: <f: 'a. 'a -> 'a>) x y = (obj#f x, obj#f y) | |
let id x = x | |
let (x, y) = ap_poly { f = id } 3 true | |
let (x2, y2) = ap_poly_obj (object method f : 'a. 'a -> 'a = id end) 3 true |
This file contains 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
open System | |
// types in our system | |
type Type = | |
| IntTy | |
| FnTy of Type * Type | |
// binary operations on integer expressions | |
type Op = | |
| Add |
This file contains 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
function Counter() | |
{ | |
const [count, setCount] = React.useState(0); | |
return ( | |
<div> | |
<p>Count = {count}</p> | |
<button onClick={() => setCount(count + 1)}> | |
Click me! Click me! Do it now, you son of a bitch! | |
</button> | |
</div> |
This file contains 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
#lang pie | |
(claim Vect | |
(→ U Nat | |
U)) | |
(define Vect | |
(λ (A n) | |
(iter-Nat | |
n | |
Trivial |
This file contains 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
#lang pie | |
(claim + (→ Nat Nat Nat)) | |
(define + | |
(λ (x y) | |
(iter-Nat x | |
y | |
(λ (acc) (add1 acc))))) | |
(claim repeat |
This file contains 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
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import dis | |
>>> def f_list(): | |
... xs = list() | |
... for i in range(10): | |
... xs.append(i * i) | |
... return xs | |
... | |
>>> def f_comp(): |
This file contains 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 sys | |
import os | |
import os.path | |
import csv | |
from typing import List, Optional, Set | |
# given a list of directories d1, d2, d3 | |
# each containing a common set of CSV files with the same columns: | |
# d1/a.csv d1/b.csv |
This file contains 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 RankNTypes #-} | |
newtype Listy a = Listy { runListy :: forall b . (a -> b -> b) -> b -> b } | |
nil :: Listy a | |
nil = Listy $ \_ init -> init | |
cons :: a -> Listy a -> Listy a | |
cons x xs = Listy $ \fn init -> fn x (runListy xs fn init) |