以下函数nested_arrays
(令人惊讶地)生成"深度"的嵌套数组n
.但是,当运行甚至很小的n
(2
,3
等等)时,运行和显示输出需要相当长的时间.
julia> nested_arrays(n) = n == 1 ? [1] : [nested_arrays(n - 1)]
nested_arrays (generic function with 1 method)
julia> nested_arrays(1)
1-element Array{Int64,1}:
1
julia> nested_arrays(2)
1-element Array{Array{Int64,1},1}:
[1]
julia> nested_arrays(3)
1-element Array{Array{Array{Int64,1},1},1}:
Array{Int64,1}[[1]]
julia> nested_arrays(10)
1-element Array{Array{Array{Array{Array{Array{Array{Array{Array{Array{Int64,1},1},1},1},1},1},1},1},1},1}:
Array{Array{Array{Array{Array{Array{Array{Array{Int64,1},1},1},1},1},1},1},1}[Array{Array{Array{Array{Array{Array{Array{Int64,1},1},1},1},1},1},1}[Array{Array{Array{Array{Array{Array{Int64,1},1},1},1},1},1}[Array{Array{Array{Array{Array{Int64,1},1},1},1},1}[Array{Array{Array{Array{Int64,1},1},1},1}[Array{Array{Array{Int64,1},1},1}[Array{Array{Int64,1},1}[Array{Int64,1}[[1]]]]]]]]]
Run Code Online (Sandbox Code Playgroud)
有趣的是,当使用@time
宏或;
在行的末尾时,结果花费的时间相对较少.相反,在REPL中实际显示结果占用了大部分时间.
这种奇怪的行为没有在例如Python中显示.
In [1]: def nested_lists(n):
...: if n == 1:
...: return [1]
...: return [nested_lists(n - 1)]
...:
In [2]: nested_lists(10)
Out[2]: [[[[[[[[[[1]]]]]]]]]] …
Run Code Online (Sandbox Code Playgroud) 我正在使用JSONAPI规范http://jsonapi.org/format/#status
我有以下数据,
{
"data":
{
"type": "tag",
"id": "1",
"attributes": {
"name": "Test"
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用postman chrome扩展程序向终点发送帖子请求?
我正打算打电话,但我无法得到参数.
OBS.我已将Content-Type设置为application/vnd.api+json
谢谢 !
我需要这样的东西:
<tr>
somecode...
</tr *ngIf="some condition">
Run Code Online (Sandbox Code Playgroud)
这当然不受支持,但有没有办法实现这种行为?
我有一个表,我希望使用一个接收节点列表(List)的组件递归地添加行,迭代节点,打印它们并为每个节点的每个子节点调用自己大致如下:
main.component.html
<table class="table table-bordered">
<thead>
<tr>
<th>node names</th>
</tr>
</thead>
<tbody>
<tr app-rower [nodes]="nodes"></tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
rower.component.html:
<ng-container *ngFor="let node of tree">
<tr>
<td>
{{node.name}}
</td>
</tr *ngIf="node.hasChildren">
<tr *ngIf="node.hasChildren" app-rower [tree]="node.children" >
</tr *ngIf="!node.hasChildren">
</ng-container>
Run Code Online (Sandbox Code Playgroud)
所以最终的HTML将是:
<table>
<thead>
<tr>
<th>node's names</th>
</tr>
</thead>
<tbody>
<tr>
<td>node 1</td>
</tr>
<tr>
<td>node 1's child</td>
</tr>
<tr>
<td>node 1's grandchild</td>
</tr>
<tr>
<td>node 2</td>
</tr>
<tr>
<td>node 2's child</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
使用react-router(V4)有两种"主要"方式; 第一种方法是使用哈希路由器,您可以通过在浏览器的地址栏上键入它来直接访问地址,但是您必须添加#到URL,另一种方法是使用BrowserRouter,它具有漂亮且用户友好的URL结构但是你不能直接键入地址以呈现路线.那么,我如何配置HashRouter无需#或配置BrowserRouter即可直接使用URL输入?是否可以使用.htaccess?怎么样?谢谢.
const React = require('react');
const ReactDOM = require('react-dom');
import { HashRouter as Router, Route, Link} from 'react-router-dom';
const routes = (
<Router forceRefresh={false}>
<div>
<Route exact path="/" component={Firstpage}/>
<Route exact path="/projects" component={Projectslist}/>
</div>
</Router>
);
ReactDOM.render(routes, document.getElementById('app'));
Run Code Online (Sandbox Code Playgroud)
[在这种类型中,它与#mark一起使用.例如:localhost:2000 /#/ projects]
另一种类型:
const React = require('react');
const ReactDOM = require('react-dom');
import { BrowserRouter as Router, Route, Link} from 'react-router-dom';
const routes = (
<Router forceRefresh={true}>
<div>
<Route exact path="/" component={Firstpage}/>
<Route exact path="/projects" component={Projectslist}/>
</div>
</Router>
);
ReactDOM.render(routes, document.getElementById('app')); …
Run Code Online (Sandbox Code Playgroud) 我想知道是否可以从vue的数据集中访问变量,但是只能通过另一个变量指定变量名。这就是我的意思:
我的一些变量/属性:
var siteAdminVue = new Vue({
el: "#siteAdmin",
data: {
tagtitle: "",
tagparent: "",
tagdesc: "",
badgestitle: "",
badgesdesc: "",
badgesprivilege: 0,
newstitle: "",
newsnotify: false,
newscontent: "",
}
Run Code Online (Sandbox Code Playgroud)
现在,我想在vue中的一种方法中设置其中一些属性:
var self = this;
var type = currentSection.toString().substr(4);
var selectElement = document.getElementById(currentSection + "select");
// name of vue property, for example newstitle
var titleElement = type + "title";
self.[titleElement]= selectElement.value;
Run Code Online (Sandbox Code Playgroud)
我不想使用switch语句来检查是否需要设置新闻标题,徽章标题等,因此我想我可以将名称存储在已经在vue中定义的变量中,然后进行设置。有没有办法做到这一点?
提前致谢
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
Public class Event{
private int Id;
private String name;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@AllArgsConstructor
Public class EventResponse{
private List<Event> eventList;
}
Run Code Online (Sandbox Code Playgroud)
作为回应,我正在发送事件列表。我正在使用spring-boot。如果Cassandra中没有ID为ID的数据,则返回null。我得到的回应是
"eventList": [
{
"event": {
"id": 1234,
"name": "Halus"
}
},
{}
]
Run Code Online (Sandbox Code Playgroud)
但我期望
"eventList": [
{
"event": {
"id": 1234,
"name": "Halus"
}
}
]
Run Code Online (Sandbox Code Playgroud) 这段代码
soundPool.release();
soundPool = null;
Run Code Online (Sandbox Code Playgroud)
有时会产生此错误:
Uncaught exception thrown by finalizer
java.lang.IllegalStateException: Binder has been finalized!
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at com.android.internal.app.IAppOpsService$Stub$Proxy.stopWatchingMode(IAppOpsService.java:431)
at android.media.SoundPool.release(SoundPool.java:195)
at android.media.SoundPool.finalize(SoundPool.java:204)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:217)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:200)
at java.lang.Thread.run(Thread.java:818)
Run Code Online (Sandbox Code Playgroud)
我能做什么?
我需要输出如下值:
"API Docs Portal : op-api-docs"
"Big Ideas : op-bigideas"
"Education : op-education"
....
Run Code Online (Sandbox Code Playgroud)
我尝试了一些东西,但它没有按预期工作......
for (var x = 1; x <= reportValue.GetLength(0); x++)
{
for (var y = 1; y <= reportValue.GetLength(1); y++)
{
if (reportValue[x, y] != null)
{
var id = reportValue[x, y];
var name = reportValue[x, y + 1];
var result = name + " : " + id;
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意:
这是我获取reportValue
数组的方式(使用C#Interop):
var reportLast = ws.Range["A" + ws.Rows.Count].End(Excel.XlDirection.xlUp).Row;
var rngReport = …
Run Code Online (Sandbox Code Playgroud) 如何在java中编写代码,以便在遵循IF条件时为真:
if (!online.equals(offline)){
}
Run Code Online (Sandbox Code Playgroud)
然后只有
a1.setOnClickListener(new View.OnClickListener() {
**algorithm**
}
Run Code Online (Sandbox Code Playgroud)
被激活,否则按钮保持不可点击状态.
注意:"在线"和"离线"都是字符串变量.