Skip to content

Instantly share code, notes, and snippets.

liuhj liuhuajin

View GitHub Profile
@liuhuajin
liuhuajin / closure.py
Created Aug 2, 2015
一个经典的闭包示例
View closure.py
def too_big(limit):
def compare(x):
return x > limit
return compare
f = too_big(100)
print f(100)
print f(101)
View exp.java
import java.util.*;
//环境类:用于存储和操作需要解释的语句,在本实例中每一个需要解释的单词可以称为一个动作标记(Action Token)或命令
class Context {
private StringTokenizer tokenizer; //StringTokenizer类,用于将字符串分解为更小的字符串标记(Token),默认情况下以空格作为分隔符
private String currentToken; //当前字符串标记
public Context(String text) {
tokenizer = new StringTokenizer(text); //通过传入的指令字符串创建StringTokenizer对象
nextToken();
@liuhuajin
liuhuajin / metatable.lua
Created Jul 8, 2014
metatable 操作 lua 13.1
View metatable.lua
Set = {}
function Set.new(t)
local set = {}
setmetatable(set, Set.mt)
for _, l in ipairs(t) do set[l] = true end
return set
end
function Set.union(a, b)
View testpro
--defines a factorial function
function fact(n)
if n == 0 then
return 1
else
return n*fact(n-1)
end
end
@liuhuajin
liuhuajin / first_test.cpp
Created Jul 7, 2014
my first test for gist
View first_test.cpp
#include<iostream>
using namespace std;
int main()
{
cout << "this is the first use of gist." << endl;
}
You can’t perform that action at this time.