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
| // run here: http://jsfiddle.net/6mt3ffpe/ | |
| module Bounce where | |
| import DOM | |
| import Graphics.Canvas | |
| import Control.Monad.Eff | |
| import Control.Monad.Eff.Ref | |
| import Control.Monad.Trans | |
| import Control.Monad.RWS |
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
| sealed trait Type { | |
| override def equals(y: Any) = super.equals(y) | |
| override def hashCode = super.hashCode | |
| def isSubtypeOf(ty: Type): Boolean = { | |
| def f(a: Type, b: Type, trail: Set[(Any, Any)]): Boolean = | |
| if (trail contains (a, b)) | |
| true | |
| else (a, b) match { | |
| case (Bot, _) => true |
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 scala.collection.immutable | |
| sealed trait SP[-A, +B] { | |
| def run(input: Stream[A]): Stream[B] = this match { | |
| case Put(value, sp) => value #:: sp.run(input) | |
| case Get(builder) => input match { | |
| case x #:: xs => builder(x).run(xs) | |
| case _ => Stream.empty | |
| } | |
| } |
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 RankNTypes, TypeFamilies, RecordWildCards, GADTs, KindSignatures #-} | |
| module Main where | |
| import Data.List as L | |
| import Data.Vector as V | |
| import Data.Vector.Unboxed as U | |
| import Data.Foldable as F | |
| type family Observation c :: * | |
| type instance Observation () = [Float] |
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 scala.collection._ | |
| class Bag[E] private (val items: Map[E, Int]) { | |
| def isEmpty = items.isEmpty | |
| def view = items.keys.view | |
| def -(item: E) = new Bag[E](items(item) match { | |
| case 1 => items - item | |
| case n => items.updated(item, n - 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
| #!/usr/bin/env python3.4 | |
| import sys | |
| import asyncio as aio | |
| import concurrent.futures as cf | |
| from getpass import getpass | |
| from itertools import takewhile | |
| import github3 |
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
| // utils.js | |
| (function ($,sr) { | |
| var debounce = function (func, threshold, execAsap) { | |
| var timeout; | |
| return function debounced () { | |
| var obj = this, args = arguments; | |
| function delayed () { | |
| if (!execAsap) | |
| func.apply(obj, args); |
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
| package apsk.jpatmat; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Random; | |
| import java.util.function.Consumer; | |
| import java.util.function.Function; | |
| public class Entry { | |
| // Simple Arithmetic Language |
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
| (defmacro $ (&rest rest) `(funcall ,@rest)) | |
| (defstruct builder | |
| combine | |
| bind | |
| return | |
| return-from | |
| yield | |
| yield-from | |
| using |
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
| (defmacro monadic (&body statements) | |
| `(let ((m *monad*)) | |
| (statements-of (monad m) ,@statements))) | |
| (defun monad-example (ma mb) | |
| (monadic | |
| (get x ma) | |
| (get y mb) | |
| (val z (+ x y)) | |
| (ret (list x y z)))) |
NewerOlder