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 Main where | |
import Text.Printf | |
import Data.List | |
profit :: Int -> Int -> [Int] -> Int | |
profit cap rides groups | |
| sum groups <= cap = rides * sum groups | |
| otherwise = | |
case toCaps . findCycle $ rideCaps cap rides groups of |
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 query-comprehension | |
(:use clojure.contrib.prxml)) | |
;; | |
;; Enhanced List Comprehensions supporting arbitary group-by, filtering and ordering. | |
;; | |
;; (from [ BINDING GENERATOR -- One or more Generator clauses | |
;; :when PREDICATE ] -- Zero or more Guards | |
;; :group-by [ EXPRESSION :into [KEY_NAME GROUP_NAME]] -- Optional Group-By qualifier | |
;; :having PREDICATE -- Optional Group Guard |
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 Data.Maybe | |
import Text.Printf | |
import Control.Applicative | |
data Expr = Term Int | Op Operator Expr Expr | Var String | |
deriving (Show, Eq) | |
data Operator = Sum | Mult | Sub | Div | |
deriving (Show, Eq) | |
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 Expressions where | |
import qualified Data.Map as M | |
import Text.Printf | |
import Control.Monad | |
import qualified Control.Monad.Error as E | |
testExpr = (Op Sum (Val 1) (Symbol "x")) | |
type Value = Either Error Int |
NewerOlder