By Leo Rudberg, for the UPL Video Lecture Series
First, let's make sure that you have ghc
and ghci
installed:
$ ghc --version && ghci
# ghci should boot up...
class Abstr { | |
constructor(f, o) { | |
this.f = f; | |
for (var key in o) { | |
this[key] = o[key]; | |
} | |
} | |
run () { | |
this.f(this); | |
} |
flr = 0 | |
cc = 1 | |
basement_char = nil | |
File.open('parens.txt', 'r') do |file| | |
file.each_line do |line| | |
line.chars.each do |c| | |
if c == '(' | |
flr += 1 | |
elsif c == ')' |
import Data.Matrix | |
import Data.List --(sortBy, intercalate, minimumBy, maximumBy, filter, nubBy) | |
import qualified Data.Vector as Vector -- hiding (Vector(++)) | |
import System.Environment (getArgs) | |
import Data.Bits (xor, rotate, shift, complement) | |
data Cell = Empty | Wall deriving (Eq) | |
instance Show Cell where | |
show c = case c of | |
Empty -> " " | |
Wall -> "#" |
// Whether Passenger p (you) can get on the bus at Time t | |
public boolean attemptToGetOnBus(Passenger p, Time t) throws HustleError { | |
if (!p.location().equal("CS Building")) { | |
return false; // what are you doing, kiddo? | |
} else if (!p.isRegisteredForWildHacks()) { | |
return false; | |
} | |
Time startTime = Time.earliestOf(LEO.arrival(), Time.FIVE_THIRTY); | |
First, let's make sure that you have ghc
and ghci
installed:
$ ghc --version && ghci
# ghci should boot up...
import qualified Data.Set as Set | |
phi :: Set.Set a | |
phi = Set.empty | |
pset :: (Ord a) => Set.Set a -> Set.Set (Set.Set a) | |
pset set = if (Set.null set) | |
then Set.singleton phi | |
else | |
let head = Set.elemAt 0 set |
import java.awt.Color; | |
import java.awt.Graphics; | |
import java.awt.image.BufferedImage; | |
import java.io.*; | |
import javax.imageio.ImageIO; | |
import java.lang.Math; | |
import java.lang.Number; | |
public class Grid | |
{ |
import Data.List (nub, unfoldr) | |
-- FIXME | |
primeItr :: Integer -> Integer -> Bool | |
primeItr n i | |
| (i * i) > n = True | |
| otherwise = if (n `mod` i) == 0 | |
then False | |
else primeItr n (i + 1) | |
isPrime :: Integer -> Bool | |
isPrime n = primeItr n 2 -- 2-7 primes do not count (n > 10) |
-- the middle integer item from a list | |
middle :: [Integer] -> Integer | |
middle list = list !! (fromIntegral midInd) | |
where midInd = length list `div` 2 | |
-- the median of three integer values | |
-- thanks to Tony Jiang from HH Coding for the improved algo! | |
qMed3 :: Integer -> Integer -> Integer -> Integer | |
qMed3 a b c = min firstMax (max firstMin c) | |
where firstMax = max a b |