小编0xF*_*xFF的帖子

如何在OCAML中读取位图?

我想使用OCAML读取位图文件(来自文件系统)并将像素(颜色)存储在具有位图的第二维的数组内,每个像素将占用数组中的一个单元.

我找到了函数Graphics.dump_image image - > color array array 但它不能从文件中读取.

ocaml bitmap image-processing

6
推荐指数
2
解决办法
4068
查看次数

IIS7显示iisstart.html而不是默认文档

我在IIS7上运行了一个Sitefinity 4.1网站,我在默认文档列表的顶部设置了"Default.aspx",但是当我访问http:// www时.* .org /它显示IIS7欢迎页面.

当我访问http:// www.* .org/default.aspx它运作得很好.

我检查了Web.config中的defaultDocument部分,它设置正确,回收了应用程序池,重新启动了网站,到目前为止没有任何内容.

我错过了什么?

编辑:

这似乎是一个缓存问题,如果我添加垃圾查询字符串参数,它会重定向到正确的页面,例如:http:// www.* .org /?aaa

iis-7 web-config

6
推荐指数
1
解决办法
2万
查看次数

在Windows Phone 7上更改ListBox的滚动条颜色

我有一个<ListBox>带有白色背景的项目,我想更改滚动条颜色,以便在用户滚动项目时可以看到它们.

我怎样才能做到这一点?

silverlight xaml listbox windows-phone-7

6
推荐指数
1
解决办法
4191
查看次数

如何将迭代器与OCaml中的集合相关联

我在OCaml中有这两个类

