我有一个String arraylist,我将把它转换为双arraylist.除了使用像for之类的循环之外,还有什么方法可以转换它吗?
ArrayList<String> S=new ArrayList<String>();
S=FillTheList();
ArrayList<Double> D=new ArrayList<Double>();
Run Code Online (Sandbox Code Playgroud) 这是F#中阶乘函数的简单实现
let rec fact =function
| 0->1
| n-> n * fact(n-1);;
fact 5
Run Code Online (Sandbox Code Playgroud)
1-这个rec词的作用是什么?
2-事实是功能,但从未提及它可以有一个参数.因此在技术上它应该面对错误,因为在signature(let rec fact)中没有为它定义参数.那它是如何运作的?
我有以下代码:
type Client =
{ Name : string; Income : int ; YearsInJob : int
UsesCreditCard : bool; CriminalRecord : bool }
type QueryInfo =
{ Title : string
Check : Client -> bool
Positive : Decision
Negative : Decision }
and Decision =
| Result of string
| Querys of QueryInfo
let tree =
Querys {Title = "More than €40k"
Check = (fun cl -> cl.Income > 40000)
Positive = moreThan40
Negative = lessThan40}
Run Code Online (Sandbox Code Playgroud)
但在最后一行:
Querys {Title = "More …Run Code Online (Sandbox Code Playgroud) 考虑F#中的以下代码
let rec ordered xs =
match xs with
| [] | [_] -> true
| x1 :: x2 :: xs' -> x1 <= x2 && ordered (x2 :: xs')
Run Code Online (Sandbox Code Playgroud)
然后
let rec insert x xs =
match xs with
| [] -> [x]
| y :: ys -> if x <= y then x :: y :: ys
else y :: insert x ys
Run Code Online (Sandbox Code Playgroud)
最后
let insertKeepsOrder (x : int) xs = ordered xs ==> ordered (insert x xs) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用它来制作一个可排序的表.我已按照说明进行操作,似乎已angular2-datatable/datatable正确安装.但是在运行时它抱怨说:
GET http://localhost:4200/angular2-datatable/datatable 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
它来自这条线:
import {DataTableDirectives} from 'angular2-datatable/datatable';
Run Code Online (Sandbox Code Playgroud)
但我检查了node_module包,我在angular2-datatable/datatable那里.所以似乎运行时的角度看起来是错误的路径.我该如何解决?
我从后端收到一个包含client对象数组的 json :这是客户端类:
export class Client {
private id:number;
private firstname: String;
private lastname: String;
private phone:String;
private address:String;
private country:String;
private Security_No:String;
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找最简单的方法将接收json到的Clients[]. 目前我将 json 存储在一个属性中,然后我去扔它并从中提取数据。但似乎,应该有更简单的方法?
populateClientData() {
this._httpClientService.getAllClients().subscribe((res)=>this.data=res.json()))
}
Run Code Online (Sandbox Code Playgroud) 我想利用TI dragula在我angular2应用程序.这是我的代码中的app.module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { DragulaService, DragulaModule } from 'ng2-dragula/ng2-dragula';
import { AppComponent } from './app.component';
import { PlayComponent } from './play/play.component';
import {SelectedInstrumentsService} from './selected-instruments.service';
import {SizeService} from './size.service';
import {AudioFinderService} from './audio-finder.service';
@NgModule({
declarations: [
AppComponent,
PlayComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,DragulaModule
],
providers: [DragulaService,SelectedInstrumentsService,SizeService,AudioFinderService],
bootstrap: [AppComponent]
})
export class AppModule { } …Run Code Online (Sandbox Code Playgroud) 我有一个简单的方法来检查*.mp3本地计算机中的文件是否存在。\n它应该返回 status响应的(200、404,403 等),但它不起作用。
fileExists(url){\n return this.http.get(url).timeout(2000)\n .map(res=>res.json())\n .subscribe(\n res=>{\n console.log("res is");\n console.log(res.status)\n return res.status;},\n err =>{ \n console.log("Error is");\n console.log(err.status); \n return err.status});\n\n }\nRun Code Online (Sandbox Code Playgroud)\n\n我为其设置了 2 秒的超时,但它只需要检查本地主机中的文件。因此,我认为,它有足够的时间来查找该文件。
\n\n它总是返回:
\n\nSubscriber {closed: false, syncErrorValue: null, syncErrorThrown: false, syncErrorThrowable: false, isStopped: false\xe2\x80\xa6}\nRun Code Online (Sandbox Code Playgroud)\n 我有一个非常简单的Maven项目来运行一些selenium测试。这是我的pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ignite</groupId>
<artifactId>selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>selenium</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
但它抱怨:
Multiple annotations found at this line:
- Failure to transfer xalan:xalan:jar:2.7.2 from https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original …Run Code Online (Sandbox Code Playgroud) 我需要在-1,1之间生成7个随机数,它们的总和等于1.我用这个代码来做.
diff(c(0, sort(round(runif(7,-1,1),2)), 1))
Run Code Online (Sandbox Code Playgroud)
但是我有一个很大的问题.
该代码的一个输出是-0.89,0.21,0.00,0.21,0.30,0.19,0.61,-0.63.
问题是它是统一的我猜这样每次都会在第一个和最后一个数字中生成大的随机数,这不是我想要的.我需要将它传播到所有数字.恩.0.22 -.21 .33 -.12 0.11 0.35 -0.08(总和不等于1只是一个例子)
你知道我可以写一个代码来获得这种随机数吗?