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
class Messages extends DispatchSnippet { | |
override def dispatch = { | |
case "all" => all _ | |
case "top" => top _ | |
case "paginate" => paginator.paginate _ | |
case "detail" => detail _ | |
} |
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
require 'formula' | |
class Fermata < Formula | |
url 'http://ghsoftware.s3.amazonaws.com/fermata-0.6.tar.gz' | |
version '0.6' | |
homepage 'http://github.com/scsibug/fermata' | |
def install | |
bin.install 'fermata' # shell script, runs java -jar fermata.war | |
bin.install 'fermata.war' # executable jar/war |
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
/*********************************************************** | |
* TI MSP-430 LaunchPad Button & LED-Blinking Demo | |
* | |
* Simple example of using a button to manipulate LEDs. | |
* | |
* Pressing the button (P1.3) will toggle a pattern of the | |
* red/green LEDs alternating on/off. | |
* | |
* Tested on an MSP430G2231, built with mspgcc toolchain. | |
**********************************************************/ |
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 Data.Set | |
import Prelude hiding (map, filter) | |
generation g = filter (\p -> or [liveRule p g, spawnRule p g]) (candidates g) | |
liveRule p g = (member p g) && ((neighborCount p g) `elem` [2,3]) | |
spawnRule p g = not(member p g) && ((neighborCount p g) == 3) | |
neighborCount p g = size $ intersection (border p) g |
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
{---------------------------------------------------------------------------- | |
__ __ __ __ ____ ___ _______________________________________________ | |
|| || || || || || ||__ Hugs 98: The Nottingham and Yale Haskell system | |
||___|| ||__|| ||__|| __|| Copyright (c) 1994-1999 | |
||---|| ___|| World Wide Web: http://haskell.org/hugs | |
|| || Report bugs to: hugs-bugs@haskell.org | |
|| || Version: February 1999_______________________________________________ | |
This is the Hugs 98 Standard Prelude, based very closely on the Standard | |
Prelude for Haskell 98. |
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 Test.QuickCheck | |
import Test.QuickCheck.Function | |
-- mapping any function over reverse of a list == | |
-- reversing the map of that function of a list | |
prop_maprev ∷ [Int] → Fun Int String → Bool | |
prop_maprev i (Fun _ f) = map f (reverse i) == reverse (map f i) | |
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 scala.Console | |
// Write a game that will take a tic-tac-toe board with X, O, and blank | |
// characters and detect the winner or whether there is a tie or no | |
// winner yet. Use classes where appropriate. | |
// Represent a board with X,O,blank plays. | |
class Board(positions:String) { | |
val winningTuples = List( (0,1,2), (3,4,5), (6,7,8), // L-to-R | |
(0,3,6), (1,4,7), (2,5,8), // T-to-B | |
(0,4,8), (2,4,6)) // Diagonal |
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
val x = List("a", "aoe", "", "foo") | |
val sum = x.foldLeft(0)(_ + _.length) | |
println(x.mkString + " --> " + sum) |
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
trait Censor { | |
val replacements = Map("Shoot" -> "Pucky", | |
"Darn" -> "Beans") | |
// Censor a string with multiple words | |
def censor(s:String):String = { | |
(s /: replacements){case (a,(k,v)) => a.replaceAll(k,v)} | |
} | |
} | |
object CensorApp extends Censor { |
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(string_words). | |
-export([word_count/1]). | |
%Write a function that uses recursion to return the number of words in a string. | |
word_count([]) -> 0; | |
word_count([32]) -> 0; | |
word_count([_]) -> 1; | |
word_count([32|T]) -> word_count(T); | |
word_count([H|32]) -> word_count(H); | |
word_count([_,32|T]) -> 1+word_count(T); |
OlderNewer