无标题文档
$(function(){
//获取第一个option的值
var firstval=$('#selectID option:first').val();
alert(firstval);
//获取最后一个option的值
var lastval =$('#selectID option:last').val();
alert(lastval);...
分类:
Web程序 时间:
2014-07-22 23:02:15
阅读次数:
367
表
a = { }
b = { x = 1, ["hello, "] = "world!" }
a.astring = "ni, hao!"
a[1] = 100
a["a table"] = b
function foo()
end
function bar()
end
a[foo] = bar
--分别穷举表a和b
for k, v in pairs(a) do
print(k, "=>",...
分类:
其他好文 时间:
2014-07-22 23:00:33
阅读次数:
261
函数环境
function foo()
print(g or "No g defined!")
end
foo()
setfenv(foo, { g = 100, print = print }) --设置foo的环境为表{ g=100, ...}
foo()
print(g or "No g defined!")
--No g defined!
--100
--No g defined!...
分类:
其他好文 时间:
2014-07-22 22:59:54
阅读次数:
338
函数闭包
function createCountdownTimer(second)
local ms=second * 1000;
local function countDown()
ms = ms - 1;
return ms;
end
return countDown;
end
timer1 = createCountdownTimer(1);
for...
分类:
其他好文 时间:
2014-07-22 22:59:53
阅读次数:
307
1.粒子化function Dot(X, Y, Z, R) { this.dx = X;
this.dy = Y; this.dz = Z; this.tx = 0; ...
分类:
编程语言 时间:
2014-07-22 22:59:53
阅读次数:
400
Keyboard inputPython provides a build-in
function called raw_input (in version 2.x) that gets input from the keyboard. In
Python 3.x we use input(). W...
分类:
其他好文 时间:
2014-05-01 19:23:26
阅读次数:
392
RecursionIt is legal for one function to call
another; it is also legal for a function to call itself. It may not be obvious
why what is a good thing,...
分类:
其他好文 时间:
2014-05-01 18:40:44
阅读次数:
302
//由于函数是对象,所以可以直接把函数通过参数传递进来;也可以把函数作为返回值。
function calFun(fun,arg){
//第一个参数就是函数对象
return fun(arg);
}
function sum(num){
return num+100;
}
function say(str){
alert("hello "+str);
}
//...
分类:
Web程序 时间:
2014-04-30 22:41:38
阅读次数:
324
根据SGI官方文档,仿函数也叫函数对象(Function Object, or Functor),定义就是任何可以像函数一样被调用的对象。一个普通的函数是函数对象,一个函数指针当然也是,广义上说任何定义了operator()的类对象都可以看作是函数对象。
仿函数(Functor、Function Object)
传递给STL算法的函数型参数(functional arguement)不一定要是...
分类:
编程语言 时间:
2014-04-30 22:28:38
阅读次数:
243
public function index(){
header('Content-Type:text/html;charset=utf-8 ');
$M = M("Constant");
$count = $M->where($where)->count();
import("ORG.Util.Page"); // 导入分页类
...
分类:
Web程序 时间:
2014-04-30 22:27:39
阅读次数:
343