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
abstract class InterpolationMethod(val s: Seq[(Double, Double)]) extends (Double => Double) { | |
protected val x_i = s.map(_._1) | |
protected val y_i = s.map(_._2) | |
} | |
class Lagrange(s: Seq[(Double, Double)]) extends InterpolationMethod(s) { | |
val n = s.size | |
private def poly(i: Int)(x: Double): Double = (for (j <- 0 until n) yield if (j != i) ((x - x_i(j)) / (x_i(i) - x_i(j))) else 1).product |
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
abstract class InterpolationMethod(val s: Traversable[(Double, Double)]) extends (Double => Double) { | |
protected val x_i = s.map(_._1) | |
protected val y_i = s.map(_._2) | |
def this(f: Double => Double, f2: Int => Double, n: Int) = this(for(i <- 0 to n) yield { | |
val x = f2(i) | |
(x, f(x)) | |
}) | |
def this(f: Double => Double, n: Int) = this(f, _.toDouble, n) |
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 GADTs #-} | |
module LenList where | |
data Zero | |
data Succ n | |
data LenList n a where | |
Nil :: LenList Zero a | |
Cons :: a -> LenList n a -> LenList (Succ n) 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
{-# LANGUAGE Arrows #-} | |
module Tile where | |
import Control.Arrow | |
import Control.Monad (void) | |
import FRP.Yampa | |
import Graphics.UI.SDL (Rect(..), blitSurface, Surface) | |
data Tile = Tile !Rect Bool | |
| AnimatedTile ![Rect] Bool |
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 Arrows #-} | |
module Main where | |
import Control.Arrow | |
import Control.Monad | |
import Data.Maybe | |
import Data.Monoid | |
import Data.VectorSpace | |
import Graphics.UI.GLUT |
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 System.Random | |
import System.Console.GetOpt | |
import System.Environment(getArgs, getProgName) | |
type Coord = (Int,Int) | |
type Range = (Int,Int) | |
type Area = (Coord,Coord) -- Upper-left and lower-right bounds. |
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 System.Random | |
import System.Console.GetOpt | |
import System.Environment(getArgs, getProgName) | |
type Coord = (Int,Int) | |
type Range = (Int,Int) | |
type Area = (Coord,Coord) -- Upper-left and lower-right bounds. |
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 OverloadedStrings #-} | |
module Main where | |
import Happstack.Server | |
import Data.Text (Text) | |
main :: IO () | |
main = simpleHTTP nullConf $ ok ("{\"hello\": \"world\"}" :: Text) |
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
name: textr | |
version: 0.0.0 | |
build-type: Simple | |
cabal-version: >=1.6 | |
executable textr | |
main-is: Main.hs | |
build-depends: base, text, bytestring, happstack-server, ixset, acid-state, safecopy, aeson |
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
db.foo.insert({ 'created at': new Date(), ooc: false, nsfw: false, body: '<p>Moo</p>\n', keywords: [ 'Moo' ], mentioned: [], tags: [], sender: { id: 'stuff', name: 'lambdadusk', 'display name': 'Lambda' } }) |