启动了 2 个线程。dataListUpdateThread将数字 2 添加到 a List。processFlowThread将相同的值List相加并将总和列表打印到控制台。这是代码:
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.stream.javadsl.Sink;
import akka.stream.javadsl.Source;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import static java.lang.Thread.sleep;
public class SourceExample {
private final static ActorSystem system = ActorSystem.create("SourceExample");
private static void delayOneSecond() {
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private static void printValue(CompletableFuture<Integer> integerCompletableFuture) {
try {
System.out.println("Sum is " + integerCompletableFuture.get().intValue());
} catch (ExecutionException | InterruptedException …Run Code Online (Sandbox Code Playgroud) 当equals一个对象的覆盖方法可以obj在下面时null,如果是这样的情况是什么?
@Override
public boolean equals(Object obj) {
Run Code Online (Sandbox Code Playgroud) 阅读" http://doc.akka.io/docs/akka/snapshot/general/remoting.html ",它指出"通过网络发送的所有消息必须是可序列化的",这反过来要求发送给actor的所有消息都是可序列化的.为什么要求actor可序列化?
是否使用序列化和反序列化在actor之间发送消息?使用序列化发送/接收原因消息是可能的消息可以发送给驻留在不同JVM上的actor吗?
对于这个功能:
foo :: (b -> c) -> (a -> b) -> (a -> c)
取自http://www.seas.upenn.edu/~cis194/spring13/lectures/04-higher-order.html
这是一个没有实际用途的功能吗?由于(b -> c)无法构造除非类型C是该函数内的另一个输入参数?
同样适用于(a -> b) -> (a -> c):b&c不是这些功能的输入参数.
这个功能有用例吗?
--This is type safe
data IntList = Empty | Cons Int IntList
deriving Show
--This is type safe
data MyB b = EmptyB | ConsB b b
deriving Show
data MyC c = EmptyC | ConsC c MyC
deriving Show
Run Code Online (Sandbox Code Playgroud)
为什么抽象数据类型MyC不是类型安全的?该gaurd条款ConsC c MyC应构建缺点列表,因为它是invokding MyC以同样的方式,intList中从调用 Cons Int IntList的IntListADT?
我收到一个开头的json文件:'b\'{ "key" : ....我试图删除'b\'字符串的一部分,因为它不是有效的json.
使用以下方法读取json:
import urllib.request
link = "http://www...."
with urllib.request.urlopen(link) as url:
s = str(url.read())
Run Code Online (Sandbox Code Playgroud)
我要替换的代码是: replace('\'b\'', '')但字符串 'b\'{ "key" : ....仍然代替{ "key" : ....
尝试重新创建排除json字符串的问题:
mystr = ' b\'{ '
mystr.replace(' b\'{ ', '')
Run Code Online (Sandbox Code Playgroud)
成功替换' '输出.
阅读Python - 将一串数字转换为一个 int 列表我试图将字符串 '011101111111110' 转换为一个 int 数组:[0,1,1,1,0,1,1,1,1,1, 1,1,1,1,0]
这是我的代码:
mystr = '011101111111110'
list(map(int, mystr.split('')))
Run Code Online (Sandbox Code Playgroud)
但返回错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-54-9b0dca2f0819> in <module>()
1 mystr = '011101111111110'
----> 2 list(map(int, mystr.split('')))
ValueError: empty separator
Run Code Online (Sandbox Code Playgroud)
如何拆分具有空拆分分隔符的字符串并将结果转换为 int 数组?
下面评论的代码是我认为代码没有编译的原因,这是正确的吗?
class Building {
}
public class Barn extends Building{
public static void main(String args[]){
Building build1 = new Building();
Barn barn1 = new Barn();
Barn barn2 = (Barn)build1;
/**
* Object is not a Building
* Building is an Object
*/
Object obj1 = Object(build1);
/**
* String is not a Building
*/
String str1 = String(build1);
/**
* Building is not a Barn
* Barn is a Building
*/
Building build2 = Building(barn1);
}
}
Run Code Online (Sandbox Code Playgroud)
插入的评论是我自己的.为什么两个下选票,我只是没有意识到转换语法是不正确的.
我正在尝试使用名为myStyle的自定义样式设置href的样式:
<a href="http://www.google.com">Red Hover</a>
<a class="myStyle" href="http://www.google.com">Blue Hover</a>
.myStyle {
a:hover {
color: blue;
}
}
/* unvisited link */
a:link {
color: green;
}
/* visited link */
a:visited {
color: green;
}
/* mouse over link */
a:hover {
color: red;
}
/* selected link */
a:active {
color: yellow;
}
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/uzaG9/863/
所以Red Hover应该在悬停时更改为红色 - 这可以正常工作,但"蓝色悬停"在悬停时不会改变.
我正在尝试使用此样式来更改悬停:
.myStyle {
a:hover {
color: blue;
}
}
Run Code Online (Sandbox Code Playgroud)
但我不认为这种格式是正确的?如何将自定义样式应用于<a>标记?
使用下面的代码,我尝试将可变长度的数组转换为一个对象,其中位置 i 处的项目是对象名称,位置 i+1 处的项目是项目值。例如 :
arr = [];
arr.push('a');
arr.push(1);
arr.push('b');
arr.push(2);
arr.push('c');
arr.push(3);
/* Want to create an object that is of type : */
var ob = {a:1 , b:2 , c:3}
console.log(ob)
Run Code Online (Sandbox Code Playgroud)
这是我试图用来实现此目的的代码:
var ob2 = {}
for (var i = 0; i < arr.length; i++) {
ob2.arr[i] = arr[i + 1]
i = i + 1
}
Run Code Online (Sandbox Code Playgroud)
但收到错误:
(index):63 Uncaught TypeError: Cannot set property '0' of undefined
at window.onload ((index):63)
Run Code Online (Sandbox Code Playgroud)
小提琴: https: //jsfiddle.net/wxkkjzm0/
这是项目列表的数据结构,其中每个列表包含4个字符串列表,每个列表包含4个字符串列表:
List<List<List<String>>> l = new ArrayList<ArrayList<ArrayList<String>>>();
Run Code Online (Sandbox Code Playgroud)
是否有更"可读"的方式来定义此数据结构?
jsp文件期望这种结构显示数据.
java ×7
akka ×2
haskell ×2
python ×2
scala ×2
akka-stream ×1
css ×1
html ×1
javascript ×1
jquery ×1
json ×1
python-3.x ×1