y :: b
とおく。x :: c
とおく。y x :: d
とおく。- (1.)(2.)(3.)より
b
とc -> d
は等しい。 - (4.)より
y :: c -> d
である。 x (y x) :: a
とおく。- (2.)(3.)(6.)より
c
とd -> a
は等しい。 - (2.)(7.)より
x :: d -> 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
import System.Random (RandomGen, getStdGen, randoms) | |
import Control.Concurrent (threadDelay) | |
import System.Process (callCommand) | |
import Data.List.Split (chunksOf) | |
import Data.Maybe (fromMaybe) | |
type Cell = Bool | |
type CellTable = [[Cell]] | |
type Score = Int | |
type Pos = (Int, Int) |
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 canvas; | |
var ctx; | |
var x; | |
var y; | |
var isRightPressed; | |
var isLeftPressed; | |
var isUpPressed; | |
var isDownPressed; | |
window.addEventListener('load', function() { |
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
function quicksort([x, ...xs]: number[]): number[] { | |
return typeof x === 'undefined' ? [] : (() => { | |
const smallerSorted = quicksort(xs.filter(a => a <= x)); | |
const biggerSorted = quicksort(xs.filter(a => a > x)); | |
return [...smallerSorted, x, ...biggerSorted]; | |
})(); | |
} |
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
const { value, stories } = new Writer(3, ['3']) | |
.write(x => [x * 5, '* 5']) | |
.write(x => [x + 3, '+ 3']); | |
print(value).next(() => print(stories.join(' '))).run(); | |
// Output: | |
// 18 | |
// 3 * 5 + 3 |
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
Task.delay(1000).next(() => print('Yeah')); |
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
// Task | |
const logTask = Task.sync<string, void>(text => console.log(text)); | |
const taskA = Task.delay(1000).map(() => 1 + 2 + 3).map(String); | |
const taskB = Task.resolve('Hello'); | |
Task.all([taskA, taskB]).map(xs => xs.join(', ')).next(logTask).run(); | |
Task.race([taskA, taskB]).next(logTask).run(); | |
// Promise | |
const logPromise = (text: string) => console.log(text); | |
const promiseA = new Promise<void>(resolve => setTimeout(resolve, 1000)).then(() => 1 + 2 + 3).then(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
var p = console.log.bind(console); | |
var q = require('readline-sync').question; | |
var r = () => Math.floor(Math.random()*15)+1 | |
var i = 1; | |
for(;;) { | |
var x = r(); | |
p(`(${i}) ${Math.pow(x, 2)}`); | |
var a = parseInt(q('Input the answer: ')); | |
var c = a === x; | |
p(c ? 'Good!' : `Bad: The correct answer is ${x}`); |
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 p = console.log.bind(console); | |
var q = require('readline-sync').question; | |
var gcd = (a, b) => !b ? a : gcd(b, a % b); | |
var r = () => Math.floor(Math.random()*9)+1 | |
var i = 1; | |
for(;;) { | |
var x = r(); | |
var y = r(); | |
var df = x % y === 0; | |
if(df) continue; |
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
interface Functor<A> { | |
map<B>(f: (a: A) => B): Functor<B>; | |
} | |
interface Monad<A> extends Functor<A> { | |
map<B>(f: (a: A) => B): Monad<B>; | |
bind<B>(f: (a: A) => Monad<B>): Monad<B>; | |
} | |
interface Eq<A> { |