This file contains hidden or 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
(ns wc.core | |
(:require [clj-http.client :as client])) | |
(defn print-matchs-over [] | |
(let [data-request (client/get "http://worldcup.sfg.io/matches" {:as :json-strict}) | |
completed (filter #(= (:status %) "completed") (:body data-request))] | |
(doseq [{home-team :home_team away-team :away_team} completed] | |
(println (str (:country home-team) " " (:goals home-team) " x " | |
(:country away-team) " " (:goals away-team)))))) |
This file contains hidden or 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.concurrent.duration._ | |
import scala.concurrent.Await | |
import dispatch._, Defaults._ | |
import play.api.libs.json._ | |
object Main { | |
def formatMatch(jsonMatch: JsObject): Option[String] = for { | |
cHome <- (jsonMatch \ "home_team" \ "country").asOpt[String] | |
gHome <- (jsonMatch \ "home_team" \ "goals").asOpt[Int] | |
cAway <- (jsonMatch \ "away_team" \ "country").asOpt[String] |
This file contains hidden or 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
package actions | |
import play.api.Play | |
import play.api.mvc._ | |
import scala.concurrent.Future | |
import org.apache.commons.codec.binary.Base64.decodeBase64 | |
object AuthenticationAction extends ActionBuilder[Request] { |
This file contains hidden or 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
-- CIS 194: Homework 1 (http://www.seas.upenn.edu/~cis194/hw/01-intro.pdf) | |
-- Part I - Credit Card Validation | |
toDigits :: Integer -> [Integer] | |
toDigits n | |
| n <= 0 = [] | |
| otherwise = toDigits (n `div` 10) ++ [n `mod` 10] | |
toDigitsRev :: Integer -> [Integer] | |
toDigitsRev = reverse . toDigits |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |