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
{-# OPTIONS_GHC -Wall -O2 -threaded -with-rtsopts="-N" #-} | |
import Control.Concurrent | |
import Control.Concurrent.Async | |
import Control.Lens | |
import Control.Monad | |
import Data.ByteString.Lazy hiding (replicate) | |
import Data.List.Split | |
import Network.Wreq hiding (getWith) | |
import Network.Wreq.Session |
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
#! /bin/bash | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
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
export GHC_DOT_APP="/Applications/ghc-7.8.4.app" | |
export PATH="${HOME}/.cabal/bin:${GHC_DOT_APP}/Contents/bin:${PATH}" | |
export PATH=$HOME/.cabal/bin:$PATH |
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
/** | |
* Binary Search Tree in Scala with ADT | |
*/ | |
sealed trait Tree[+T] | |
case object Leaf extends Tree[Nothing] | |
case class Branch[T](value: T, left: Tree[T], right: Tree[T]) extends Tree[T] | |
object Tree { | |
def showTree[T](tree: Tree[T]): String = tree match { |
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
{-# OPTIONS_GHC -fno-warn-missing-methods #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
-- Homework 6 - http://www.seas.upenn.edu/~cis194/spring13/hw/06-laziness.pdf | |
fib :: Integer -> Integer | |
fib 0 = 0 | |
fib 1 = 1 | |
fib n = fib (n - 1) + fib (n - 2) |
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 TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
-- Homework 6 - http://www.seas.upenn.edu/~cis194/spring13/hw/05-type-classes.pdf | |
import ExprT | |
import Parser | |
import StackVM as VM | |
import qualified Data.Map as M | |
import Control.Monad |
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
-- Homework 4 - http://www.seas.upenn.edu/~cis194/spring13/hw/04-higher-order.pdf | |
import Data.List | |
-- Exercise 1: Wholemeal programming | |
fun1 :: [Integer] -> Integer | |
fun1 [] = 1 | |
fun1 (x:xs) | |
| even x = (x - 2) * fun1 xs |
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
-- Homework 3 - http://www.seas.upenn.edu/~cis194/spring13/hw/03-rec-poly.pdf | |
module Golf where | |
import Data.List | |
skips :: [a] -> [[a]] | |
skips xs = map (\(i,x) -> takeNth i x) $ zipWith (\_ b -> (b, xs)) xs [1..] | |
takeNth :: Int -> [a] -> [a] |
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 Golf where | |
skips :: [a] -> [[a]] | |
skips xs = map (\(i,x) -> takeNth i x) $ zipWith (\_ b -> (b, xs)) xs [1..] | |
takeNth :: Int -> [a] -> [a] | |
takeNth n xs = [y | (i,y) <- zip [1..] xs, i `mod` n == 0] |
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
{-# OPTIONS_GHC -Wall #-} | |
-- Homework 2 - http://www.seas.upenn.edu/~cis194/spring13/hw/02-ADTs.pdf | |
module LogAnalysis where | |
import Log | |
parseMessage :: String -> LogMessage | |
parseMessage = parseWords . words | |
where parseWords :: [String] -> LogMessage |