小编fra*_*ank的帖子

clojure:无法访问同一个包中的非公共字段

在我的clojure程序中,我无法访问java类com.foo.Foo的包范围字段,尽管我在命名空间"com.foo"中(通过我的clojure程序顶部的"(ns com.foo)").但是,com.foo.Foo中的公共字段是可访问的.

为什么?

clojure

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

boost :: bind不编译

我是新手来提升精神,我有以下问题:

#include <string>
#include <vector>
#include <boost/spirit/include/qi.hpp>

#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>

#include <boost/bind.hpp>

using namespace boost::spirit;
using namespace std;

struct MyGrammar
    : qi::grammar<string::const_iterator, string(), ascii::space_type> {
    MyGrammar();

    void myFun(const string& s);

    private:
    qi::rule<string::const_iterator, string(), ascii::space_type> myRule;
};



using namespace boost::spirit;
using namespace std;

MyGrammar::MyGrammar() : MyGrammar::base_type(myRule) {
    using qi::_1;

    myRule = int_ [boost::bind(&MyGrammar::myFun, this, _1)]; // fails
    myRule = int_ [_val = _1];  // fine
}

void MyGrammar::myFun(const string& s){
    cout << "read: " << s << endl; …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-bind boost-spirit

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

R的data.table找不到函数“.”

我读到 data.table 理解点“。” 作为“列表”的别名。但:

> dt <- data.table(x = c(11, 22), y = c("f", "b"))
> dt
    x y
1: 11 f
2: 22 b
> dt[,.(y)]
Error in eval(expr, envir, enclos) : could not find function "."
>
Run Code Online (Sandbox Code Playgroud)

这是为什么?

r data.table

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

获取作为参数传递给 R 中嵌套函数的函数的名称

在 R 中,我需要作为参数传递给嵌套函数的函数的名称。

> fun1 <- function(f) deparse(substitute(f))
> fun2 <- function(f) fun1(f)
> fun1(mean)
[1] "mean"
> fun2(mean)
[1] "f"
> 
Run Code Online (Sandbox Code Playgroud)

如何获得一个函数的名称,而与它作为参数传递给嵌套函数的次数无关?

r

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

标签 统计

r ×2

boost ×1

boost-bind ×1

boost-spirit ×1

c++ ×1

clojure ×1

data.table ×1