所谓高阶函数(higher-order function) 就是操作函数的函数,它接收一个或多个函数作为参数,并返回一个新函数。 下面的例子接收两个函数f()和g(),并返回一个新的函数用以计算f(g());//返回一个新的可以计算f(g())的函数//返回的函数h()将它所有的实参传入g()...
分类:
编程语言 时间:
2015-06-24 20:34:00
阅读次数:
112
对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:[sql]view plaincopyselectidfromtwherenumisnu...
分类:
其他好文 时间:
2015-06-24 18:11:53
阅读次数:
104
从100万条记录中的得到成绩最高的记录”。看到这个题目,通常我们的做法是: select top 1 * from student order by score desc 但是这样做你会发现,如果有几个人分数并列第一,这样就只能取到一个记录。用下面的...
分类:
其他好文 时间:
2015-06-24 16:50:53
阅读次数:
127
QuestionGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example:
Given binary tree {3,9,20,#,#,15,7}, 3
/ 9 20
/...
分类:
其他好文 时间:
2015-06-24 16:30:04
阅读次数:
97
db.pay_order.find({"id":"5332336532"},{"tradeNo":true,"status":true,"create":true}).forEach(function (a) { a["create"] = (new Date(a["create"]).toString()); printjson(a) })...
分类:
数据库 时间:
2015-06-24 12:57:56
阅读次数:
277
在日常作业中,有时候可能是一些活动要抽出得奖人或选出抽查的一些名单, 就常常会使用到 Order BY Newid() 的方式来做随机数选出, 但有可能的状况需是要搭配到 DISTINCT 来选出,这时候如 DISTINCT 与 Order By Newid() 同时使用就会遇到错误讯息「如果已指定...
分类:
其他好文 时间:
2015-06-24 10:56:24
阅读次数:
90
Search Insert Position
题目:
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may as...
分类:
其他好文 时间:
2015-06-24 09:23:34
阅读次数:
116
原文:4--视图模型1、创建视图 1 array('id'=>'cid','title'=>'ctitle','alias'=>'calias','published'=>'cpublished','order'=>'corder','access'=>'caccess','sectionid'),...
分类:
其他好文 时间:
2015-06-24 02:00:41
阅读次数:
144
原文:ThinkPhp学习11一、常用连贯操作 1.where 帮助我们设置查询条件 2.order 对结果进行排序 $arr=$m->order('id desc')->select(); $arr=$m->order(array('id'=>'desc','sex'=>'asc'))->sele...
分类:
Web程序 时间:
2015-06-24 01:54:57
阅读次数:
121
原文:PHP 二维数组根据某个字段排序要求:从两个不同的表中获取各自的4条数据,然后整合(array_merge)成一个数组,再根据数据的创建时间降序排序取前4条。 遇到这个要求的时候就不是 ORDER BY 能解决的问题了。因此翻看 PHP 手册查找到了如下方法,做此笔记。 1, 'name' =...
分类:
编程语言 时间:
2015-06-24 00:39:46
阅读次数:
172