Skip to content

Instantly share code, notes, and snippets.

View dvdsgl's full-sized avatar
🦋
Gliding

David Siegel dvdsgl

🦋
Gliding
View GitHub Profile
data Tree a = Branch (Tree a) (Tree a)
| Leaf a
treeOp :: (a -> b) -> (b -> b -> b) -> Tree a -> b
treeOp fL fB (Leaf a) = fL a
treeop fL fB (Branch t1 t2) = treeOp fL fB t1 `fB` treeOp fL fB t2
myFringe :: Tree a -> [a]
myFringe = treeOp (:[]) (++)
#!/bin/bash
# Install dependencies
sudo apt-get install ghc6 ghc6-prof ghc6-doc haddock libglut-dev happy alex \
libedit-dev zlib1g-dev checkinstall
# Get haskell-platform
wget http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2.tar.gz
tar -xzf haskell-platform-2009.2.0.2.tar.gz
cd haskell-platform-2009.2.0.2
using System;
namespace Data
{
public struct Maybe<T> where T : class
{
public static implicit operator Maybe<T> (T value)
{
== Solution: <name of solution> ==
=== Description ===
# Briefly describe the solution.
=== Advantages ===
# List advantages of the solution.
=== Disadvantages ===
# List at least one disadvantage of the solution.
module YataWindow ( YataWindow
, new, showAll
, onMessagePost
, displayTweets
)
where
import Control.Applicative
import Text.Printf (printf)
#!/usr/bin/runhaskell
import Data.List (isInfixOf)
import Web.Twitter (getUserTimeline)
import Web.Twitter.Monad (runTM)
import Web.Twitter.Fetch (nullAuthUser)
import Web.Twitter.Types (Status (..))
username = "jonobacon"
patterns = ["rock", "awesome", "jam"]
[~/Developer/ScalaMono]% cat ScalaMono.scala
object ScalaMono extends Application {
def fib (i: Int): Int = i match {
case 0 | 1 => 1
case i => fib (i - 2) + fib (i - 1)
}
println (fib (35))
}
[~/Developer/ScalaMono]% time mono ScalaMono.exe
[~/Developer/ScalaMono]% scalac-net ScalaMono.scala
[~/Developer/ScalaMono]% ilasm ScalaMono.msil
Assembling 'ScalaMono.msil' , no listing file, to exe --> 'ScalaMono.exe'
Operation completed successfully
[~/Developer/ScalaMono]% mono ScalaMono.exe
Scala on Mono! fib (0) = 1
Scala on Mono! fib (1) = 1
Scala on Mono! fib (2) = 2
Scala on Mono! fib (3) = 3
import System._
object ScalaMono extends Application {
def fib (i: Int): Int = i match {
case 0 | 1 => 1
case i => fib (i - 2) + fib (i - 1)
}
for (i <- 0 until 10) {
[~/Developer/ScalaMono]% time mono ScalaMono.exe
Scala on Mono! fib (0) = 1
Scala on Mono! fib (1) = 1
Scala on Mono! fib (2) = 2
Scala on Mono! fib (3) = 3
Scala on Mono! fib (4) = 5
Scala on Mono! fib (5) = 8
Scala on Mono! fib (6) = 13
Scala on Mono! fib (7) = 21
Scala on Mono! fib (8) = 34