-> Team { let teams = tournament.joinTeams(); let groups = tournament.emitGroups(teams); let groupResults = groups.map(tournament.runGroup); let brackets = tournament.buildBracket(groupResults); NSLog("%@", brackets); let winner = tournament.eliminate(brackets); return winner; }
| abs(a-b) <= eps = b | otherwise = within eps (b:rest) easydiff f x h = (f(x+h) − f x)/h differentiate h0 f x = map (easydiff f x) (repeat (/2) h0) within eps (differentiate h0 f x)
D | E | F | G | H | I | J | K | L | M | N deriving (Show, Enum, Bounded, Eq) edge from to = case (from, to) of (A, B) -> Just 4 (A, E) -> Just 6 (A, D) -> Just 7 -- ...
minbranch = minbranch' Unknown minbranch' :: Ord a => Bound a -> Tree a -> Bound a minbranch' bound (Tree.Node root subs) = case subs of [] -> Bound root _ -> foldr f bound subs where f sub@(Tree.Node r _) b | Bound r <= b = branch' b sub | otherwise = b -- **prune !!!**
-> Team { let teams = tournament.joinTeams(); let groups = tournament.emitGroups(teams); let groupResults = groups.map(tournament.runGroup); let brackets = tournament.buildBracket(groupResults); NSLog("%@", brackets); let winner = tournament.eliminate(brackets); return winner; }
a = {- constructor for a computation that returns a value of type `a' -} ! :: Effects a -> (a -> Effects b) -> Effects b ! a f = {- perform computation `a', then feed its result to `f' which will give a computation `b' -} unit :: a -> Effects a unit a = {- make `a' pretend to be a computation -}
f => Monad (Free f) where return = Return (>>=) :: Free f a -> (a -> Free f b) -> Free f b x >>= f = case x of Return a -> f a Free as -> Free (fmap (>>= f) as)
Query (Input -> next) bot :: [Input] -> Free Dialog Input -> Int bot answers program = case program of Return x -> x Free (Ask q f) -> case answers of (x:xs) -> bot xs (f x) [] -> error "lol"
https://mirage.io/wiki/tutorial-lwt let start c = Lwt.join [ (Time.sleep_ns (Duration.of_sec 1) >>= fun () -> C.log c "Heads"); (Time.sleep_ns (Duration.of_sec 2) >>= fun () -> C.log c "Tails") ] >>= fun () -> C.log c "Finished"
+ b let f: Rep<(Float2D, Float2D, Float1D) -> Float2D> = lambda { x, w, b in x • w + b } // Staged function ’g’, type-inferred from ’f’ let g = lambda { x, w, b in let linear = f[x, w, b] // staged function application return tanh(linear) } // Gradient of ’g’ with respect to arguments ’w’ and ’b’ let dg = gradient(of: g, withRespectTo: (1, 2), keeping: 0) // ’dg’ has type: // Rep<(Float2D, Float2D, Float1D) -> (Float2D, Float2D, Float2D)> // Call staged function on input data ’x’, ’w’ and ’b’ let (dg_dw, dg_db, result) = dg[x, w, b]