我想要一个次要模式,它允许以不变的方式访问数字键上的移位符号(然后移动数字).看来这对Perl代码($,@,%等等)有帮助.理想情况下,有一个切换此模式的键.有点类似于大写但仅限于数字键.
这样的模式是否已经存在?
在C语言的历史上,有没有做过增加模块系统的实验?
我知道没有制定最新标准的 C++ 提案。我正在考虑更多与特定实现相关的内容,这些实现将模块系统添加为非标准功能。
“模块系统”是指至少允许用户编写一个文件而不是 .h/.c 对的东西。
我已经UserControl定义了这个XAML并且想ItemsPanelTemplate在我的代码后面动态设置(XAML在示例中不是这样):
<UserControl>
<ItemsControl x:Name="Items">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid> <!-- I want to add this Grid definition in code behind -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
我试过类似的东西
this.Items.ItemsPanel.Template = new Grid();
Run Code Online (Sandbox Code Playgroud)
但悲惨地失败了.有帮助吗?
背景: 我只知道运行时网格列和行的数量.
Dart编程语言支持方法级联.方法级联将允许以下Silverlight/WPF C#代码:
var listBox = new ListBox();
listBox.Width = 200;
listBox.MouseEnter += (s, e) => Console.WriteLine("MouseEnter");
var button1 = new Button() { Content = "abc" };
button1.Click += (s, e) => Console.WriteLine("button1.Click");
listBox.Items.Add(button1);
var button2 = new Button() { Content = "def" };
button2.Click += (s, e) => Console.WriteLine("button2.Click");
listBox.Items.Add(button2);
ContentPanel.Children.Add(listBox);
Run Code Online (Sandbox Code Playgroud)
改为:
ContentPanel.Children.Add(
new ListBox()
..Width = 200
..MouseEnter += ((s, e) => Console.WriteLine("MouseEnter"))
..Items.Add(
new Button()
..Content = "abc";
..Click += ((s, e) => Console.WriteLine("button 1 Click"))) …Run Code Online (Sandbox Code Playgroud) 我为Visual Studio Express 2012 for Web安装了F#Tools.当我选择New Project时,我希望在Visual F#模板列表中看到F#Application,但我看到的只有F#Library和F#Tutorial.
我说我期待它,因为我在Chris Smith编写的F#3.0一书中看到了它.
有关在列表中获取F#应用程序模板的任何建议吗?
的象征库重载算术运算符.虽然它是用C#编写的,但我可以在F#中使用它:
open Symbolism
let x = new Symbol("x")
let y = new Symbol("y")
let z = new Symbol("z")
printfn "%A" (2*x + 3 + 4*x + 5*y + z + 8*y)
Run Code Online (Sandbox Code Playgroud)
输出:
3 + 6 * x + 13 * y + z
Run Code Online (Sandbox Code Playgroud)
但是,它也会超负荷^.这当然不适合F#.
作为解决方法的一步,我导出了一个权限的方法组:
printfn "%A" (Aux.Pow(x, 2) * x)
Run Code Online (Sandbox Code Playgroud)
输出:
x ^ 3
Run Code Online (Sandbox Code Playgroud)
如何重载**以使用Aux.Pow方法组?
我可以这样做:
let ( ** ) (a: MathObject) (b: MathObject) = Aux.Pow(a, b)
Run Code Online (Sandbox Code Playgroud)
这对MathObject价值观有效:
> …Run Code Online (Sandbox Code Playgroud) f# symbolic-math computer-algebra-systems symbolic-computation
Dart和Smalltalk有方法级联.
似乎可以通过类似的风格来实现do with.
例如,这是一个简单的程序,它使用GTK::Simple:
use v6;
use GTK::Simple;
my $app = GTK::Simple::App.new(title => "abc");
$app.set-content(
GTK::Simple::VBox.new(
my $button_a = GTK::Simple::Button.new(label => 'bcd'),
my $button_b = GTK::Simple::Button.new(label => 'cde')
)
);
$app.border-width = 20;
$button_a.clicked.tap({ .sensitive = False; $button_b.sensitive = True });
$button_b.sensitive = False;
$button_b.clicked.tap({ $app.exit });
$app.run;
Run Code Online (Sandbox Code Playgroud)
这是do with在几个地方使用的等效程序,以实现类似于方法级联的效果:
use v6;
use GTK::Simple;
my $app;
my $button_a;
my $button_b;
do with GTK::Simple::App.new(title => 'abc')
{
$app = $_;
.set-content(
GTK::Simple::VBox.new(
$button_a …Run Code Online (Sandbox Code Playgroud) 系统我在:
/tmp/jonesforth $ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
Run Code Online (Sandbox Code Playgroud)
这是一个32位系统.
从annexia存储库中克隆:
git clone git://git.annexia.org/git/jonesforth.git
Run Code Online (Sandbox Code Playgroud)
构建顺利:
cd jonesforth
/tmp/jonesforth $ make
gcc -m32 -nostdlib -static -Wl,-Ttext,0 -o jonesforth jonesforth.S
Run Code Online (Sandbox Code Playgroud)
然而,测试没有通过:
/tmp/jonesforth $ make test
test_stack_trace.f ... --- .test_stack_trace.test 2016-09-17 17:44:59.488492834 -0500
+++ test_stack_trace.f.out 2016-09-17 17:33:11.171189490 -0500
@@ -0,0 +1,6 @@
+TEST4+0 TEST3+0 TEST2+0 TEST+0
+3
+TEST4+0 TEST3+32 TEST2+0 TEST+0
+TEST4+0 TEST3+0 TEST2+4 TEST+0
+3
+TEST4+0 TEST3+32 TEST2+4 TEST+0
Makefile:34: recipe for target 'test_stack_trace.test' failed
make: *** [test_stack_trace.test] Error 1
Run Code Online (Sandbox Code Playgroud)
启动jonesforth会导致分段错误: …
有没有办法使用从文件加载的定义启动 Perl 6 REPL?
即假设我有这个test.p6:
sub abc() { say 123; }
Run Code Online (Sandbox Code Playgroud)
我希望能够启动 perl6 REPL 并加载该文件,以便我可以abc交互使用。
当我运行这段代码时,Equation(10, 20)输出到控制台:
public class Equation
{
public int a;
public int b;
public override string ToString()
{ return "Equation(" + a + ", " + b + ")"; }
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine(new Equation() { a = 10, b = 20 });
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
我想支持Equation在测试中使用的实例,if所以我允许隐式转换为Boolean:
public class Equation
{
public int a;
public int b;
public override string ToString()
{ return "Equation(" + a + …Run Code Online (Sandbox Code Playgroud)