码迷,mamicode.com
首页 >  
搜索关键字:return array    ( 86705个结果
生产者消费者 协同程序 python
生成器和普通函数有些区别,比如生成器不用return返回,而用yield来返回一系列元素 除非“召唤”生成器的next(),否则函数体里面不会执行任何代码块,上下文环境保存着。 虽然不需要明确定义__iter__()和next()方法,但是它本身包含这个方法。 当想要结束一个协程时,使用close()方法即可,close会在协程中引发GeneratorExit异常,这时候可以通过try/ex...
分类:编程语言   时间:2014-05-10 09:53:34    阅读次数:317
Lua chapter 4
1. 函数可以返回多个值 return a, b, c; 但是如果函数不是作为表达式的最后一个元素的话,仅返回第一个 如: function f2() return "a", "b" end; x, y = f2()     -> x = "a", y = "b"; x, y = f2(), 1  -> x = "a", y = nil; 2. 可以将一个函数调用放入一对圆括...
分类:其他好文   时间:2014-05-10 09:21:56    阅读次数:317
Lua chapter 6
一个简单的迭代器示例 --迭代工厂函数 function value(t)     local i = 0;     return            function()                i = i+1;                return t[i];           end; end; t = {10,20,30}; iter = va...
分类:其他好文   时间:2014-05-10 08:36:53    阅读次数:268
C++操作符的优先级 及其记忆方法
优先级操作符描述例子结合性1()[]->.::++--调节优先级的括号操作符数组下标访问操作符通过指向对象的指针访问成员的操作符通过对象本身访问成员的操作符作用域操作符后置自增操作符后置自减操作符(a + b) / 4;array[4] = 2;ptr->age = 34;obj.age = 34;...
分类:编程语言   时间:2014-05-07 09:45:56    阅读次数:396
ThinkPHP学习(四)volist标签高级应用之多重嵌套循环
Action代码: public function index(){ $prod = I("get.prod_en"); $id = I("get.id", 0, "int"); if ($prod == ""){ $serviceProduct = array();//多重循环遍历的数组 //数据保存在两张表中,这里通过循环初始化$serviceProduct数组...
分类:Web程序   时间:2014-05-07 07:13:02    阅读次数:440
felayman---ajax对象的兼容写法
function FactoryXMLHttpRequest() { if(window.XMLHttpRequest) { return new XMLHttpRequest(); }else if(window.ActiveXObject) { var msxmls = new Array( 'Msxml2.XM...
分类:其他好文   时间:2014-05-07 07:00:03    阅读次数:382
递归法求解汉罗塔hanoi问题
#include using namespace std; //汉罗塔递归求解函数 从a移到c void move(int m,char a,char c); void hanoi(int n,char a,char b,char c) { if(1==n) { move(n,a,c); return; } hanoi(n-1,a,c,b); move(n,a,c); hano...
分类:其他好文   时间:2014-05-07 03:24:14    阅读次数:228
leetcode -day8 Copy List with Random Pointer & Single Number I II
五一中间断了几天,开始继续。。。 1、 ?? Copy List with Random Pointer A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a...
分类:其他好文   时间:2014-05-06 18:54:59    阅读次数:386
【Leetcode】3Sum
【Question】 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in ...
分类:其他好文   时间:2014-05-06 14:57:29    阅读次数:318
ASP.NET MVC 动态加载图像
private ImageInfo CreateImageFile(string fileName) { if (!File.Exists(fileName)) return null; Image image = Image.FromFile(fileName); MemoryStream ms....
分类:Web程序   时间:2014-05-06 10:01:43    阅读次数:313
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!