我必须做一个软件来识别C中的令牌。我有以下代码:
*main = do
x <- readFile "progc.c"
let resultado = lexCmm X
print resultado
lexCmm :: String -> [Tok]
lexCmm X = case X of
c:cs | isSpace c -> lexCmm cs
c:cs | isAlpha c -> getId s
c:cs | isDigit c -> getInt s
c:d:cs | isSymb [c,d] -> TS [c,d] : lexCmm cs
c:cs | isSymb [c] -> TS [c] : lexCmm cs
_ -> []
where
getId s = lx i : lexCmm cs where …Run Code Online (Sandbox Code Playgroud) data MinList (min : ?) : Set where
[] : MinList min
_??_?_ : (x : ?) -> min ? x -> MinList x -> MinList min
Run Code Online (Sandbox Code Playgroud)
什么是<< >>意味着什么?
或者是什么意思
_??_?_ : (x : ?) -> min ? x -> MinList x -> MinList min
谢谢
我正在写一个很大的代码,我不希望它都在我的main.c中,所以我写了一个.inc文件,其中包含带有函数的IF-ELSE语句,我想知道它是否可以像这样编写:
#if var==1
process(int a)
{
printf("Result is: %d",2*a);
}
#else
process(int a)
{
printf("Result is: %d",10*a);
}
#endif
Run Code Online (Sandbox Code Playgroud)
我试图编译它,但它给了我错误,或者在最好的情况下,它只是在第一个函数进程上没有检查var变量(它被设置为0).
我正在使用haskell进行解析,我想解析以这种方式表示的时间戳值
946685561.618847
Run Code Online (Sandbox Code Playgroud)
我没有问题来识别(解析)它,但我的问题是关于结果的类型.我想到两种情况:
Int范围从-2 29到2 29 - 1?在Haskell中,我在定义函数时遇到了一些问题,因为我的参数类型与所需类型不匹配.
例如,我想编写一个函数,它接受n :: Int并生成从1到floor平方根的整数列表n.因此我会有一个功能,如:
list :: Int -> [Int]
Run Code Online (Sandbox Code Playgroud)
最初我定义的功能如下:
list :: Int -> [Int]
list n = [1 .. floor (sqrt n)]
Run Code Online (Sandbox Code Playgroud)
当我加载sript时,会出现类型不匹配的错误消息.但是,我不确定我是否不匹配sqrt函数或floor函数的类型.错误消息如下:
No instance for (Floating Int)
arising from a use of 'sqrt' at pe142.hs:6:22-27
Possible fix: add an instance declaration for (Floating Int)
In the first argument of 'floor', namely '(sqrt n)'
In the expression: floor (sqrt n)
In the expression: [1 .. floor (sqrt n)]
Failed, …Run Code Online (Sandbox Code Playgroud) 如果我正在使用lambda表达式,那么在生产规则中快速计算表达式的值是不行的.
例如这段代码
Exp : let var '=' Exp in Exp { \p -> $6 (($2,$4 p):p) }
| Exp1 { $1 }
Exp1 : Exp1 '+' Term { \p -> $1 p + $3 p }
| Exp1 '-' Term { \p -> $1 p - $3 p }
| Term { $1 }
Term : Term '*' Factor { \p -> $1 p * $3 p }
| Term '/' Factor { \p -> $1 p `div` $3 p …Run Code Online (Sandbox Code Playgroud) 当我运行"rails server"命令并转到我的网页时,我收到此错误http://s7.postimg.org/jcxqxl3gr/image.png我正在使用Postgresql并且只安装了twitter-bootstrap-rails宝石.我使用的是rails 4.0.0.为什么它会向我显示此错误?我通过railsinstaller安装了所有东西,但是通过rubygems更新到4.0.0.
任何帮助都会受到重视,
阿马尔
编辑:
对于迟到的编辑很抱歉,但这是我的开发日志文件的当前内容:
Started GET "/" for 127.0.0.1 at 2013-07-02 09:39:00 +1200
PG::Error (could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
):
activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize'
activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `new'
activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'
activerecord (4.0.0) …Run Code Online (Sandbox Code Playgroud) 我需要解析html页面.据我所知,BeautifulSoap是最流行的用于在Python中解析html页面的库.Haskell怎么样?我找到了一些像tagsoup,http-conduit和xml-conduit,HXT 而且我在犹豫哪个选择.你的建议?