我已经习惯了strtod
和变种.我想知道为什么stdlib.h没有附带strtoi.为什么整数被排除在这个派对之外?
具体来说,我问为什么没有版本的atoi具有strtod的安全功能.
我一直在emacs lisp文档中搜索如何将正则表达式搜索到字符串中.我找到的只是如何在缓冲区中执行此操作.
有什么我想念的吗?我应该将我的字符串吐入临时缓冲区并在那里搜索它吗?这只是elisp的编码风格,我会习惯吗?有没有这个问题的标准解决方案.当我应该能够直接搜索已经存在的变量时,操作缓冲区似乎很复杂.
我的问题是ocamlc和ocamlopt apear拒绝找到通过apt-get安装的第三方库.当我尝试将第三方模块合并到我自己的OCaml程序中时,我首先遇到了这个问题,并且很快将其写成个人未能理解OCaml编译.很快 - 然而 - 当我试图按照自己的指示编译其他人的项目时,我发现自己遇到了同样的问题.
这是最直接的例子.其他人都使用ocamlbuild,这会使事情变得模糊不清.
该计划:http://groups.google.com/group/fa.caml/msg/5aee553df34548e2
汇编:
$ocamlc -g -dtypes -pp camlp4oof -I +camlp4 dynlink.cma camlp4lib.cma -cc g++ llvm.cma llvm_bitwriter.cma minml.ml -o minml
File "minml.ml", line 43, characters 0-9:
Error:Unbound module Llvm
Run Code Online (Sandbox Code Playgroud)
即使我提供ocamlc与llvm文件的绝对路径,就像这样......
$ ocamlc -g -dtypes -pp camlp4oof -I +camlp4 dynlink.cma camlp4lib.cma -cc g++ /usr/lib/ocaml/llvm-2.7/llvm.cma /usr/lib/ocaml/llvm-2.7/llvm_bitwriter.cma minml.ml -o minml
Run Code Online (Sandbox Code Playgroud)
......无济于事
我究竟做错了什么?
从Lisp来到OCaml,我发现自己在函数何时返回以及何时不返回时非常困惑.我想念我的魔术报价!值得庆幸的是,大多数时候,OCaml似乎能够自动地知道我什么时候需要评估功能,何时不需要.但是,我经常发现自己试图在let表达式中分配函数的返回值,如下所示.
let start = Sys.time in
(*
* do something here
*)
;
let ending = Sys.time in
Printf.printf "did something in %f seconds\n" (ending -. start)
Run Code Online (Sandbox Code Playgroud)
但后来ocamlc抱怨
Error: This Expression has type unit -> float
but an expression was expected of type float
Run Code Online (Sandbox Code Playgroud)
告诉我开始和结束都是必然的Sys.time
,而不是返回值Sys.time
.
这种行为我试图不是OCamly吗?我想以另一种方式做事吗?我只是缺少一些完全明显的东西吗?
我过去在学习开罗时已经过了一些镜头,但总是转向其他一些图形库.我的问题是我找不到一个很好的教程,可以为我的表面提供一个简单的显示.我总是最终通过GTK或QT文档挖掘与我想做的事情无关的事情.我想学习开罗,而不是大规模的OO架构.
什么是裸骨包装,给我一个带有开罗画布的跨平台窗口?
当我尝试
> Int maxBound
Run Code Online (Sandbox Code Playgroud)
在ghci,我明白了
Not in scope: data constructor 'Int'
Run Code Online (Sandbox Code Playgroud)
即使我import Data.Int
,问题仍然存在.这里发生了什么?
我有以下代码.
template<class key,class val>
bool has_key(key chkey,std::map<key,val> map){
for (std::map<key,val>::iterator it = map.begin(); #line 13 referenced by gcc
it!=map.end(); ++it){
if(chkey == it->first) return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
海湾合作委员会给我以下错误.
objects.hpp: In function `bool has_key(key, std::map<key, val, std::less<_Key>,
std::allocator<std::pair<const _Key, _Tp> > >)':
objects.hpp:13: error: expected `;' before "it"
objects.hpp:14: error: `it' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
某种方式"它"没有被初始化,山姆海恩在这里发生了什么?!
我有以下Haskell代码
import Data.Int
import System.Environment
type Coord = (Int16, Int16)
distributePointsOverCircle :: Int16 -> Int16 -> [Coord]
distributePointsOverCircle points radius =
[ (xOf point, yOf point) | point <- [1..points] ]
where
xOf x = abstract cos x
yOf x = abstract sin x
abstract :: RealFrac a => ( a -> a ) -> Int16 -> Int16
abstract f x = (radius *) . truncate . f . fromIntegral $ (angleIncrement * x) * truncate (pi / 180)
angleIncrement …
Run Code Online (Sandbox Code Playgroud) 这个在这里出现了几次Go
,但我认为我的经历是独一无二的.这是我的代码.
type Stack []Weight
func newStack( size int, startSpread Spread ) Stack {
stack := make(Stack, size)
for _, curWeight := range stack {
curWeight = Weight{ startSpread, rand.Float64( ), rand.Float64( ) }
}
return stack
}
Run Code Online (Sandbox Code Playgroud)
为什么gc
告诉我我没用curWeight
?