我一直在玩装配一段时间并查看一些代码.其中AL首先设置为0x84,然后使用cmp AL,0x30.然后该指令触发溢出标志.
从我读到的CMP应该从第一个数字中减去第二个数字然后设置标志,在这种情况下它应该是0x84-0x30,结果是0x54并且没有溢出.
我有一个简单的问题.哈斯克尔正在向57 - Undefined variable "f" error我投掷,我不知道为什么.如果你能看一下,我会很感激的.
码:
eval :: Expr -> Environment -> Float
eval expr env = eval' expr
where
eval' :: Expr-> Float
eval' (Num num) = num
eval' (App app exprs) = foldl1 (f) (map eval' exprs) -- **Line 57**
eval' (Id id) = 5
where
f = getFunctionForApp app -- **f is here**
getFunctionForApp :: String -> (Float->Float->Float)
getFunctionForApp "+" = (+)
getFunctionForApp "-" = (-)
getFunctionForApp "*" = (*)
getFunctionForApp "/" = (/) …Run Code Online (Sandbox Code Playgroud) 假设我有一个简单的程序,它采用以下形式之一的参数输入
do1 inputLocation outputLocation do2 inputLocation
outputLocation
do3 [30或60或90] inputLocation
outputLocation do4 [PD或C] inputLocation
outputLocation do5 [GHI] inputLocation outputLocation
我还需要在程序中调用5个具有相同名称的函数.到目前为止,我想过这样做(在"半伪代码"中)
static void main(String[] args)
{
if (args.length == 3)
processTriple(args);
if (args.length == 4)
processQuadruple(args);
throw new UnsupportedOperationException("dasdhklasdha");
}
Run Code Online (Sandbox Code Playgroud)
过程函数看起来像这样
processDouble(String args[])
{
String operation = "args[0]";
Location input = getInput(args[1]);
Location output = getInput(args[2]);
if (operation.equals("do1"))
do1(input,output);
if (operation.equals("do2"))
do2(input,output);
... etc
}
Run Code Online (Sandbox Code Playgroud)
我这样做的方式似乎不太可扩展.如果一个函数的参数发生了变化,或者添加了新函数,那么这似乎很难维护.什么是"最好"的方式来做这样的事情