我需要测量一个函数的CPU时间,如下所示:
t <- getCPUTime
res <- callTheFunction input
t' <- getCPUTime
print $ t' - t
Run Code Online (Sandbox Code Playgroud)
问题来自Haskell的懒惰.必须严格评估callTheFunction.我搜索了很多,并尝试使用seq和$!但没有成功.我认为这应该是一项非常普遍的任务.无论如何,我需要一些帮助.谢谢.
更新: 感谢您的所有帮助,尤其是@FUZxxl.它让我想起WHNF(弱头标准形式)和标准形式之间的区别. Haskell/Laziness 有助于理解Haskell的惰性评估.
我需要的是再做一步评估.无论如何$!只要只需要WHNF,就可以评估两种工作:
t <- getCPUTime
res <- callTheFunction input
evaluate res OR return $! res
t' <- getCPUTime
print $ t' - t
Run Code Online (Sandbox Code Playgroud) 我有一个Backbone View,它使用iScroll来实现幻灯片放映.
iScroll发布一个onScrollEnd事件,但我似乎无法在View中绑定/订阅它:
App.Views.Scroller = Backbone.View.extend({
events: {
'onScrollEnd' : 'scrollEnd'
},
initialize: function(){
var self = this;
this.scroller = new iScroll('content-scroller', {
onScrollEnd: function() {
self.trigger('onScrollEnd');
}
});
},
scrollEnd: function(e){
// never called :(
console.log(e);
}
});
Run Code Online (Sandbox Code Playgroud) 我的GWT项目中有这个简单的对象.我不能通过电线发送它.将构造函数放在这样的类中是不可能的?
public class MceDto implements IsSerializable {
public MceDto(String uri, String tag) {
this.uri = uri;
this.tag = tag;
}
public String uri;
public String tag;
public Date created;
}
Run Code Online (Sandbox Code Playgroud)
我检查了*.gwt.rpc策略,对象不在那里意味着它不是可序列化的东西.如何预先知道是否可以序列化对象?
谢谢
我想对电子邮件地址进行 URL 编码。我在w3schools上输入“bmackey@foo.com” ,但它没有编码“@”或“.”。我正在使用encodeURI()并且有相同的结果。到底是怎么回事?
至少,我认为它没有编码,因为我在 FireBug Net 选项卡中看到:
GET http://dev:8989/SJMUserManager/Service/Index/bmackey@foo.com
我期待看到
GET http://dev:8989/SJMUserManager/Service/Index/bmackey%40foo%2Ecom
我希望这是发布此内容的正确位置,有人可以提供帮助.
我是一名音乐技术专业的学生,我最近学习了C++,因为它对我的职业生涯有很大帮助,因为它可以用于视频游戏行业.
无论如何进入主题.我想要创建的是一个程序(在C++中),它允许用户加载一个16位线性PCM WAVE文件.然后我想操纵该波形文件中的音频样本数据.我想要删除每个第n个样本,或者在某个参数内随机化它们(±10%).然后将其写为新的WAVE文件.
我对WAVE文件和RIFF标题的结构比较熟悉.我现在也使用Xcode作为我的IDE(因为我的macbook pro是我的工作计算机),但如果需要,我可以使用代码块在我的PC上编码.
所以简单来说它应该显示类似的东西?我知道这里有错误,所以你知道我在追求什么:
#include <iostream>
using namespace std;
class main() //function start
{
string fileinput; //variable
string outlocation; //variable
cout << "please type file path directory: \n \n";
cin >> fileinput; //navigate to file by typing
cout << "Where would you like to save new file? \n \n";
cin >> outlocation; //select output by typing
// Then all the maths and manipulation is done
cout << "Your file has been created at ";
cout << outlocation; …Run Code Online (Sandbox Code Playgroud) 在Mac OS X上,vm_allocate()允许创建可清除的内存区域.当检测到记忆压力时,内核可以在任何时间(除非被锁定时)被内核回收.它对于缓存数据等非常有用.
我想知道Linux(内核2.6)上是否存在类似的机制.谷歌搜索引导我在Android上讨论可能被清除的共享内存分配的一些信息,但我还没有看到任何有关在vanilla Linux上实际执行此操作的API的讨论.该手册页的审查mmap,shmat等等,表明没有任何标志的设置可清除区域.Linux上是否提供此功能?
Android上有关此功能的说明如下:
谢谢!
我有一个具有引用其他实体的属性的实体(示例中为ReferenceEntity).
使用HQL,我可以这样做:
select e.ReferenceEntity from Entity e where e.Id = :entityId
Run Code Online (Sandbox Code Playgroud)
NHibernate会给我一个没有懒惰的ReferenceEntity实例.
通过im尝试查询执行此操作:
Session.QueryOver<Entity>()
.Where(e => e.Id == entityId)
.Select(e => e.ReferenceEntity)
.SingleOrDefault<ReferenceEntity>()
Run Code Online (Sandbox Code Playgroud)
使用QueryOver Nhibernate给了我ReferenceEntity但是懒惰.
我想通过查询来获得ReferenceEntity和eager加载,就像我使用hql一样.
谢谢
如何精确匹配句子中的给定字符串。
例如,如果句子是var句子=“ Google Wave基本上是捕获通信的文档”
而给定的字符串是var inputString =“ Google Wave”。我需要检查上述句子中Google Wave的确切存在并返回true或false。
我试过了
if(sentence.match(inputString)==null){
alert("No such word combination found.");
return false;
}
Run Code Online (Sandbox Code Playgroud)
即使有人输入“ Google W”,此方法也有效。我需要找到完全匹配的方法。请帮忙
早上好,下午或晚上,
要么在MSIL或JIT编译器更换之类的东西1 << 5或1 << 31与代码32和2147483648分别,否则他们将等待执行的方法来评估这些常量"及时",因为它们涉及到其他的方法(经营者)?
非常感谢你.
我在Sharepoint 2010中获得了一个带有选择列的列表.选项是复选框.
如何使用其余的api查询选择列?
我试过用了
http://sp2010/_vti_bin/listdata.svc/mylist?$filter=myChoicesColumn/xxx eq something
Run Code Online (Sandbox Code Playgroud)
然后我明白了
类型'System.Collections.Generic.IEnumerable`1 [[Microsoft.SharePoint.Linq.DataServiceEntity,Microsoft.SharePoint.Linq,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c]]'中不存在属性'xxx'在第6位.
我应该使用什么属性?
javascript ×3
audio ×1
backbone.js ×1
c# ×1
c++ ×1
caching ×1
cil ×1
events ×1
gwt ×1
gwt-rpc ×1
haskell ×1
jit ×1
lazy-loading ×1
linux ×1
linux-kernel ×1
nhibernate ×1
operators ×1
queryover ×1
rest ×1
select ×1
sharepoint ×1
urlencode ×1