小编mat*_*ker的帖子

用于分析OCaml代码的工具

除了在编译时使用-p选项然后使用gprof时,有没有人知道用于分析OCaml代码的程序?我问这个问题是为了检查0.01秒的采样时间是否可以进一步降低?

profiling ocaml gprof

15
推荐指数
3
解决办法
1948
查看次数

如何在Graphviz点文件中插入希腊字符等数学符号?

我有一个独特的问题.我使用点来表示本质上是通用的图形.因此,我不打算使用数字,而是计划使用像alpha,beta等希腊字母之类的符号.我很想知道如何使用某些符号标记.dot文件中的节点/边缘?

例如,

node1 -> node2 [label= <something here which will show up as symbol of beta> style=dashed]
Run Code Online (Sandbox Code Playgroud)

dot graphviz

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

在OCaml源代码中使用Unix函数

我有一个函数来使用函数time.ml中的unix gettimeofday()来获取当前时间.该文件以下列方式访问该函数:

open Unix; (*declared at the top of the file*)

let get_time ()  = Unix.gettimeofday ()
Run Code Online (Sandbox Code Playgroud)

.mli文件中的相应条目如下所示:

val get_time : unit -> float
Run Code Online (Sandbox Code Playgroud)

但在编译期间会抛出错误:

File "_none_", line 1, characters 0-1:
No implementations provided for the following modules:
Unix referenced from time.cmx
Run Code Online (Sandbox Code Playgroud)

我已检查/ lib/ocaml目录中是否存在以下文件:

unix.cmi, unix.a unix.cma unix.cmx unix.cmxa unix.cmxs unix.mli 
Run Code Online (Sandbox Code Playgroud)

并且路径设置正确设置为.bashrc文件.

LD_LIBRARY_PATH=~/lib
Run Code Online (Sandbox Code Playgroud)

尽管存在于同一个/ lib/ocaml目录中,但来自Printf模块的fprintf等其他函数也能正常工作.

什么想法可能是错的?我做错了什么或者我错过了什么?

unix ocaml

4
推荐指数
2
解决办法
2554
查看次数

字符串转换的字符串选项

如何在Ocaml中将字符串选项数据类型转换为字符串?

let function1 data = 
  match data with
   None -> ""
   | Some str -> str 
Run Code Online (Sandbox Code Playgroud)

我的实施错误是免费的吗?这里'data'的类型值string option.

ocaml type-conversion

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

使用正则表达式匹配 Ocaml 中的精确字符串

如何在 Ocaml 中使用正则表达式找到精确匹配?例如,我有这样的代码:

let contains s1 s2 =
let re = Str.regexp_string s2
in
try ignore (Str.search_forward re s1 0); true
with Not_found -> false
Run Code Online (Sandbox Code Playgroud)

其中 s2 是“_X_1”,s1 将“A_1_X_1”、“A_1_X_2”等字符串提供给函数“contains”。目的是当 s1 为“A_1_X_1”时找到精确匹配。但即使 s1 是“A_1_X_10”、“A_1_X_11”、“A_1_X_100”等,当前代码也会找到匹配。

我尝试使用“[_x_1]”、“[_X_1]$”作为 s2 而不是“_X_1”,但似乎不起作用。有人可以建议什么可能是错的吗?

regex ocaml

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

朋友功能的范围

我有两个类,一个两个,每个都有一个朋友成员函数,指向另一个.第一个头文件如下:

#ifndef FIRSTCLASS_H
#define FIRSTCLASS_H

class two;

class one {

private:
int one_data;

public:
friend void second_data (two *);
};

#endif
Run Code Online (Sandbox Code Playgroud)

第二个头文件如下所示:

#ifndef SECONDCLASS_H
#define SECONDCLASS_H

class one;

class two {

private:
int two_data;

public:
friend void first_data (one *);
};

#endif
Run Code Online (Sandbox Code Playgroud)

实际函数位于第三个.cpp文件中.我用适当的类限定符编写了函数,它给出了编译错误.我正在使用g ++.功能如下:

#include "firstclass.h"
#include "secondclass.h"

void two::first_data (one * class1) {

}

 void one::second_data (two * class2) {

}
Run Code Online (Sandbox Code Playgroud)

错误如下:

 error:no ‘void two::first_data (one*)’ member function declared in class ‘two’ 
 error: …
Run Code Online (Sandbox Code Playgroud)

c++ g++ friend

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

标签 统计

ocaml ×4

c++ ×1

dot ×1

friend ×1

g++ ×1

gprof ×1

graphviz ×1

profiling ×1

regex ×1

type-conversion ×1

unix ×1