我想生成大数据样本(差不多100万条记录)来研究postgresql中的tuplesort.c的多相合并,我希望模式如下:
CREATE TABLE Departments (code VARCHAR(4), UNIQUE (code));
CREATE TABLE Towns (
id SERIAL UNIQUE NOT NULL,
code VARCHAR(10) NOT NULL, -- not unique
article TEXT,
name TEXT NOT NULL, -- not unique
department VARCHAR(4) NOT NULL REFERENCES Departments (code),
UNIQUE (code, department)
);
Run Code Online (Sandbox Code Playgroud)
如何使用generate_series和随机来做呢?非常感谢!
我不喜欢DrRacket,因为它没有像Emacs那样方便的编辑功能,但是我只能通过添加命令"racket current-file.scm" .emacs来运行Scheme文件,现在,我想在Emacs中运行Scheme文件描述为"运行:重置交互窗口并在定义窗口中运行程序." 在DrRacket的手册中,我读到了Racket的帮助" 19.1运行球拍和球拍 ",似乎它没有回答我的问题,我该怎么办?
所有读完Scala协方差/逆变问题及其答案由Daniel Spiewak提供,以及"Scala编程"一书的第19.3-19.7节,我对Function1 [-A,+ B]的定义有另一种疑惑:为什么它的第一种类型参数是逆变的吗?我有一个原因,就是这种类型参数保证了当有多种情况时,子类型总是比超类型更早出现,同时,子类型"是一种"超类型.例如:
class A
class B extends A
class C extends B
scala> val withDefault: A => B = {
| case x:B => new B
| case x:A => new B }
withDefault: A => B = <function1>
Run Code Online (Sandbox Code Playgroud)
这里,(1)case x:B早于case x:A,(2)功能1 [A,B] <:功能1 [B,B]并且必须有其他原因?任何消息将不胜感激!
当我运行烧瓶0.9时,我得到了日志记录:
127.0.0.1 - - [30/Mar/2016 10:08:38] "GET / HTTP/1.1" 200 -
Run Code Online (Sandbox Code Playgroud)
我应该怎么做,除去- -之间127.0.0.1和[30/Mar/2006 10:08:38]?
如果我想200从日志消息中删除响应代码,我该怎么办?
任何建议将被认真考虑!
正如@alecxe建议的那样,我列出了我的代码段相对日志记录:
logging.basicConfig(filename='werkzeug.log', level=logging.INFO)
logger = logging.getLogger('werkzeug')
logger.setLevel(logging.INFO)
Run Code Online (Sandbox Code Playgroud) (let ([x (call/cc (lambda (k) k))])
(x (lambda (ignore) "hi"))) => "hi"
Run Code Online (Sandbox Code Playgroud)
如何编写此延续的执行步骤?
我正在学习PLAI,现在我已经在DrRacket(带#lang plai)中运行了第3章的代码,但我是DrRacket的新手.我可以仅在Emacs中编辑和运行代码吗?
在Haskell/Understanding monads/State中有一个代码片段:
type GeneratorState = State StdGen
rollDie :: GeneratorState Int
rollDie = do generator <- get
let (value, newGenerator) = randomR (1,6) generator
put newGenerator
return value
Run Code Online (Sandbox Code Playgroud)
关于<-上面第三行中的符号,有一个解释:
我们<-与get一起取出伪随机生成器.获得覆盖一元值(a中m a)与状态,结合发电机的状态.(如果有疑问,请回忆一下get和>>=above 的定义).
我不明白:(1)generator对应于定义的第一个类型参数State?(2)为什么generator只是两个参数中的一个State,而不是两个?当然,从上下文来看,答案是显而易见的,但我不知道具体的规则<-.
据我所知,在评估时evalState rollDie (mkStdGen 600),get将被替换为State (mkStdGen 0) (mkStdGen 0),并且,根据RWH的描述" <-拉出monad的东西",这里的东西不是(mkStdGen 0) (mkStdGen 0)?
在themes.rb中,包含以下代码%@ @:
%@
$has_bg_image: #{theme.has_bg_image?};
$bg_color: ##{theme.bg_color};
$fg_color: ##{theme.fg_color};
$bg_image_url: '/_files/themes/bg_image/#{theme.group_id}/# {theme.id}/#{theme.version}.png';
$topbar_color: ##{theme.topbar_color};
$logo_url: '/_files/groups/logo/#{theme.group_id}/# {theme.version}.png';
$view_bg_color: ##{theme.view_bg_color};
$brand_color: ##{theme.brand_color};
$fluid: #{theme.fluid};
$bg_shadow: #999;
@
Run Code Online (Sandbox Code Playgroud)
我能找到哪些关于语法的参考?我不知道这是尴尬如何搜索特殊字符,例如%@在google和SO!
(define self-add
(let ((x 0))
(lambda ()
(set! x (+ x 1))
x)))
Run Code Online (Sandbox Code Playgroud)(自我添加)=> 1
(自我添加)=> 2
(自我添加)=> 3
(自我添加)=> 4
(define self-add1
(lambda ()
(let ((x 0))
(set! x (+ x 1))
x)))
Run Code Online (Sandbox Code Playgroud)
(self-add1)=> 1
(self-add1)=> 1
(self-add1)=> 1
请告诉我如何理解上述两个功能之间的区别?非常感谢提前!最好的祝福.
当我使用$.ajax()以下respond_to块提交表单内容时:
respond_to do
render :json => { :url => question_path(resource, :recent => :true),
:uploadPath => question_path(@question, :format => "json"),
:editPath => edit_question_path(@question),
:exitPath => question_path(resource)
}
end
Run Code Online (Sandbox Code Playgroud)
我有一个错误:
Completed 406 Not Acceptable in 124690.7ms (Views: 0.4ms | ActiveRecord: 16.7ms | Sphinx: 0.0ms)
Run Code Online (Sandbox Code Playgroud)
删除后respond_to,由于上面的代码改为:
render :json => { :url => question_path(resource, :recent => :true),
:uploadPath => question_path(@question, :format => "json"),
:editPath => edit_question_path(@question),
:exitPath => question_path(resource)
}
Run Code Online (Sandbox Code Playgroud)
错误消失了,为什么会发生这种情况?我想念什么东西?谢谢!
在Real World Haskell(Monads)的第14章中,inject函数的类型签名return是return :: a -> m a,其中m a是一个类型构造函数,因此在ghci下我可以为a指定类型签名return arg1,例如:
*Main> return 1 :: Maybe Integer
Just 1
*Main> return "ok" :: Maybe String
Just "ok"
Run Code Online (Sandbox Code Playgroud)
因为Nothing是类型的值Maybe a,Nothing"S型Maybe Integer或Maybe String,所以我想我可以指定如下类型:
*Main> return Nothing :: Maybe String
Run Code Online (Sandbox Code Playgroud)
但是我收到了一个错误:
Couldn't match type `Maybe a0' with `[Char]'
Expected type: String
Actual type: Maybe a0
In the first argument of `return', namely `Nothing'
In …Run Code Online (Sandbox Code Playgroud)