我想写一个函数,可以检查列表中的每个项是true还是false.如果至少有一个元素为false,则返回true,以便:
assert_eq"checkFalse [true; false; true]"(checkFalse [true; true; true])false; assert_eq"checkFalse [false; false]"(checkFalse [false; true])true;
我是OCaml的绝对初学者,我不知道如何处理这个问题.我尝试使用for循环,例如:
assert_eq "checkFalse [true; false; true]" (checkFalse [true; true; true]) false;
assert_eq "checkFalse [false; false]" (checkFalse [false; true]) true;
Run Code Online (Sandbox Code Playgroud)
然后它说"未绑定的记录字段......"
我也尝试过使用find:
true
但我的方式不起作用.我来自Java背景.
非常感谢你!
我试图在运行时确定对象的大小.sizeof不起作用,因为它在编译时返回大小.这是我的意思的一个例子:
class Foo
{
public:
Foo()
{
c = new char[1024*1024*1024];
}
~Foo()
{
delete[] c;
}
private:
char *c;
};
Run Code Online (Sandbox Code Playgroud)
在这种情况下,sizeof(Foo)将是4个字节而不是〜1GB.如何在运行时确定Foo的大小?提前致谢.
我在互联网上找到了一些代码如下(稍加修改).
它只是请求网页的内容.
Private Sub readWebpage(ByVal url As String)
Dim Str As System.IO.Stream
Dim srRead As System.IO.StreamReader
Try
' make a Web request
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
srRead = New System.IO.StreamReader(Str)
' read all the text
textContent.text = srRead.ReadToEnd
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unable to download content from: " & url)
Finally
srRead.Close()
Str.Close()
End Try
End Sub
Run Code Online (Sandbox Code Playgroud)
但是我得到两个警告:
Warning 1 Variable 'srRead' is used before it has …Run Code Online (Sandbox Code Playgroud) 我想设置一个外部配置文件,我可以将它存储在我的 WPF 应用程序的目录中,也不一定是我创建程序时的 exe 目录。
我创建了一个 App.Config 文件并将 System.Configuration 添加到我的程序集中。我的 App.Config 有:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="sd.config">
<add key="username" value="joesmith" />
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的 sd.config(外部文件)现在在我的项目的根目录中,有
<?xml version="1.0"?>
<appSettings>
<add key="username1" value="janedoe" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
在我使用的 MainWindow cs 类中
string username = ConfigurationManager.AppSettings.Get("username1");
Run Code Online (Sandbox Code Playgroud)
它返回一个空字符串。当我刚刚从 App.Config 检索用户名字段时,它可以工作。我错过了什么?非常感谢!
我有一个非常"长"的屏幕,显然当我使用Ext JS 3.3.1消息框时,它一直到底部并删除后台的所有内容.
这是一些示例代码:
Ext.Msg.show({
title:'[SOME TITLE]',
msg: '[SOME MESSAGE]',
buttons: Ext.Msg.YESNO,
fn: function (btn){
if(btn=='yes'){
//Do something
}
}
},
icon: Ext.Msg.QUESTION}
);
Run Code Online (Sandbox Code Playgroud) 我正在寻找亚马逊EC的一个小型Linux主机设置,其中包含多达十几个网站,我希望标准的PHP/MySQL网站具有良好的性能.在考虑以下情况时,我想了解亚马逊服务的物有所值:
...与其他类似价格的Linux VPS主机设置相比.
我知道可伸缩性对亚马逊来说是一个很大的好处,但我对上述3个因素更感兴趣.
我一直在使用static关键字来定义内部链接.后来,我转而采用C++方式在匿名命名空间中包装本地事物.
但是,现在当我使用匿名命名空间多年时,我开始认为static关键字更容易使用!
一个常见的问题是我有这种模式:
namespace {
// ...five pages of code...
} // namespace
Run Code Online (Sandbox Code Playgroud)
要查看某个函数是否具有内部或外部链接,我现在必须滚动很多,而不是旧的C样式,我可以检查函数/对象是否static在它前面.
我知道匿名命名空间有些东西static不能 - 隐藏typedef - 但不管怎样,我个人对此并不是很感兴趣.
你对此有何看法?匿名命名空间的胜利是否很好,它保证了可读性的降低?或者我都错了?
这是我试图用CSS渐变构建的按钮渐变:

这通常很容易做到,但正如您所看到的,顶部的渐变看起来更像是一个大的剪切径向渐变,因为它在中间向下倾斜并且不会一直延伸到边缘.
那么,任何想法如何用CSS来解决这个问题?
我正在努力让我的CheckBoxes适当地集中在我的内心GridViewColumn.
我已经Style为我的CheckBoxes 定义了一个:
<Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Margin" Value="4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type GridViewColumn}},Path=ActualWidth}" />
</Style>
Run Code Online (Sandbox Code Playgroud)
我的CheckBoxes被添加到GridViewColumn使用DataTemplate这样的:
<GridViewColumn Header="Comment">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Style="{StaticResource DataGridCheckBox}" IsChecked="{Binding PropertyItem.Comment, Converter={StaticResource booleanConverter}, ConverterParameter='string'}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Run Code Online (Sandbox Code Playgroud)
但我CheckBox遇到的问题是es保持左对齐(即使调整列的大小).
有任何想法吗?
先谢谢,
桑尼
编辑: 我一直CheckBox在一个空白窗口搞乱,我认为问题可能与CheckBox …
请问我面临一个简单的问题..这是问题,在我的lex文件中我有类似的东西:
char *ptr_String;
"name = " { BEGIN sName; }
<sName>.+ {
ptr_String = (char *)calloc(strlen(yytext)+1, sizeof(char));
strcpy(ptr_String, yytext);
yylval.sValue = ptr_String;
return NAME;
}
Run Code Online (Sandbox Code Playgroud)
现在在我的Yacc文件中,我有类似于:
stmt_Name:
NAME
{
/*Now here i need to get the matched string of <sName>.+ and measure it's length. */
/*The aim is simply outputing the name to the screen and storing the length in a global variable.
}
;
Run Code Online (Sandbox Code Playgroud)
请问有什么建议?非常感谢您的所有时间和帮助.