Skip to content

Instantly share code, notes, and snippets.

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
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)
{-# 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
{-# 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
{-# LANGUAGE Arrows #-}
module Main where
import Control.Arrow
import Control.Monad
import Data.Maybe
import Data.Monoid
import Data.VectorSpace
import Graphics.UI.GLUT
@scan
scan / mapgen.hs
Created June 7, 2012 09:55 — forked from splinterofchaos/mapgen.hs
A simple roguelike map generator. Uses naiive splatter pattern to create rooms.
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.
@scan
scan / mapgen.hs
Created June 5, 2012 13:21 — forked from splinterofchaos/mapgen.hs
A simple roguelike map generator. Uses naiive splatter pattern to create rooms.
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.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Happstack.Server
import Data.Text (Text)
main :: IO ()
main = simpleHTTP nullConf $ ok ("{\"hello\": \"world\"}" :: Text)
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
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' } })