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
import curtana.lib.parser as P | |
def withcolor(color): | |
return lambda text: '\033[1;%dm%s\033[1;m' % (color, text) | |
def is_hashtag_char(c): | |
return c == "_" or c.isalnum() or 12353 <= ord(c) <= 12534 or 20124 <= ord(c) <= 40657 | |
SCREEN_NAME = P.StringA ** P.Char("@") * P.join ** +(P.alnum | P.Char("_")) | |
HASHTAG = P.StringA ** P.Char("#") * P.join ** +P.Sat(is_hashtag_char) |
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
class Quantify(object): | |
""" | |
メソッドを量化する。 | |
量化子はクラス属性のqで指定する。 | |
""" | |
def __init__(self, iterable): | |
self.iterable = iterable | |
def __lt__(self, other): | |
return self.__class__.q(el < other for el in self.iterable) |
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
infixl 1 ☢>>=☢ | |
class Monad m => UnsafeMonad m where | |
(☢>>=☢) :: m a -> (a -> b) -> b |
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 consume(iterator, n=None): | |
"Advance the iterator n-steps ahead. If n is none, consume entirely." | |
# Use functions that consume iterators at C speed. | |
if n is None: | |
# feed the entire iterator into a zero-length deque | |
collections.deque(iterator, maxlen=0) | |
else: | |
# advance to the empty slice starting at position n | |
next(islice(iterator, n, n), None) |
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
# coding: utf-8 | |
import re | |
import datetime | |
import json | |
from itertools import imap | |
from curtana.common import twitterlib, userstream | |
NAME = "" | |
PATTERN = re.compile(ur"^ゆ$|^ゆ\s?RT @") |
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
import Control.Applicative | |
import Control.Arrow | |
import Control.Monad | |
import Data.Function | |
import Data.List | |
import Data.Array | |
import Data.Tuple | |
import System.Random | |
type Mapping = Array Char Int |
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
collect :: (Functor m, Monad m) => Int -> [m [a]] -> m [a] | |
collect 0 _ = return [] | |
collect _ [] = return [] | |
collect 1 (x:_) = take 1 <$> x | |
collect n (x:xs) = x >>= \v -> (v ++) <$> collect (n - length v) xs |
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
(load "lazier.scm") | |
(load "prelude.scm") | |
(load "prelude-numbers.scm") | |
(lazy-def '(main input) '(parse-unlambda i input)) | |
(lazy-def 'parse-unlambda | |
'((lambda (x) (x x)) | |
(lambda (self cont input) | |
((nth (car input) dispatch-list) (self self) cont (cdr input)) ))) |
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
import Control.Arrow | |
import Control.Applicative | |
import Data.Char (chr, ord) | |
import System.Exit | |
import System.Environment | |
import System.IO | |
infixl 9 :$ | |
data Expr = Expr :$ Expr | I | K | S | Inc | Export {-# UNPACK #-} !Int deriving Show |
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
````sii``s`k`s`k`si``s`k`s`kk``s`k``ss`kk``s`k``s`kks``s`k`s``s``s``si`k``si`k`k | |
i`k`````s``si``s``sss``ss`ki```ss``ssi``ss`ki``s`ksk``s`k`s``si`kik``s``si`k``s` | |
`s`ksk``s``s`k``s`ksk``s`ksk`k``s`ksk`k``````s``s`ks`ssi``ss`ki``s`ksk``s`k`s``s | |
i`kik``s``si`k`k``si`ki`k``s``si`ki`k``s``si`k`k``si`kk`k`````ss``s``sss``ss`ki` | |
`s`ksk``s`k`s``si`kik``s``si`k`k``si`ks`k```si```sii``s`k`si``sii``s`k`s``si`kik | |
`kk``s`kk``siii |