Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
from abc import ABC, abstractmethod | |
class Proposition(ABC): | |
def __and__(self, other): | |
return CompositeProposition('and', self, other) | |
def __or__(self, other): | |
return CompositeProposition('or', self, other) |
This file contains 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
\documentclass[a4paper,11pt]{jsarticle} | |
\usepackage{amsmath,amsfonts} | |
\usepackage{bm} | |
\usepackage[dvipdfmx]{graphicx} | |
\usepackage{amsthm} | |
\usepackage{ascmac} | |
\newtheorem*{definition}{定義} | |
\newtheorem*{axiom}{公理} | |
\newtheorem*{theorem}{定理} |
This file contains 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
# コンピュータに愛を囁いてもらえる……かもしれない | |
def formula(x, y): | |
return x**2 + (y - (x**2)**(1/3))**2 | |
def draw_char(x, y, point='*', space=' '): | |
return point if abs(formula(x, y) - 12) < 2 else space | |
def draw(): | |
print('\n'.join(''.join(draw_char((y - 20) / 5, (x - 15) / 2) for y in range(0, 40)) for x in range(0, 30)[::-1])) |
This file contains 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
from abc import ABC, abstractmethod as abstract | |
class AbstractMapping(ABC): | |
@abstract | |
def __iter__(self): | |
""" | |
return an iterator or iterable denotes mapping keys | |
""" | |
yield from [] |
This file contains 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
from functools import wraps | |
from inspect import signature | |
def carry(func): | |
""" | |
carrying most of functions, methods or built-in functions. | |
""" | |
params = [*signature(func).parameters.items()] | |
if any(map(lambda x: x[1].kind&1 == 0, params)): | |
raise ValueError('Undeterminable length of varargs was declared.') |
This file contains 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* monteCarlo() { | |
let it = 0; | |
let prev = 0; | |
while (true) { | |
prev = prev * it / (it + 1) + (Math.random() ** 2 + Math.random() ** 2 < 1 ? 1 / (it + 1) : 0); | |
it++; | |
const res = prev * 4; | |
yield { current: res, iterations: it, diff: Math.PI - res }; | |
} | |
} |
This file contains 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 Conditional<T> { | |
then: (expr: () => T) => Conditional<T>; | |
fail: (expr: () => T) => Conditional<T>; | |
result: () => T | undefined; | |
} | |
export default function cond<T>(condition: boolean): Conditional<T> { | |
let res: T | undefined; | |
return { |
This file contains 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
Require Import List. | |
Import ListNotations. | |
Fixpoint reversed { A: Type } (xs: list A) := | |
match xs with | |
| nil => nil | |
| x :: xs' => reversed xs' ++ [x] | |
end. | |
Lemma reversed_sub: |
This file contains 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
from re import match | |
def validateEmail(email): | |
valid = 'abcdefghijklmnopqrstuvwxyz1234567890!#$%&\'*+-/=?^_`{}|~' | |
if not email: | |
return False | |
email = email.lower() | |
if email.startswith('"'): | |
i = 1 | |
while i < min(64, len(email)): |