小编Cyb*_*hot的帖子

R绘图撤消线段?

是否有一个快速简便的功能来撤消一个片段或从你的情节中删除它?

    p1 <- locator(1)
    p2 <- locator(1)
    segments(p1$x, p1$y, p2$x, p2$y, col = 'pink')
    //Undo segments
Run Code Online (Sandbox Code Playgroud)

我的意思是说,是否可以存储您要擦除的线段(每个像素的颜色/强度),然后再添加粉红色线段的线段实际上撤消粉红色线段绘制.如何实现这一目标?

r segment

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

在向量c ++中获取字符串数

我有这个载体

vector <string> data

data = ["this is", "data that", "is in", "this is", "vector", "vector", "vector"]
Run Code Online (Sandbox Code Playgroud)

我如何获得一个矢量(或2D数组)来删除重复项,而不是每个第i个条目的计数?

 results = [("this is", 2), ("data that", 1), ("is in", 1), ("vector", 3)]
Run Code Online (Sandbox Code Playgroud)

c++ string stl vector count

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

ARM程序集十六进制乘法

有人可以向我解释以下内容吗?

以下是最小长度ARM指令序列,它将R1乘以常量0x0110 003F而不使用乘法指令

ADD r2, r1, r1, LSL #4      //r2 = 0x11 * r1
RSB r3, r1, r1, LSL #6      //r3 = 0x3F * r1
ADD r3, r3, r2, LSL #20     //r3 = 0x0110 003F * r1
Run Code Online (Sandbox Code Playgroud)

我不确定为什么0x110X3F以前习惯0x0110 003F

任何熟悉ARM体系结构或hex的人都能为我解释一下这个程序吗?为什么使用RSB?

assembly hex arm

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

制作未绑定变量列表(LISP)

我有以下LISP代码

(defun l (x y) (list x y))
Run Code Online (Sandbox Code Playgroud)

当我这样做时,(l a a)我得到A没有价值的错误.

我希望这回来(aa).我怎么能克服这个?

lisp list

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

LISP cdr功能

如果我做

(setq x   '(NOT (NOT (NOT (NOT A)))) )
Run Code Online (Sandbox Code Playgroud)

(cdr x)(NOT (NOT (NOT A))))

(cdr (cdr x))NIL

这里发生了什么?

lisp cdr

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

Prolog将变量附加到列表中

我想在列表中附加一个变量N,它绑定到一个数字.

N = 1.

append([N], [2,3,4], Z).

Z = [N,2,3,4]. //Wrong output!
Run Code Online (Sandbox Code Playgroud)

我想得到 Z = [1,2,3,4]

如何追加变量的数字部分,而不是实际变量本身?

list append prolog

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

使用随机数gen的相对概率

如果我有事件A,B,C的相对概率发生.

即P(A)= 0.45,P(B)= 0.35,P(C)= 0.20,

如何使用0到1之间的随机数生成器来表示?

即R =兰特(0,1)

if (R < 0.45)
   event A

else if(R < 0.35)
  event B

else if(R < 0.20)
  event C
Run Code Online (Sandbox Code Playgroud)

以上适用于两个事件A,B,但我认为由于存在重叠,上述情况对于三个或更多是错误的.

这显然是一个非常简单的问题,答案应该立即明显,但我看起来太愚蠢了.

random probability

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

继承和构造函数的问题

在定义我的Element类时,我收到以下错误:

no matching function for call to ‘Dict::Dict()’ word1.cpp:23:
    note: candidates are: Dict::Dict(std::string) word1.cpp:10:
    note: Dict::Dict(const Dict&)
Run Code Online (Sandbox Code Playgroud)

我没有打电话给任何人,我只是让Element从Dict继承.这有什么问题?

另一个错误是在我的Word类构造函数中我得到以下内容:

In constructor ‘Word::Word(std::string)’: word1.cpp:71:
    note: synthesized method ‘Element::Element()’ first required here
Run Code Online (Sandbox Code Playgroud)

在这一点上我真的很沮丧,因为对我来说一切似乎都没问题.

#include <iostream>
#include <vector>
#include <sstream>
#include <string.h>
#include <fstream>

using namespace std;

class Dict {
   public:
    string line;
    int wordcount;
    string word;
    vector <string> words;

    Dict(string f) {
        ifstream in(f.c_str());
        if (in) {
            while (in >> word) {
                words.push_back(word);
            }
        }
        else cout << "ERROR couldn't open file" …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance

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

R编程功能没有()

所以,我有以下非常简单的map.r文件.

我正在尝试让用户在交互模式下键入"click",然后使用该功能.

由于它是一个函数,用户必须键入"click()"我如何才能使它们只需要单词(没有括号),然后让该函数对img做一些事情.

所以用户输入:

mydist( "image.pnm")

点击

//然后单击函数会执行它应该执行的操作

mydist <- function(mapfile) {

    img <- read.pnm(mapfile)

    plot(img)
}

click <- function() {

    //Prompt user to click on img
}
Run Code Online (Sandbox Code Playgroud)

interactive r function

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

标签 统计

c++ ×2

lisp ×2

list ×2

r ×2

append ×1

arm ×1

assembly ×1

cdr ×1

count ×1

function ×1

hex ×1

inheritance ×1

interactive ×1

probability ×1

prolog ×1

random ×1

segment ×1

stl ×1

string ×1

vector ×1