如何通过F#中歧视联盟的可能"价值"进行枚举?
我想知道是否有类似于Enum.GetValues(Type)受歧视的工会的事情,我很难确定我会列举什么样的数据.我想为每个选项生成一个具有区别联合的列表或数组,其中包含一个项目.
我想用bash做什么:
> if true; then echo y; else echo n; fi
y
> if false; then echo y; else echo n; fi
n
> if false || true; then echo y; else echo n; fi
y
Run Code Online (Sandbox Code Playgroud)
现在尝试用鱼:
> if true; echo y; else; echo n; end
y
> if false; echo y; else; echo n; end
n
# Here 'or true' are just two arguments for false
> if false or true; echo y; else; echo n; end
n
# …Run Code Online (Sandbox Code Playgroud) 我正在为遗留的ASP.NET应用程序设计一些体系结构更改.我为一些模拟ASP.NET MVC的IDependencyResolver的依赖项解析的类做了原型.我不会发布,因为它几乎是相同的界面,但用其他自然语言.
我发现它可能被认为是服务位置,反过来通常(在某些情况下不完全)被谴责支持依赖注入.尽管如此,我找不到任何反对使用ASP.NET MVC的依赖项解析实现的建议.
ASP.NET MVC的IDependencyResolver是否被视为反模式?这是件坏事吗?
我已经习惯了在我的身体元素的底部伸出我的JS(按HTML5Boilerplate),但由于TurboLinks,这将是在默认情况下在轨道4,重新加载体(和标题)在每个请求时,它才有意义从现在开始把我的JS放在头上?对此有没有合适的指南或最佳实践?
我是Mongoid的新手.在我的模型文件中,我创建了一个数据类型为BigDecimal的字段.我想在其中存储时间戳.以下是我正在使用的模型:
class Test
include Mongoid::Document
field :time_stamp, type: BigDecimal
end
Run Code Online (Sandbox Code Playgroud)
以下是我用来创建文档的代码:
aTime = "Wed Apr 24 09:48:38 +0000 2013"
timest = aTime.to_time.to_i
Test.create({time_stamp: timest})
Run Code Online (Sandbox Code Playgroud)
我看到time_stamp在数据库中存储为String.任何人都可以指示我将时间戳存储为DB中的数字,以便我可以对其执行某些操作.提前致谢.
如下面的ruby示例所示,我不能lambda使用Proc从a创建的错误数量的参数调用,Method因为它对参数的数量是严格的:
# method with no args
def a; end
instance_eval(&method(:a))
# ArgumentError: wrong number of arguments (1 for 0)
method(:a).to_proc.call(1, 2, 3)
# ArgumentError: wrong number of arguments (3 for 0)
method(:a).to_proc.lambda?
# => true
Run Code Online (Sandbox Code Playgroud)
我如何得到一个Proc不是来自一个Proc或来自一个lambda的lambda Method?
我知道CSS不应该有内容,但确实如此,就像从Twitter Bootstrap文档CSS中提取的这个好框(下面):

/* Echo out a label for the example */
.bs-docs-example:after {
content: "Example";
}
Run Code Online (Sandbox Code Playgroud)
我不关心"示例",我使用类似的东西作为mixin:
.box (@legend) {
/* Echo out a label for the example */
&:after {
content: @legend;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我不需要真正的动态CSS,我可以轻松地将mixin包含在一个类中,但不是传递"Observation"我需要传递t 'box.observation':
.observation {
.box("<%= t 'box.observation' =>");
}
Run Code Online (Sandbox Code Playgroud)
Rails应该遵循Conventions over Configuration,只需添加静态CSS/LESS/SCSS就很容易了,它已经包含在一个缩小的CSS中的所有页面中.国际化CSS的惯例是什么?例如,我应该把声明放在.observation哪里?
我正在处理有很多重复行的东西:
# => [ [1, "A", 23626], [1, "A", 31314], [2, "B", 2143], [2, "B", 5247] ]
puts xs
# => [ [1, "A"], [2, "B"] ]
puts xs.uniq{ |x| x[0] }.map{ |x| [x[0], x[1]] }
Run Code Online (Sandbox Code Playgroud)
但是xs很大.我试图懒洋洋地加载它,但Enumerator #Lazy没有uniq方法.
我该如何懒惰地实现这一目标?
As the title says I want to randomize the gravity of the Text in my layout(i have allready been able to randomize the color and text size of the text) The following code is rigged to an onclicklistener :
if (check.contains("WTF")) {
Random crazy = new Random();
display.setText("WTF!!!1!");
display.setTextSize(crazy.nextInt(30));
display.setTextColor(Color.rgb(crazy.nextInt(256),crazy.nextInt(256),crazy.nextInt(256)));
display.setGravity(Gravity.CENTER);
}
Run Code Online (Sandbox Code Playgroud)
and there are a couple of else if and an else statement but i don't think that including them is relevant to the question.
我试图从scala 使用java.util.Scanner:
val scanner = new java.util.Scanner(System.in)
val line = scanner.readLine()
println(line)
Run Code Online (Sandbox Code Playgroud)
通过粘贴在scala REPL上或通过运行scala file.scala,我得到以下信息:
:2: error: value readLine is not a member of java.util.Scanner
val line = scanner.readLine()
Run Code Online (Sandbox Code Playgroud)
我想念什么?
ruby ×2
android ×1
asp.net-mvc ×1
c# ×1
css ×1
f# ×1
fish ×1
gravity ×1
if-statement ×1
java ×1
lambda ×1
mongoid ×1
proc ×1
scala ×1
turbolinks ×1