如果我有一个数组:
@int_array = (7,101,80,22,42);
Run Code Online (Sandbox Code Playgroud)
如何在不循环遍历每个元素的情况下检查整数值80是否在数组中?
我想将一个函数应用于表的特定列.对(mxn)表的第i列说.实际上我只想用该标量将该列中的所有元素相乘,但一般函数的应用也可以.
它可能只需要一些Map或MapAt命令,可能与Transpose结合使用以应用于行而不是列 - 但我无法找出用于寻址整个列(或行)的正确语法.
任何提示都将受到高度赞赏.
嗨,
我想使用NamedPipeServerStream,这是.NET 3.5中用于namedpipe通信的新功能.我想写多线程管道服务器.它是默认处理还是我应该为此编写代码.我的管道服务器应该一次处理多个请求
任何解决方案或代码?
是否有一个示例如何使用Phonegap Framework对功能进行编程以共享电子邮件,Twitter和Facebook的URL?对于Android中的示例,此功能占90%的应用程序.在Iphone中,它适用于任何应用程序.在用于Iphone的techcrunch应用程序中,当您打开文章时,您可以看到它.是否可以使用Phonegap创建它?
比方说,我有一个PostsService创建帖子:
public class PostsService : IPostsService
{
public bool Create(Post post)
{
if(!this.Validate(post))
{
return false;
}
try
{
this.repository.Add(post);
this.repository.Save();
}
catch(Exception e)
{
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这样做的问题是,如果在存储库操作期间抛出异常,则会吞下它.Create()返回false,消费者知道的所有内容Post都是未添加,但不知道原因.
相反,我想到了一ServiceResult堂课:
public class ServiceResult
{
public bool Success { get; private set; }
public Exception Exception { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
这是一个很好的设计吗?或者我甚至需要向消费者报告这些错误?是否足以说"添加帖子时发生错误".然后在服务内部记录异常?
任何其他建议表示赞赏.
当我尝试在MyActivity上使用CheckBox"活动来启动名为"MyService"的服务时,我在DDMS中看到以下错误:
W/ActivityManager( 73): Unable to start service Intent { cmp=com.example.android.myprogram/.MyService }: not found
Run Code Online (Sandbox Code Playgroud)
我使用了教程http://developer.android.com/resources/tutorials/views/hello-formstuff.html,并将提供的代码添加到我的onCreate()方法的末尾.我在MyActivity.java和MyService.java中单独指定了类.
package com.example.android.myprogram;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
public class MyActivity extends Activity {
private static final String TAG = "MyActivity";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on …Run Code Online (Sandbox Code Playgroud) 所以我想知道单元测试在处理外部依赖关系方面是如何工作的.在这里和其他地方,我已经熟悉依赖注入,以及它如何允许我们测试代码的单元(A).但是,我对如何测试现在具有外部依赖性的其他单元(B和C)感到困惑,因此他们可以将它注入原始单元(A).
例如,假设一些类Foo使用外部依赖...
class Foo
{
private ExternalDependency ed;
public int doSomethingWithExternalDependency() {...}
}
Run Code Online (Sandbox Code Playgroud)
而且Bar使用Foo ...
class Bar
{
public int doSomethingWithFoo
{
Foo f = new Foo();
int x = f.doSomethingWithExternalDependency();
// Do some more stuff ...
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我知道我可以使用依赖注入,以便我可以测试Foo,但是我如何测试Bar?我想,我可以再次使用依赖注入,但在某些时候某些单元需要实际创建外部依赖; 那我该怎么测试那个单位呢?
目前我正在使用OpenNLP工具对PoS标记德语句子,其下载网站上列出了maxent模型:
de POS Tagger Maxent model trained on tiger corpus. de-pos-maxent.bin
这非常有效,我得到的结果如下:
Diese, Community, bietet, Teilnehmern, der, Veranstaltungen, die, Möglichkeit ... PDAT, FM, VVFIN, NN, ART, NN, ART, NN ...
使用标记的句子,我想进行一些进一步的处理,我必须知道单个标签的含义.不幸的是,在OpenNLP-Wiki中搜索标签集并不是很有帮助,因为它说:
TODO: Add more tag sets, also for non-english languages
有谁知道我在哪里可以找到德国maxent模型中使用的标签集?
每次我尝试打开wavefront obj文件时,都会收到不支持的文件类型错误.为什么是这样?.obj不是3D标准吗?
我正在使用下一个代码来格式化双值:
String.Format("${0:0,0.#}",...);
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但是当数字小于10时,我遇到了问题.例如,数字显示为$ 03,$ 06.
请告诉我正确的字符串,以下一格式ddd,ddd,ddd,ddd.dd为双号
c# ×3
.net ×2
android ×1
architecture ×1
arrays ×1
blender ×1
cordova ×1
formatting ×1
named-pipes ×1
nlp ×1
opennlp ×1
perl ×1
service ×1
tags ×1
twitter ×1
unit-testing ×1