我对Elm进行排序时使用了什么排序算法List?
> sort [1,3,5,6]
[1,3,5,6] : [comparable]
Run Code Online (Sandbox Code Playgroud)
什么[comparable]类型以及如何找回number?
> [1,2]:: (sort [3,2,1])
[1 of 1] Compiling Repl ( repl-temp-000.elm )
Type error on line 4, column 3 to 24:
[1,2] :: (sort [3,2,1])
Expected Type: [number]
Actual Type: comparable
Run Code Online (Sandbox Code Playgroud)
这可能是了解List榆树如何实施的好时机,但我现在不想过于深入.只是让它运行起来.
我有一个返回数据的网址text/event-stream,因此我尝试连接并打印我找到的所有内容:
var url = "..."
var source = new EventSource(url);
source.addEventListener('message', function(e) {
console.log(e.data);
}, false);
source.addEventListener('open', function(e) { }, false);
source.addEventListener('error', function(e) {
if (e.readyState == EventSource.CLOSED) { }
}, false);
Run Code Online (Sandbox Code Playgroud)
不幸的是这在服务器端不起作用。我可以这样连接吗?
$ node app.js
app.js:2
var source = new EventSource(url);
^
ReferenceError: EventSource is not defined
at Object.<anonymous> (app.js:2:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Run Code Online (Sandbox Code Playgroud) 我试图从github gist(美国地图)重现这个例子https://gist.github.com/4431123我复制到我的主目录 所需的文件" us.json ".
此网站上已经出现了类似的问题.
<!-- language: lang-html -->
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: none;
stroke: steelblue;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<script>
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("us.json", function(error, us) {
svg.append("path")
.attr("d", topojson.object(us, us.objects.counties).geometries.map(function(d) {
var bounds = path.bounds(d);
return "M" + bounds[0]
+ "H" + bounds[1][0]
+ "V" + bounds[1][3]
+ "H" + …Run Code Online (Sandbox Code Playgroud) 这是我第一次使用make.我正在尝试安装Julia语言.所以我从GitHub克隆
git clone git://github.com/JuliaLang/julia.git
Run Code Online (Sandbox Code Playgroud)
然后说明说明输入Julia目录并输入make.它跑了很长时间 - 我吃披萨.
当我回来时,打字Julia不起作用.在安装结束时,我收到一条很长的错误消息:
/usr/bin/install -c -m 644 libpcre.pc libpcreposix.pc libpcrecpp.pc '/home/john/Downloads/julia/usr/lib/pkgconfig'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 130 100 130 0 0 243 0 --:--:-- --:--:-- --:--:-- 337
0 0 0 8773k 0 0 310k 0 --:--:-- 0:00:28 --:--:-- 0
curl: (28) Operation too slow. Less than 1 bytes/sec transferred the last 15 seconds …Run Code Online (Sandbox Code Playgroud) 我有两个数组,x = np.arange(3) = [0,1,2,3]和y = np.arange(4) = [0,1,2].
是否有一个numpy函数,提供了所有产品的表格?或者例如,这将是:
x*y = [[0,0,0,0], [0,1,2,3], [0,2,4,6]]
Run Code Online (Sandbox Code Playgroud)
这不是内部产品或标量产品.这可以称为"张量产品"或其他东西.
我正在尝试自定义绘制二维中随机点的Voronoi区域
import matplotlib.pyplot as plt
%matplotlib inline
from scipy.spatial import Voronoi
pt = np.random.random((10,2))
x = sp.spatial.Voronoi(pt)
# trial an error to figure out the type structure of [x]
plt.plot(x.vertices[:,0], x.vertices[:,1], '.', markersize=5)
# how to iterate through the x.regions object?
for poly in x.regions:
z = np.array([ x.vertices[k] for k in poly])
print z
if z.shape[0] > 0:
plt.plot( z[:,0], z[:,1])
plt.xlim([0,2])
plt.ylim([0,2])
Run Code Online (Sandbox Code Playgroud)
为什么区域重叠?绘制无限区域的任何建议?
数据点只是随机数:
x.vertices
array([[ 0.59851675, 0.15271572],
[ 0.24473753, 0.70398382],
[ 0.10135325, 0.34601724],
[ 0.42672008, …Run Code Online (Sandbox Code Playgroud) 我正在弄乱榆树,我得到了这个错误信息:
[1 of 1] Compiling Main ( Main.elm )
Parse error at (line 3, column 1):
unexpected '\t'
expecting newline, spaces or end of input
Run Code Online (Sandbox Code Playgroud)
标签在Elm中是否具有特殊含义,因为它们可能在Python中?
例如http://share-elm.com/sprout/53d1a38ae4b07afa6f98344d
main : Element
main = flow down
[ leftAligned (toText "A")
, leftAligned (toText "B")
, leftAligned (toText "C")
]
Run Code Online (Sandbox Code Playgroud) 我正在使用的项目没有 Stackage 上的文档(它们已经过时了)。这是 0.3 版的原始版本
https://hackage.haskell.org/package/reflex-dom-0.3/docs/Reflex-Dom-Widget-Basic.html
有人告诉我可以用 haddock 生成文档。我的电脑上有源代码(使用git clone)版本0.4
黑线鳕网页太先进了。
对于初学者来说,一旦进入我的目录,如何生成文档?
感谢我取得的答案之一,取得了进展,但这里有一条错误消息:
src/Reflex/Dom/Xhr.hs:154:0:
error: missing binary operator before token "("
#if MIN_VERSION_aeson(1,0,0)
^
Run Code Online (Sandbox Code Playgroud) 我在Hartl的Rails教程第2章的末尾,该应用程序在本地运行,但我无法部署它.
http://quiet-ocean-3277.herokuapp.com/
$ git push heroku master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 253 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Using rake (10.1.0)
Using i18n (0.6.4)
Using minitest (4.7.5)
Using multi_json (1.7.7)
Using atomic …Run Code Online (Sandbox Code Playgroud)