class type ['a] collection =
  object
    method add : 'a -> unit
    method clear : unit -> unit
    method iterator : unit -> 'a iterator
    method remove : 'a -> unit
  end

class type ['a] iterator =
  object 
    method hasNext : unit -> bool 
    method next : unit -> 'a 
  end
Run Code Online (Sandbox Code Playgroud)

我需要创建两个具体类['a] queue子类型collection['a] iterator_queue子类型iterator.

我想主要知道如何定义方法,iterator : unit -> 'a iterator因为我没有看到这两种类型是如何连接的,是否['a] iterator_queue必须从两个类型继承?或者我应该采取不同的行动

collections ocaml iterator class

5
推荐指数
1
解决办法
472
查看次数

配置 MPI 主机文件以使用多个用户身份

我想在不同的机器上使用 mpirun 运行程序(所有带有 Open Mpi 1.5 的 linux 机器)。

现在我有可以登录的机器username A,还有另一组可以使用username B. 所有机器都可以通过 ssh 访问,但我不知道如何实现这一点。

我的主机文件将是这样的:

localhost          #username local

machine_set_A_1    #username A
machine_set_A_2    #username A
...

machine_set_B_1    #username B
machine_set_B_2    #username B
...
Run Code Online (Sandbox Code Playgroud)

是否有可能实现这一点。谢谢。

ssh mpi openmpi

5
推荐指数
1
解决办法
7902
查看次数

在SPARQL中测试谓词的存在

我有以下RDF模型:

@prefix : <http://test.com/#> .

:graph1   :hasNode   :node1 ;
          :centerNode   :node1 .

:graph1   :hasNode   :node2 .
:graph1   :hasNode   :node3 .
Run Code Online (Sandbox Code Playgroud)

我想运行一个SPARQL查询,其中如果a 与一个谓词:nodeX相关,我返回(或其他一些指示); 结果如下所示::graphX:centerNodetruefalse

?n       ?g        ?centered
-----------------------------
:node1   :graph1   true
:node2   :graph1   false
:node3   :graph1   false
Run Code Online (Sandbox Code Playgroud)

有没有办法在SPARQL 1.0中执行此操作?如果没有,可以在SPARQL 1.1中完成吗?

rdf sparql

5
推荐指数
1
解决办法
2187
查看次数

jQuery对话框上的动态按钮名称

我有一个网页,使用存储在localStorage中的不同语言,在jQuery对话框中,我希望按照语言动态更改按钮的名称,例如:

var btn_hello_text = getLanguageBtnHelloText();

$('#dialog').dialog({
    autoOpen: false,
    buttons: {
        btn_hello_text: function() { 
            doThings();
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

这里的问题是对话框显示一个带有文本的按钮,"btn_hello_text"而不是变量本身包含的值.我想办法动态地改变按钮文本的值,任何提示?谢谢.

jquery jquery-ui

4
推荐指数
1
解决办法
2228
查看次数

OCaml makefile依赖问题

我正在使用OCaml Makefile进行我正在进行的项目,我有以下模块

DynamicTree.ml

Huffman_Dynamic.ml 哪个使用 DynamicTree

Huffman_Static.ml

main.ml它使用Huffman_StaticHuffman_Dynamic.

这是我的make文件:

# put here the names of your source files (in the right order)
SOURCES = huffman_static.ml dynamictree.ml huffman_dynamic.ml main.ml

# the name of the resulting executable
RESULT  = huffman

# generate type information (.annot files)
ANNOTATE = yes

# make target (see manual) : byte-code, debug-code, native-code
all: native-code

include OCamlMakefile
Run Code Online (Sandbox Code Playgroud)

当我尝试创建项目时,我得到了Makefile生成的Unbound value DynamicTree.create_anchor_leaf结果ocamlopt -c -dtypes huffman_dynamic.ml.

Ocaml Makefile wepage 声明它会自动 …

ocaml makefile

3
推荐指数
1
解决办法
536
查看次数

在启用-std = c ++ 0x时编译自定义分配器的问题

我有一个Matrix类是Rows 的集合.数据类型定义如下:

行:

template <typename Index>
class Row {
public:

    Row()
    {
        _index_vector = std::vector<Index, aligned_allocator<Index> > ();
    }

    Row& operator=( const Row& source )
    {
        //some copy logic here
        return *this;
    }

private:
    std::vector<Index, aligned_allocator<Index> >       _index_vector;
};
Run Code Online (Sandbox Code Playgroud)

矩阵:

template <typename Index>
class Matrix {
public:
    typedef std::vector<Row<Index> > Rep;

    Matrix () : _m (0), _n (0)
    {}

    Matrix (size_t n, size_t m) :
            _m (m),
            _n (n)
    {
        _A = Rep (n);
    }

private: …
Run Code Online (Sandbox Code Playgroud)

c++ vector allocator c++11

3
推荐指数
1
解决办法
296
查看次数

printf可以更改其参数吗?

编辑: 主要的完整代码在这里http://codepad.org/79aLzj2H

再一次,这就是奇怪的行为正在发生

for (i = 0; i<tab_size; i++)
{
  //CORRECT OUTPUT
  printf("%s\n", tableau[i].capitale);
  printf("%s\n", tableau[i].pays);
  printf("%s\n", tableau[i].commentaire);
  //WRONG OUTPUT
  //printf("%s --- %s --- %s |\n", tableau[i].capitale, tableau[i].pays, tableau[i].commentaire);
}
Run Code Online (Sandbox Code Playgroud)

我有一系列以下strcuture

struct T_info
{
    char capitale[255];
    char pays[255];
    char commentaire[255];
};

struct T_info *tableau;
Run Code Online (Sandbox Code Playgroud)

这是阵列的填充方式

int advance(FILE *f)
{
  char c;

  c = getc(f);
  if(c == '\n')
    return 0;

  while(c != EOF && (c == ' ' || c == '\t'))
  {
    c = getc(f);
  }

  return fseek(f, -1, …
Run Code Online (Sandbox Code Playgroud)

c printf

2
推荐指数
1
解决办法
1256
查看次数

变量函数中是否共享变量

我正在尝试计算C#中递归函数中成功案例的数量,但我对所有函数调用之间共享变量的事实感到惊讶!

[更新2]

这次比奇怪多了.这样做

i = i + validTreesFun(tree.Nodes, newWords.ToList()) ;
Run Code Online (Sandbox Code Playgroud)

将i重置为0

这样做

i = validTreesFun(tree.Nodes, newWords.ToList()) + i ;
Run Code Online (Sandbox Code Playgroud)

给出一些结果(我不确定它是否正确)

[更新:完整代码]

public static  int validTreesFun(List<Tree<char>> nodes, List<string> words)
    {
        int i = 0;
        if (nodes == null && (words == null || words.Count == 0 || (words.Count == 1 && words.First() == "")))
            return 1;
        else
            if (nodes == null)
                return 0;

        foreach (Tree<char> tree in nodes)
        {
            var validWords = words.Where(w => w.ToCharArray()[0] == tree.Root)
                .Select(w => w);
            if …
Run Code Online (Sandbox Code Playgroud)

c# recursion scope

0
推荐指数
1
解决办法
2714
查看次数

xsl:cds元素在xsl:element中

我想获得以下输出:

<name><![CDATA[ SomeNameHere ]]></name>
Run Code Online (Sandbox Code Playgroud)

使用以下xslt:

  <xsl:element name="name"> 
            <xsl:cdata>
                <xsl:value-of select="name"/> 
            </xsl:cdata>
  </xsl:element>
Run Code Online (Sandbox Code Playgroud)

但是在编译时我得到以下异常:

'xsl:cdata' cannot be a child of the 'xsl:element' element.
Run Code Online (Sandbox Code Playgroud)

如何在xml节点中插入cdata元素呢?

谢谢.

xml xslt cdata

0
推荐指数
1
解决办法
997
查看次数

使用g ++ -std = c ++ 0x,代码运行速度较慢

我试图测试中的性能差异std::swap,并vector::swap和我有和没有编译-std=c++0x选项.我注意到大约200毫秒的差异,当我不包括这个选项时程序运行得更快.

#include <iostream>
#include <string>
#include <vector>

int main()
{
    commentator.setReportStream (cout);

    size_t nbElts = 2048;
    vector<int> v, w;

    v.resize (nbElts);
    w.reserve (nbElts);

    for (int i = 0; i < nbElts; ++i) {
        w.push_back (i);
    }

    commentator.start ("std::swap", __FUNCTION__);
    for (int i = 0; i < 10000000; ++i) {
        std::swap (v, w);
    }
    commentator.stop (MSG_DONE);

    commentator.start ("vector::swap", __FUNCTION__);
    for (int i = 0; i < 10000000; ++i) {
        v.swap (w);
    }
    commentator.stop (MSG_DONE);
    return …
Run Code Online (Sandbox Code Playgroud)

c++ performance g++ c++11

-1
推荐指数
1
解决办法
769
查看次数