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 too_big(limit): | |
def compare(x): | |
return x > limit | |
return compare | |
f = too_big(100) | |
print f(100) | |
print f(101) |
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 java.util.*; | |
//环境类:用于存储和操作需要解释的语句,在本实例中每一个需要解释的单词可以称为一个动作标记(Action Token)或命令 | |
class Context { | |
private StringTokenizer tokenizer; //StringTokenizer类,用于将字符串分解为更小的字符串标记(Token),默认情况下以空格作为分隔符 | |
private String currentToken; //当前字符串标记 | |
public Context(String text) { | |
tokenizer = new StringTokenizer(text); //通过传入的指令字符串创建StringTokenizer对象 | |
nextToken(); |
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
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) |
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
--defines a factorial function | |
function fact(n) | |
if n == 0 then | |
return 1 | |
else | |
return n*fact(n-1) | |
end | |
end |
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
#include<iostream> | |
using namespace std; | |
int main() | |
{ | |
cout << "this is the first use of gist." << endl; | |
} |