我使用WinGHCi和我的代码(非常简单)如下:
module Main
where
import IO
main = do
hSetBuffering stdin LineBuffering
putStrLn "Enter your name: "
name <- getLine
putStrLn("Hello, " ++ name ++ ", how are you?");
Run Code Online (Sandbox Code Playgroud)
错误信息:
2.hs:4:8:
Could not find module `IO'
It is a member of the hidden package `haskell98-2.0.0.1'.
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)
(该代码在WinHugs中正确运行,但我只是想编译它)
也许问题真是微不足道,但我自己研究Haskell,没有人可以咨询.我尝试在谷歌搜索,遗憾的是找不到任何有意义的东西.
我卡住了...先谢谢你.
我有以下代码
f = open('BigTestFile','w');
str = '0123456789'
for i in range(100000000):
if i % 1000000 == 0:
print(str(i / 1000000) + ' % done')
f.write(str)
f.close()
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到了这个TypeError:
Traceback (most recent call last):
File "gen_big_file.py", line 8, in <module>
print(str(i / 1000000) + ' % done')
TypeError: 'str' object is not callable
Run Code Online (Sandbox Code Playgroud)
这是为什么?怎么修?
现在,让我们看一个示例
Flight模型,我们将使用它从我们的flights数据库表中检索和存储信息
所以我写道:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Media extends Model
{
//
}
Run Code Online (Sandbox Code Playgroud)
和控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Media;
class MediaController extends Controller
{
public function index() {
return view('medias.index')->with('medias', Media::all());
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我查询时MediaController@index,它给出了这个错误:
QueryException in Connection.php line 729:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myapp.media' doesn't exist (SQL: select * from `media`)
Run Code Online (Sandbox Code Playgroud)
它需要一个命名的表,media而不是medias像文档所说的那样。那么为什么会发生这种错误呢?我是否不小心打开了选项标志,它更改了从模型到表的默认名称映射或类似的东西?
任何建议将不胜感激。
环境:
这是我自己实现的堆(用于算法竞赛).有一些我无法从中恢复的编译错误......
\Map_Heap.cpp|13|error: invalid use of non-static data member 'MapHeap<DT>::nv'|
\Map_Heap.cpp|19|error: from this location|
Run Code Online (Sandbox Code Playgroud)
码:
#include<cstdio>
#include<cstring>
const int HEAP_SIZE=10005;
template<class DT>
struct MapHeap
{
DT f[HEAP_SIZE+5];
int mp1[HEAP_SIZE+5];//val -> index
int mp2[HEAP_SIZE+5];//index -> val
int nv;///line 13
MapHeap():nv(0)
{
memset(mp1,-1,sizeof(mp1));
memset(mp2,-1,sizeof(mp2));
}
void print(int n=nv)//line 19
{
for(int i=1;i<=n;i++) printf("%d ",f[i]);
puts("");
for(int i=1;i<=n;i++) printf("%d ",mp1[i]);
puts("");
for(int i=1;i<=n;i++) printf("%d ",mp2[i]);
puts("");
}
};
Run Code Online (Sandbox Code Playgroud) 可能重复:
C:数组的地址如何等于它的值?
我在GCC 4.4.1中测试,我发现&a=a.我无法理解.我认为&a应该是存储数组地址的地址,它不能相同.有人能给我一个很好的解释吗?非常感谢.
我正在学习Java中的反射,我写了一些测试代码:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Test {
class Base {
public Base() {}
public void print(){
System.out.println("base");
}
}
class Derived extends Base {
@Override
public void print() {
System.out.println("derived");
}
}
public static void main(String args[])
{
try {
Class.forName(Derived.class
.getTypeName())
.getSuperclass()
.getMethod("print", new Class[0])
.invoke(Base.class.newInstance());// line 41
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) { …Run Code Online (Sandbox Code Playgroud) var a = 2;
function f(a) {return a;}
console.log(f(1));// return 1
console.log(f());// return undefined, but I want to make it return 2...
Run Code Online (Sandbox Code Playgroud)
f()返回undefined,但我想a在全局范围内引用变量.我怎么能实现这一目标?
C++代码:
#include <string>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/time.h>
using namespace std;
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
int main() {
timeval tv1, tv2, tv3, tve;
gettimeofday(&tv1, 0);
int size = 0x1000000;
int fd = open("data", O_RDWR | O_CREAT | O_TRUNC, FILE_MODE);
ftruncate(fd, size);
char *data = (char *) mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
for(int i = 0; i < size; i++) {
data[i] = 'S';
}
munmap(data, size);
close(fd);
gettimeofday(&tv2, 0); …Run Code Online (Sandbox Code Playgroud) 单击跨度后,将添加或删除虚线边框.添加或删除边框后,您可以看到它们移动一点.我只想让他们保持沉默.
我的代码:
var border_style = "2px dotted RED"
document.querySelectorAll('span').forEach(function (node) {
node.addEventListener('click', function (e) {
if (e.target.style.border != "") {
e.target.style.border = ""
} else {
e.target.style.border = border_style
}
})
})Run Code Online (Sandbox Code Playgroud)
<span id="a">
span a
</span>
<span id="b">
span b
</span>Run Code Online (Sandbox Code Playgroud)
那么,如何在添加和删除边框时保持两个跨度?
例A:
class F {
private $f = null;
}
Run Code Online (Sandbox Code Playgroud)
例B:
class F {
private $f;
}
Run Code Online (Sandbox Code Playgroud)
这两个班级之间有什么不同?