我正在尝试使用指定为的算法实现unify函数
unify ? ? = idSubst
unify ? ? = update (?, ?) idSubst
unify ? (?1 ? ?2) =
if ? ? vars(?1 ? ?2) then
error ”Occurs check failure”
else
update (?, ?1 ? ?2) idSubst
unify (?1 ? ?2) ? = unify ? (?1 ? ?2)
unify (?1 ?1 ?2) (?3 ?2 ?4) = if ?1 == ?2 then
(subst s2) . s1
else
error ”not uni?able.”
where s1 = unify ?1 ?3
s2 = unify (subst …
Run Code Online (Sandbox Code Playgroud) 我有一个字典定义为
Dictionary<string, int> one
它有一些数据,我在上面做LINQ
var temp = one.OrderBy(r => r.Value).Select(r => r.Key).Take(5);
但现在我想将它转换回`Dictionary
我试过用 temp.ToDictionary(r => r.Key, r => r.Value);
但它告诉我:无法将lambda表达式转换为'System.Collections.Generic.IEqualityComparer'类型,因为它不是委托类型
我该如何进行转换?
我试图写出定义为的字符串的字节大小
#define PATHA "/tmp/matrix_a"
使用代码
rtn=write(data,(strlen(PATHA)*sizeof(char)),sizeof(int));
if(rtn < 0)
perror("Writing data_file 2 ");
Run Code Online (Sandbox Code Playgroud)
我回来了 Writing data_file 2 : Bad address
这是一个错误的地址究竟是什么?数据文件描述符是打开的,并且在上述代码段之前和之后正确写入。要写入文件的数据必须data
是原始数据,而不是 ASCII。
我也试过将字符串定义为 char[] 并有同样的问题
我有一个搜索树,定义为:
data (Ord a) => Stree a = Null | Fork (Stree a) a (Stree a) deriving Show
Run Code Online (Sandbox Code Playgroud)
我必须定义两个函数,mapStree:
mapStree :: (Ord b, Ord a) => (a -> b) -> Stree a -> Stree b
Run Code Online (Sandbox Code Playgroud)
和foldStree:
foldStree :: (Ord a) => (b -> a -> b -> b) -> b -> Stree a -> b
Run Code Online (Sandbox Code Playgroud)
我不完全了解发生了什么,也不知道该怎么做.
我收到了一个错误 "Cross-thread operation not valid: Control 'AllOtherStatus' accessed from a thread other than the thread it was created on."
我有这个代码:_output
设置为AllOtherStatus
,查看调试器,_output.InvokeRequired
是false
这段代码工作正常,直到我改变了一个不使用这段代码的无关类.代码到达else语句然后抛出异常.
private void Thread(Object p)
{
lock (this)
{
if (_output.InvokeRequired)
{
if(s!= null)
_output.Invoke(new MethodInvoker(delegate { _output.AppendText(s); }));
}
else
_output.AppendText(s);
s = null;
}
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是,为什么_output.InvokeRequired
突然返回时会突然返回false?
我有一个Dictionary<char, int> charstat
可以计算一个角色的出现次数.我想从这本词典中获得5个最常见的字符数.如何做到这一点.
一些示例数据:
<'T', 1>
<'A', 2>
<'C', 5>
<'Q', 10>
<'B', 3>
<'Z', 7>
Run Code Online (Sandbox Code Playgroud)
从这里我想得到最大数量的顺序:
Q
Z
C
B
A
Run Code Online (Sandbox Code Playgroud)