我创建了一个字典使用两种阵列zip()状
list1 = [1,2,3,4,5]
list2 = [6,7,8,9,19]
dictionary1 = Dict(zip(list1,list2))
Run Code Online (Sandbox Code Playgroud)
现在我想按key(list1)或通过这个词典排序list2.有人可以告诉我一个方法或功能,如何实现它?
假设输入参数是几个文件的FULL路径.说,
/abc/def/file1
/abc/def/ghi/file2
/abc/def/ghi/file3
Run Code Online (Sandbox Code Playgroud)
/abc/def在bash shell脚本中获取目录名?file1,/ghi/file2和/ghi/file3?我想将一个加载的JSON对象存储在一个变量中.通常我应该做的事情如下:
d3.json("jsondatafile.json", function(json){ DO SOMETHING; });
Run Code Online (Sandbox Code Playgroud)
但是,相反,我想要的东西:
var jsonData = d3.json("jsondatafile.json");
Run Code Online (Sandbox Code Playgroud)
我想jsonData在d3.json函数外部访问.我怎样才能做到这一点?
有一个数组[1, 2, ..., m],有一个整数n.
如果m=2和n=3,我想获得
[1, 1, 1]
[1, 1, 2]
[1, 2, 1]
[1, 2, 2]
[2, 1, 1]
[2, 1, 2]
[2, 2, 1]
[2, 2, 2]
Run Code Online (Sandbox Code Playgroud)
就像我一样
for i=1:m
for j=1:m
for k=1:m
\\ get [i, j, k]
end
end
end
Run Code Online (Sandbox Code Playgroud)
但是,无论是m和n是变量.我怎样才能做到这一点?我正在使用Julia,但任何一般建议都没问题.
是否可以kramdown在 jekyll的引擎中使用方程数?之前的引擎似乎maruku支持方程编号。我想使用 MathJax 支持的方程编号和交叉引用。
我试过了
$$
\begin{equation}
a + b = c \label{abc}
\end{equation}
$$
Equation \eqref{abc} is ...
Run Code Online (Sandbox Code Playgroud)
我获得了:
出于某种原因,我不得不将quote...end块放在宏中并ex以编程方式生成。此代码有效。
macro addsum_out()
quote
ex = :(x+y)
sum(eval(ex))
end
end
x = [1 1 1]
y = [2 2 2]
z2 = @addsum_out
Run Code Online (Sandbox Code Playgroud)
当宏被放入模块时,它不再起作用:
module MyModule
export @addsum
macro addsum()
quote
ex = :(x+y)
sum(eval(ex))
end
end
end
using MyModule
x = [1 1 1]
y = [2 2 2]
z = @addsum
Run Code Online (Sandbox Code Playgroud)
它说:
ERROR: LoadError: UndefVarError: x not defined
Run Code Online (Sandbox Code Playgroud)
我想我应该把它放在esc某个地方,以评估ex模块外主作用域中的表达式。我应该怎么处理这个?
我想创建一个矩阵
[1 2;
1 3;
1 4;
1 5;
2 3;
2 4;
2 5;
3 4;
3 5;
4 5 ]
Run Code Online (Sandbox Code Playgroud)
当大小为5.我的目标是大小超过100.如何在MATLAB中使用vertorization创建这样的矩阵?
在朱莉娅,当我想要打印宽度为10的数字"4"时,我会:
@printf("%10d", 4)
Run Code Online (Sandbox Code Playgroud)
如果我想将宽度设置为特定字符串的长度,例如:
mystr = "Hello World"
Run Code Online (Sandbox Code Playgroud)
如何将"%10d"中的10改为length(mystr)?
对于MATLAB图,我有类似的东西:
figure; hold on;
line ( [1 2], [3 4] );
line ( [5 6], [7 8] );
plot(x1,y1,'r.');
plot(x2,y2,'b.');
Run Code Online (Sandbox Code Playgroud)
其中x1,y1,x2,y2都是向量.
如何legend仅添加最后两个图,而不是两个图?
我喜欢在每个坐标中画一个圆圈.只使用width,height以及coordinates,如何调整坐标?我对D3.js很新,我猜我在投影部分做错了.
var width = 200,
height = 200;
var svg = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height);
var coordinates = [ [43.08803611,-79.06312222],
[43.09453889,-79.05636667] ];
var group = svg.append('g');
var projection = d3.geo.mercator()
.translate([width,height]);
var projectedCoordinates = [];
for (var i=0; i<coordinates.length; i++) {
projectedCoordinates[i] = projection(coordinates[i]);
}
group.selectAll("circle")
.data(projectedCoordinates)
.enter()
.append("circle")
.attr("r",4)
.attr("cx", function(d){ return d[0]; })
.attr("cy", function(d){ return d[1]; });
Run Code Online (Sandbox Code Playgroud) 我的本地机器上有一个四核CPU.如果我运行julia的
julia -p 4
Run Code Online (Sandbox Code Playgroud)
并运行一个带并行计算的脚本,我的理解是:
它是否正确?
另外,如果我的进程多于核心数,会发生什么?例如
julia -p 8
Run Code Online (Sandbox Code Playgroud)
它是否像以下那样?
当我在数组中有许多元素时,Julia REPL仅显示其中的一部分。例如:
julia> x = rand(100,2);
julia> x
100×2 Array{Float64,2}:
0.277023 0.0826133
0.186201 0.76946
0.534247 0.777725
0.942698 0.0239694
0.498693 0.0285596
?
0.383858 0.959607
0.987775 0.20382
0.319679 0.69348
0.491127 0.976363
Run Code Online (Sandbox Code Playgroud)
有没有办法以上述垂直形式显示所有元素?print(x)或showall(x)将其以丑陋的形式显示而无需更改行。