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
| -- | |
| -- AVLTree | |
| -- keywords: tree, Zipper, QuickCheck | |
| import Test.QuickCheck | |
| type Key = (Int, Int) | |
| data AVLTree = Empty | Node Key AVLTree AVLTree deriving (Show) | |
| -- record of parent's Key and the sibling |
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
| -- | |
| -- 2-3 Tree | |
| -- Chifeng Chou ([email protected]) | |
| -- | |
| -- keywords: tree, Zipper, QuickCheck | |
| {-# LANGUAGE FlexibleInstances #-} | |
| import Test.QuickCheck |
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
| {-- ToN.hs | |
| -- http://www.geeksforgeeks.org/count-total-set-bits-in-all-numbers-from-1-to-n/ | |
| -- Given a positive integer n, count the total number of set bits in binary | |
| -- representation of all numbers from 1 to n. | |
| -- | |
| -- E.g. | |
| -- > allOnes 9 | |
| -- 15 | |
| --} | |
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.language.higherKinds | |
| trait CBF[-Fr, -Elm, +To] | |
| trait QLike[+A, +Repr] { | |
| def foo[B, That](q: B)(implicit cbf: CBF[Repr, B, That]): Int = 0 | |
| } | |
| trait QFac[CC[_]] { | |
| class GCBF[A] extends CBF[CC[_], A, CC[A]] |
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.language.higherKinds | |
| trait Budr[-Elm, +To] { | |
| def +=(elem: Elm): this.type | |
| def result(): To | |
| } | |
| trait CBF[-Fr, -Elm, +To] | |
| trait QLike[+A, +Repr] { |
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.language.higherKinds | |
| import scala.annotation.unchecked.uncheckedVariance | |
| trait Budr[-Elm, +To] { | |
| def +=(elem: Elm): this.type | |
| def result(): To | |
| } | |
| trait CBF[-Fr, -Elm, +To] |
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.language.higherKinds | |
| import scala.annotation.unchecked.uncheckedVariance | |
| trait Budr[-Elm, +To] { | |
| def +=(elem: Elm): this.type | |
| def result(): To | |
| def mapResult[NewTo](f: To => NewTo): Budr[Elm, NewTo] = { | |
| new Budr[Elm, NewTo] with Proxy { | |
| val self = Budr.this | |
| def +=(x: Elm): this.type = { self += x; this } |
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 DeriveDataTypeable #-} | |
| module KSSolver where | |
| import System.Console.CmdArgs | |
| import System.IO | |
| import Control.Monad | |
| import Control.Applicative | |
| import Data.Vector (Vector, (!)) | |
| import qualified Data.Vector as V | |
| import Debug.Trace |
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 Data.Char | |
| import Control.Monad | |
| import Control.Monad.Trans.State.Lazy (StateT(..), runStateT) | |
| import Control.Monad.Trans.Reader | |
| import Control.Monad.State.Class | |
| import Control.Monad.Trans.Class | |
| type Pos = (Int, Int) -- (line, column) | |
| type PString = (Pos, String) |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
OlderNewer