我有以下格式的文字:
ERR_OUT_OF_MEM, "ERR OUT OF MEM"
ERR_SOMETHING_BAD, "ERR SOMETHING BAD"
Run Code Online (Sandbox Code Playgroud)
我想用下划线替换文本中带引号的所有空格:
ERR_OUT_OF_MEM, "ERR_OUT_OF_MEM"
ERR_SOMETHING_BAD, "ERR_SOMETHING_BAD"
Run Code Online (Sandbox Code Playgroud)
我能想到的最好的正则表达式是:
\("\w\+\)\@<=
Run Code Online (Sandbox Code Playgroud)
(那里有一个空间)
但是这只能找到每个引用字符串中的第一个空格,我需要多次重复这个空格才能获得所需的效果.
有什么办法一次性完成吗?
谢谢!
我正在学习Haskell,并试图理解类型系统.
我正在尝试编写一个函数,它返回系列'Half或Three Plus One'的长度作为输入.这是我对函数的尝试,使用递归方法(该函数仅对整数输入有效):
hotpo :: (Integral a) => a->a
hotpo n = hotpoHelper n 1
hotpoHelper:: (Integral a) => a->a->a
hotpoHelper 1 n = n
hotpoHelper num count
| even num = hotpoHelper (truncate (num/2)) (count+1)
| otherwise = hotpoHelper (3*num+1) (count+1)
Run Code Online (Sandbox Code Playgroud)
这是我尝试在GHC 6.12.3中加载此文件时得到的错误
test.hs:8:30:
Could not deduce (RealFrac a) from the context (Integral a)
arising from a use of `truncate' at test.hs:8:30-45
Possible fix:
add (RealFrac a) to the context of
the type signature for `hotpoHelper'
In the …
Run Code Online (Sandbox Code Playgroud)