我想在我的macbook air(2011版)上安装Eclim.但是在安装过程中我遇到了一些问题.它告诉我,我没有安装make和gcc.
我试图找到它的解决方案,但所有解决方案都在谈论使用XCode.实际上,我安装了XCode.但我仍然无法安装Eclim,因为没有安装make和gcc.
如何安装它们才能安装Eclim?
我刚刚使用病原体和子模块将Powerline插件安装到我的vim中.
仅当多个缓冲区位于何处时,电源线才可见.当vim中只有一个缓冲区时,我看不到它.
我想知道它是不是一个bug?
我有一个学生和一个课程模型.学生属于课程,课程有很多学生.
class Student < ActiveRecord::Base
attr_accessible :course_id, :name, :password, :status, :studentID, :year
belongs_to :course
validates :name, :password, :status, :studentID, :year, :presence =>true
validates_associated :course
end
class Course < ActiveRecord::Base
attr_accessible :courseCode, :courseName, :courseYr
validates :courseCode,:courseName,:courseYr, :presence => true
validates :courseCode,:courseYr, :uniqueness=>{:message=>"Cannot repeat the code"}
has_many :students
end
Run Code Online (Sandbox Code Playgroud)
在用于创建学生记录的表单中,我让用户输入课程ID.
<div class="field">
<%= f.label :course_id %><br />
<%= f.text_field :course_id %>
</div>
Run Code Online (Sandbox Code Playgroud)
但我不知道如何验证course_id
用户的输入.即使我键入不存在的课程ID,学生模型验证也不会生成错误.如何让它显示错误?
我正在阅读Data.Map的源代码,我发现!()用于数据构造函数中data Map k a
.
data Map k a = Tip
| Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a)
Run Code Online (Sandbox Code Playgroud)
我发现这!( )
不会影响patten如何匹配数据.在mapWithKey的功能中,模式匹配仍然适用于5件事.所以我不认为它是一个运营商.
mapWithKey f (Bin sx kx x l r)
Run Code Online (Sandbox Code Playgroud)
谷歌后,我发现!( )
可能与-XBangPatterns
懒惰评估有关.我对吗 ?还是出于其他目的?
在我解决离散数学的程序中,我想让用户输入一串逻辑运算; 例如,如果用户输入let f (x:y:_) = x && y
,那么我将得到一个功能,f
用于该程序的其余部分.在GHCi中,我可以通过输入轻松测试我的程序let f (x:y:_) = x && y
.
我不知道如何完成这项任务.我已经eval
从plugins
包中看了一下这个函数,但它似乎不是正确的函数.我可以在Haskell中这样做吗?
我计划使用它的代码是:
type TruthTable = [[Bool]]
type TruthTableResult = [([Bool], Bool)]
solveTable :: ([Bool] -> Bool) -> Integer -> (TruthTableResult)
solveTable f n = let table = truthTable n
result = map f table
in zipWith (\v r -> (v, r)) table result
Run Code Online (Sandbox Code Playgroud) 我想检查前一个的条件,if condition
以确定下一个if condition
是否要执行.每个人都if condition
可以返回一个值.
编辑:对不起,我之前提供的例子有些奇怪... :(这是我真实的例子,我想简化if-then-else
为goingToMove
goingToMove p routes points w h =
if canMove p points
-- the point can be moved in the map
then let r = routes ++ [p]
l = remainList p points
in move p r l w h
-- the point cannot be moved in the maps
else []
move p routes points w h =
if (length routes) == 2
then routes
else …
Run Code Online (Sandbox Code Playgroud) recursion haskell functional-programming if-statement tail-recursion
假设我想创造一个游戏.在游戏开始时,玩家将挑选一个怪物.
公平地挑选怪物很容易.
// get all monsters with equal chance
public Monster getMonsterFair(){
Monster[] monsters = {new GoldMonster(), new SilverMonster(), new BronzeMonster()};
int winIndex = random.nextInt(monsters.length);
return monsters[winIndex];
}
Run Code Online (Sandbox Code Playgroud)
并不公平地挑选怪物.
// get monsters with unequal chance
public Monster getMonsterUnFair(){
double r = Math.random();
// about 10% to win the gold one
if (r < 0.1){
return new GoldMonster();
}
// about 30% to winthe silver one
else if ( r < 0.1 + 0.2){
return new SilverMonster();
}
// about 70% …
Run Code Online (Sandbox Code Playgroud) 我正在阅读的源代码reads
.reads
被定义为reads :: Read a => ReadS a
它只是返回ReadS a
而a必须是一个实例Read
.
并且ReadS a
被定义为type ReadS a = String -> [(a, String)]
,所以返回的东西reads
只是一个函数,它接受一个字符串并返回一个元组数组.
然后我想知道为什么reads
没有ReadS 定义a.就像
reads :: Read a => (String -> [(a, String)])
我刚刚将我的XCode升级到4.5并安装了SDK 6.0.我发现SDK 5.0消失但我仍然可以下载回Iphone 5.0模拟器.
我只是想知道天气我可以使用SDK 6.0开发iOS 5.1应用程序.我已经进行了如下图所示的配置.
我正在读这本书,它谈到了类型类的定义Eq
在Eq中有两个函数==
,/=
它们实现为:
x == y = not (x /= y)
x /= y = not (x == y)
Run Code Online (Sandbox Code Playgroud)
书中说它们是相互递归的,函数的结果是在另一个函数的项目中.
我不明白的是我在相互递归中没有看到基本情况,我不明白为什么函数会停止并返回结果.