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
-- Copyright 2018 Google LLC. | |
-- SPDX-License-Identifier: Apache-2.0 | |
{-# LANGUAGE FlexibleContexts #-} | |
import Control.Applicative | |
import Control.Monad.Writer | |
data Expr = Lit Int | Plus Expr Expr | Times Expr Expr | |
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
<link rel="import" href="../paper-input/paper-input.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; |
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
class None { | |
None(); | |
} | |
class Some { | |
final value; | |
Some(this.value); | |
} | |
/* environments */ |
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
class Node { | |
final val; | |
final left; | |
final right; | |
Node(this.val, this.left, this.right); | |
insert(n) => | |
n.lt(this.val) | |
? new Node(this.val, this.left.insert(n), this.right) |
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
class Cons { | |
final x; | |
final xs; | |
Cons(this.x, this.xs); | |
freeze() => new Cons(((v) => <v>)(this.x), this.xs.freeze()); | |
contains(e) => < (~this.x).eq(~e) ? true : ~(this.xs.contains(e)) >; | |
} |
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 Data.Char | |
main = interact unindent | |
unindent = unlines . unindentLines . lines | |
unindentLines ls = map (drop commonPrefixLength) ls | |
where -- the number of characters to drop from each line | |
commonPrefixLength = length (commonPrefix prefixes) | |
-- whitespace-only prefixes of non-empty lines of ls |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<script type="text/javascript" src="flapjax.js"></script> | |
<script> | |
function onload() { | |
/****** utils ******/ | |
// 2d vectors |