在MOE SVL中,如何将int转换为令牌?例如,我应该如何替换something,以便:
my_int = 0;
my_tok = tok_cat ['start', something my_int, 'end'];
pr my_tok;应打印:
start0end发布于 2021-08-06 08:53:03
或者,您也可以将totok应用于每个元素,以防有多个数字要转换:
my_int = 0;
my_tok = tok_cat totok ['start', my_int, my_int, 'end'];
pr my_tok;
'start00end'但是,如果您有一个字符串,则需要首先通过token标记它
my_string = "test";
my_tok = tok_cat ['start', token my_string, 'end'];
pr my_tok;
'starttestend'由于字符串是字符的向量,所以字符串上的totok将导致标记字符的向量:
my_string = "test";
pr totok my_string;
['t','e','s','t']因为SVL是一种将标量和向量结果组合成向量的向量语言:
my_string = "test";
my_tok = tok_cat ['start', totok my_string, 'end'];
pr my_tok;
['starttend','starteend','startsend','starttend']发布于 2021-06-25 20:54:34
正如帮助文档的类型转换函数页所描述的那样,函数是totok。
my_int = 0;
my_tok = tok_cat ['start', totok my_int, 'end'];
pr my_tok;https://stackoverflow.com/questions/68136969
复制相似问题