最近,在一本书中我读了这段代码.您能否定义此代码的方式以及此代码的工作方式.
int i = 0;
for (; i != 10; )
{
Console.WriteLine(i);
i++;
}
Run Code Online (Sandbox Code Playgroud) 请考虑以下代码:
public enum SomeCode
{
NIF = 0
,NIE = 1
,CIF = 2
,PAS = 3
,NIN = 4
,SSN = 5
,OTH = 5
,UKN = 6
}
Run Code Online (Sandbox Code Playgroud)
会改变OTH = 5成OTH = 7一个突破性的变化吗?
编辑:我从不存储int值,只存储枚举的文本表示.它可能在其他DLL中使用,但会使用相同的存储.
在Google和Yahoo Maps API中,我阅读了服务条款:
您不应该:"存储或允许最终用户存储来自Yahoo! Maps API的地图图像,地图数据或地理编码位置信息,以备将来使用;"
我的项目的问题和范围是建立一个房地产网站.发布用于出售他/她的房屋的广告的用户将能够写出房屋的地址,或者将其直接指向地图.然后我会将这个纬度/经度数据保存到mysql数据库中,这样我以后可以在新用户寻找待售房屋时检索它.
这是正确的程序吗?这与上述条款有何关系?我的意思是,如果我不能存储简单的纬度/经度,地理编码系统如何有用呢?
我正在使用Solrs TermsComponent来实现自动完成功能.我的文档包含我在"标签"字段中编入索引的标签.现在,我可以使用TermsComponent找出所有存储文档中使用的标记.到目前为止,这非常有效.
但是还有一些额外的要求:每个文档都有一个所有者字段,其中包含拥有它的用户的ID.自动填充列表应仅包含文档中的标记,请求自动填充的用户实际拥有该标记.
我试图设置查询参数,但这似乎被TermsComponent忽略:
public static List<String> findUniqueTags(String beginningWith, User owner) throws IOException {
SolrParams q = new SolrQuery().setQueryType("/terms")
.setQuery("owner:" + owner.id.toString())
.set(TermsParams.TERMS, true).set(TermsParams.TERMS_FIELD, "tags")
.set(TermsParams.TERMS_LOWER, beginningWith)
.set(TermsParams.TERMS_LOWER_INCLUSIVE, false)
.set(TermsParams.TERMS_PREFIX_STR, beginningWith);
QueryResponse queryResponse;
try {
queryResponse = getSolrServer().query(q);
} catch (SolrServerException e) {
Logger.error(e, "Error when querying server.");
throw new IOException(e);
}
NamedList tags = (NamedList) ((NamedList)queryResponse.getResponse().get("terms")).get("tags");
List<String> result = new ArrayList<String>();
for (Iterator iterator = tags.iterator(); iterator.hasNext();) {
Map.Entry tag = (Map.Entry) iterator.next();
result.add(tag.getKey().toString());
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
那么有没有办法限制由TermsComponent返回的标签,还是我手动查询用户的所有标签并自己过滤?
我可以将Style应用于下面"Labeled"的输出吗?
Manipulate[\[Lambda],
Control@{{\[Lambda], 401,
Style[" \[Lambda]", Black, Bold, 24]},
Range[401, 570, 1],
ControlType -> Slider,
ControlPlacement -> Bottom,
Appearance -> "Labeled",
ImageSize -> 200}]
Run Code Online (Sandbox Code Playgroud)
这是滑块的右侧部分:

putStrLn当使用任何参数调用时,将始终返回type的值IO ().我同意这是纯粹的,我可以处理.但它是否具有参考透明度?我是这么认为的,因为对于任何给定的输入,你可以用一个IO ()将在stdout抛出正确字符串的函数调用替换.
所以我很酷putStrLn,但是getLine当没有参数调用时可以返回任何数量的东西,只要它们是类型的IO String.这既不是纯粹的,也不是引用透明的吗?
愚蠢的迂腐问题,它可能不会改变我编写代码的方式,但我真的想要一劳永逸地解决这个问题.(我知道IO monad会正确排序,这不是我的问题)
这为我提出了另一个问题.编译器是否足够智能以识别不带输入的程序?比如说我编译
main = putStrLn . show $ map (+1) [1..10]
Run Code Online (Sandbox Code Playgroud)
GHC是否足够聪明,可以将该程序减少到IO ()导致[2,3,4,5,6,7,8,9,10,11]打印出来的程序?或者它仍在运行并在运行时评估/执行所有内容?对于不需要输入的任意程序也是如此.GHC是否采用了这样一个事实:整个程序是透明的,并且可以简单地用它的价值取代?
haskell functional-programming side-effects referential-transparency
在POSIX环境中使用系统调用来操作文本文件(open(), close(), read(), write())时,有没有办法检查我在使用时是否实际关闭了文件描述符close(file_descriptor)?
示例:
int main(int argc, char **argv)
{
int input_file; // file descriptor for input file
int output_file; // file descriptor for output file
input_file = open(argv[1], O_RDONLY));
ouput_file = open(argv[2], ...file properties & permissions and crap.....);
// blah blah blah...
close(input_file);
close(output_file);
// what can I code here to check if the file descriptor was actually closed?
}
Run Code Online (Sandbox Code Playgroud) 什么是<big>元素的CSS等价物?如果我没有弄错,那么将文本包装在<big>元素中与设置更大的文本不同font-size.
我是Thrift的新手.我想我正确安装了它.我有以下的库:
luckyan315@ubuntu:~/code/thrift-0.8.0/tutorial/cpp$ ll /usr/local/lib/
total 11496
drwxr-xr-x 4 root root 4096 Mar 23 19:35 ./
drwxr-xr-x 10 root root 4096 Oct 12 22:27 ../
-rwxr-xr-x 1 root root 4100463 Mar 31 20:26 libthrift-0.8.0.so*
-rw-r--r-- 1 root root 7256552 Mar 31 20:26 libthrift.a
-rwxr-xr-x 1 root root 991 Mar 31 20:26 libthrift.la*
lrwxrwxrwx 1 root root 18 Mar 23 19:35 libthrift.so -> libthrift-0.8.0.so*
-rwxr-xr-x 1 root root 160727 Mar 31 20:26 libthriftz-0.8.0.so*
-rw-r--r-- 1 root root 218290 Mar 31 20:26 libthriftz.a …Run Code Online (Sandbox Code Playgroud) c# ×2
.net ×1
autocomplete ×1
c ×1
c++ ×1
client ×1
cpu-word ×1
css ×1
deprecated ×1
enums ×1
haskell ×1
html ×1
low-level ×1
low-level-io ×1
maps ×1
reference ×1
side-effects ×1
solr ×1
solrj ×1
thrift ×1