Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{-# LANGUAGE TemplateHaskell #-} | |
{- This works in GHC 7.8.3 -} | |
import Control.Monad | |
import Language.Haskell.TH | |
data DB = DB { couples :: [Couple], people :: [People] } | |
type Couple = (String, String) | |
type People = (String, Int) |
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
module-template: ! 'module MODULE_NAME where | |
' | |
extensions: {} | |
environment: null | |
cabal-file: project.cabal | |
modules: | |
Main(gistfile1.hs): | |
filename: gistfile1.hs | |
version: 1 |
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
-- Based on http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html | |
-- But uses the Gloss (http://hackage.haskell.org/package/gloss) library to draw the image. | |
module OneDCA where | |
import Data.Bits | |
import Data.Word | |
import Graphics.Gloss | |
-- Universes |
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 Control.Parallel.Strategies (using, parBuffer, rseq) | |
import Data.List (partition) | |
-- *** Example Haskell functions *** | |
-- Is a list of integers sorted? | |
isOrdered :: [Int] -> Bool | |
isOrdered (x:y:zs) = x <= y && isOrdered (y:zs) | |
isOrdered _ = True |
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
Fun with monoids | |
================ | |
We'll need the monoid library. | |
> import Data.Monoid | |
Difference lists | |
---------------- |
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
Michaels solution | |
================= | |
> a 0 y = 1 | |
> a x 0 = 1 | |
> a x y = a (x-1) y + a x (y-1) | |
> result = map (\x -> a x x) [0..] | |
Memoised form |
NewerOlder