我定义了以下函数:
ex 1 x = 1
ex 0 x = 0
ex b x = b ** x
Run Code Online (Sandbox Code Playgroud)
然后,当我执行以下操作时:
1 `ex` (sum [1..])
Run Code Online (Sandbox Code Playgroud)
它试图计算无限序列的总和,而不是懒惰和返回1.为什么?
编辑:经过进一步调查,我发现如果我ex在文件中定义函数会发生懒惰,但如果我在GHCI中定义它则不会:
$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> let ex 1 x = 1
Prelude> let ex b x = b ** x
Prelude> ex 1 (sum [1..])
<interactive>: out of memory (requested 1048576 bytes)
Run Code Online (Sandbox Code Playgroud)
如果我将ex定义拉入文件(在本例中为test.hs):
$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ …Run Code Online (Sandbox Code Playgroud) 获取字符串表示中的秒数(如"hh:mm:ss")的最佳方法是什么?
显然Integer.parseInt(s.substring(...))*3600 + Integer.parseInt(s.substring(...))*60 + Integer.parseInt(s.substring(...))有效.
但我不想测试它,并重新发明风暴,我希望有一种方法可以使用DateTimeFormat或标准库中的其他类.
谢谢!
这甚至可能吗?如果我有一天想sprintf(str, "%doodle %d", var);输出"%doodle 123"而不是"123oodle",我怎么能阻止第一个%d被处理?
所以我使用ubuntu 8.04在amazon ec2上安装node.js,并运行node sayhello.js以下代码:
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
setTimeout(function () {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<br/><strong> Hello World!</strong>');
res.end();
sys.puts(sys.inspect(req, false));
}, 2000);
}).listen(8000);
sys.puts('Server running at http://ec2-174-12-132-193.compute-1.amazonaws.com:8000/');
Run Code Online (Sandbox Code Playgroud)
我知道了
服务器运行 http://ec2-174-12-132-193.compute-1.amazonaws.com:8000/
正确显示在控制台中.
该教程说:去:8000在浏览器中,你应该看到的Hello World!
我去了http://ec2-174-12-132-193.compute-1.amazonaws.com:8000/(不是真正的地址)但它没有加载(只是连接...).该示例使用localhost,是否正在进行公共域不正确或某些此类?
谢谢.
我创建了一个Hello world应用程序,但是得到了这个奇怪的错
The project cannot be built until the build path errors are resolved
Run Code Online (Sandbox Code Playgroud)
我没有改变项目,jut创建它并尝试运行它.
我手动使用此代码来模拟系统通过代码单击鼠标.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1 : Form
{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public Form1()
{
}
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
$message = "Good news! The item# $item_number on which you placed a bid of \$ $bid_price is now available for purchase at your bid price.\n
The seller, $bid_user is making this offer.\n
\nItem Title : $title\n
\nAll the best,\n
$bid_user\n
$email\n
";
echo $message;
$htmlContent = $baseClass->email_friend($item_number, $title, $bid_price, $bid_user, $mcat, $message, $email, $VIEWSTATE, $EVENTVALIDATION, $URL);
Run Code Online (Sandbox Code Playgroud)
问题是新的换行符 (\n)不起作用.
你们许多人可能还记得旧的DOS程序 - 调试.虽然在许多方面已经过时,但其中一个好处是可以轻松找到给定指令的字节序列,而无需完成编写程序,编译,反汇编,检查文件内容的步骤. ..输入指令,然后转储指令地址.令人遗憾的是'debug'不会执行32位指令.
有没有人知道一个类似于32位x86指令的工具?我不想经历整个编译过程; 我只需要能够输入几条指令并让它显示指令的长度及其字节序列.
我想开发一个应用程序,它必须解析Auto CAD软件生成的Industry Foundation Class(IFC),并使用Java在applet窗口中渲染3D图像.我不知道怎么做.如果有人知道解决方案,请帮助我.