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 markedit::{Heading, Matcher}; | |
use pulldown_cmark::{Event, Parser, Tag}; | |
use std::fmt::{self, Display}; | |
use std::fs; | |
use std::io; | |
use std::mem; | |
use structopt::StructOpt; | |
#[derive(StructOpt, Debug)] | |
#[structopt(name = "mdtoc", about = "print table of contents of markdown file")] |
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
#define _GNU_SOURCE | |
#define _XOPEN_SOURCE | |
#define _DEFAULT_SOURCE | |
#include <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <pwd.h> |
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 | |
class Multimethod(object): | |
def __init__(self): | |
self.registry = {} | |
def __call__(self, *types): | |
def decorator(func): | |
self.registry[(types, func.__name__)] = 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
var assert = require('assert') | |
function concat(array, e) { | |
return [].concat(array, [e]) | |
} | |
function concatArrays(arrayA, arrayB) { | |
return [].concat(arrayA, arrayB) | |
} |
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
//pre: arr 是数组,其元素是相同类型的。 | |
//post: 函数返回排好序的数组 | |
//要求: 不能有“副作用”。 | |
//arr 的元素不得有增删改,局部变量不得被多次赋值,也不能使用任何对象的有副作用的方法,如数组的 push, pop 等。 | |
//不能用循环语句 | |
function sort(arr) { | |
//do it here | |
} | |