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
Prelude> let all@x:xs@a:b:s = [1..4] | |
Prelude> (all, x, xs, a, b, s) | |
(1,1,2,2,3,[4]) | |
Prelude> let all@(x:xs)@(a:b:s) = [1..4] | |
<interactive>:9:15: parse error on input `@' | |
Prelude> let all@(x:xs@a:b:s) = [1..4] | |
Prelude> (all, x, xs, a, b, s) | |
([1,2,3,4],1,2,2,3,[4]) |
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
// #[feature(globs)]; | |
extern crate collections; | |
// use std::iter::*; | |
use std::from_str::from_str; | |
// use std::str::from_utf8; | |
// use collections::hashmap::HashSet; | |
#[deriving(Clone)] | |
struct Knapsack { | |
score: uint, |
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
use std::rand; | |
use std::rand::Rng; | |
struct BinTree<T>(Option<~BinNode<T>>); | |
struct BinNode<T> { | |
value: T, | |
left: BinTree<T>, | |
right: BinTree<T>, | |
} |
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 chunks(iterable, size): | |
if not size > 0: | |
raise ValueError('size should greater than 0; not {}'.format(size)) | |
it = iter(iterable) | |
def iterate(): | |
while True: | |
chunk = list(islice(it, size)) | |
if not chunk: | |
break |
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 CeleryDaemon(script.Command): | |
capture_all_args = True | |
def run(self, args): | |
from project.tasks import initialize | |
celery = initialize(current_app) | |
celery.worker_main(argv=sys.argv[:1] + args) | |
manager.add_command('celeryd', CeleryDaemon()) |
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
// $ rustc --version | |
// rustc 0.9-pre (90754ae 2013-11-14 22:01:26 -0800) | |
// host: x86_64-apple-darwin | |
use std::task::{task, with_task_name, deschedule}; | |
use std::comm; | |
use std::io::{Timer}; | |
use std::ascii::AsciiCast; | |
fn main() { |
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
&v-1:< v *< | |
> :#^_$>\:#^_$.@ |
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
use std::to_bytes::*; | |
use std::num::{Zero, Add, Shl, NumCast}; | |
use N = std::i16; | |
trait FromBytes { | |
fn from_bytes(bytes: &[u8], lsb0: bool) -> Self; | |
} | |
impl<N: Zero + Add<N, N> + Shl<N, N> + NumCast> FromBytes for N { |
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 indexer(object): | |
def __init__(self, getter, setter=None, deleter=None, doc=None): | |
self._getter = getter | |
self._setter = setter | |
self._deleter = deleter | |
self.__doc__ = doc or getter.__doc__ | |
self._delegates = {} | |
def setter(self, func): | |
self._setter = func |
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
#!/usr/bin/env python | |
import sys | |
import text | |
if __name__ == '__main__': | |
for line in sys.stdin: | |
line = line.decode('utf-8').rstrip(u'\n') | |
while True: | |
a, line = text.east_asian_partition(line, 44) | |
a = a.rstrip(u'\0') |