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 Control.Applicative ((<$>)) | |
import Data.List (partition) | |
readNumList :: String -> [Int] | |
readNumList = map read . words | |
segmentsCount :: [Int] -> [[Int]] -> Int | |
segmentsCount [] _ = 0 | |
segmentsCount (v:vs) edges = let (vs', es') = mark v vs edges in 1 + segmentsCount vs' es' |
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
/// <reference path="../../defs/_references.d.ts" /> | |
import {createFactory} from 'react'; | |
import Rx from 'rx'; | |
import RxComponent = require('src/utils/RxComponent'); | |
const div = createFactory('div'); | |
interface CounterProps { | |
signal: Rx.Observable<number>; |
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 Control.Applicative ((<$>)) | |
import Text.Printf (printf) | |
type Solution = Maybe [Double] | |
gauss :: [[Double]] -> Solution | |
gauss [[a, b]] = return [b / a] | |
gauss (h@(x : xs) : t) = do | |
let minor = transform h t | |
if any isNull minor |
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 Control.Applicative ((<$>)) | |
import Text.Printf (printf) | |
type Solution = Maybe [Double] | |
solve :: [[Double]] -> Solution | |
solve [[a, b]] = return [b / a] | |
solve (h@(x : xs) : t) = do | |
let minor = transform h t | |
if any isNull minor |
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
var React = require('react'); | |
var {Chart, Line, Axis, Layout} = require('react-chart'); | |
var LineChart = React.createClass({ | |
propTypes: { | |
data: React.propTypes.arrayOf(React.propTypes.shape({ | |
x: React.propTypes.number.isRequired, | |
y: React.propTypes.number.isRequired | |
})).isRequired, | |
color: React.propTypes.string.isRequired |
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
var good = [ | |
[1,2,3,4,5,6,7,8], | |
[1,2,8,4,5,6,7,3], | |
[1,5,8,4,2,6,7,3] | |
]; | |
var bad = [ | |
[1,2,3,6,5,6,7,6], | |
[1,2,3,4,5,6,8], | |
[1,2,3,4,5,6,7,8,10] | |
]; |
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
<!DOCTYPE html> | |
<html> | |
<head><title>Example</title></head> | |
<body> | |
<script type="text/javascript" src="http://localhost:8090/webpack-dev-server.js"></script> | |
<script type="text/javascript" src="http://localhost:8090/assets/bundle.js"></script> | |
</body> | |
</html> |
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
(** **** Exercise: 2 stars (andb_eq_orb) *) | |
(** Prove the following theorem. (You may want to first prove a | |
subsidiary lemma or two.) *) | |
Lemma orb_always_true : | |
forall b, | |
orb true b = true. | |
Proof. reflexivity. Qed. | |
Lemma andb_always_false : |
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
instance GenServerState Command Int CounterState where | |
handle_call Get = gets counter | |
handle_cast Inc = | |
modify $ \st -> st { counter = counter st + 1 } | |
-- another instance for CounterState | |
instance GenServerState Command Float CounterState where | |
handle_call Get = gets (fromIntegral . counter) | |
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 BangPatterns, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} | |
module Proto.King.Hello (Hello(..)) where | |
import Prelude ((+), (/)) | |
import qualified Prelude as Prelude' | |
import qualified Data.Typeable as Prelude' | |
import qualified Data.Data as Prelude' | |
import qualified Text.ProtocolBuffers.Header as P' | |
import qualified Proto.King.NodeDescription as King (NodeDescription) | |
data Hello = Hello{hNodeDesc :: !King.NodeDescription} |