我无法通过教程找到如何启用部署模式.它说要做:
WAGlobalConfiguration
setDeploymentMode
这是不被承认的,
或做:
Initialize
| app |
app := self registerAsApplication: 'app-name'.
app preferenceAt: #deploymentMode put: true
Run Code Online (Sandbox Code Playgroud)
执行,但不删除工具栏.
我根本无法解决这个问题:
renderContentOn: html
html form: [
html textInput
on: #newEmp of: self.
html submitButton
callback: [ self addEmployee: newEmp ];
text: 'Add Employee'.
self employeeNames do: [ :eachEmp | html text: Character cr asString. html text: eachEmp.]
]
Run Code Online (Sandbox Code Playgroud)
我只是继续将输出放在一行上.我错过了什么吗?我尝试了几种变体cr
但到目前为止还没有.
是否有一个词典等价物将接受字母数字作为关键?花了一些时间在这里让你们帮助分配UUID值,我现在意识到Dictionaries只采用整数.我曾计划使用UUID作为密钥.
我的设计是为总帐 - 我的分类帐成员初始化为ledger := Dictionary new
,我希望做的事情符合以下方面:
postTransaction: GLEntry
ledger at: GLEntry UID put: GLEntry
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个允许多个客户端连接和播放的游戏 - 下面是相关代码(它非常混乱 - 稍后清理):
编辑:我意识到这是很多滚动...在游戏结束时发生崩溃:
std::cout << black_hits << " black hits & " << white_hits
<< " white hits.\n";
if (black_hits == 4) {
std::cout << "you won!\n";
std::cin.ignore().get();
close(client); //<<<< CRASH HERE
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我猜不是真的崩溃......但足够接近:)
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <string>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>
#define BACKLOG …
Run Code Online (Sandbox Code Playgroud) 我这样做:
sub worker {
my ($job, @action) = @$_; #<-- error thrown here
Build($job, @action[0]);
}
for (1..NUM_WORKERS) {
async {
while (defined(my $job = $q->dequeue())) {
worker($job);
}
};
}
$q->enqueue([$_, 'clean']) for @compsCopy;
# When you're done adding to the queue.
$q->end();
$_->join() for threads->list();
Run Code Online (Sandbox Code Playgroud)
当这执行时,我得到:
线程8异常终止:使用"严格引用"时,不能使用字符串("8")作为ARRAY引用(@上面引用的行)
我在这做错了什么?
编辑:为了更深入地了解我想要完成的任务,我希望能够做到这样的事情:
$q->enqueue([$_, 'clean']) for @compsCopy; #clean
$q->enqueue([$_, 'l1']) for @compsCopy; #build
$q->enqueue([$_, '']) for @compsCopy; #link
Run Code Online (Sandbox Code Playgroud)
用户可以指定何时运行脚本,以及$action
他们想要在组件(目录)上执行哪些操作.
在YouTube的一次讲座中,一位教授说Markov Chains可以简化为Start(S) * Transition Matrix(Q)^State#
我试图用numpy来复制它.
import numpy as np
S = np.zeros(shape=(1,2))
Q = np.zeros(shape=(2,2))
#starting state
S[0] = [.2,.8]
#transition matrix
Q[0] = [.9, .1]
Q[1] = [.7, .3]
Run Code Online (Sandbox Code Playgroud)
如果我这样做print S.dot(Q).dot(Q)
,它给了我[[0.848 0.152]]
似乎是正确的答案(未来的两个步骤).
然而,这看起来并不完全相同SQ^x
,所以我试过print S.dot(np.power(Q,2))
,但这给了我[[0.554 0.074]]
.我哪里出错了,或者我在这里不懂什么?
有人可以解释为什么这不符合我的预期吗?
add: rhsKey
myUnits includesKey: rhsKey
ifTrue: myUnits put: (myUnits at: rhsKey) + 1 at: rhsKey
ifFalse: myUnits add: rhsKey -> 1.
Run Code Online (Sandbox Code Playgroud)
执行示例:
ut:= UnitTracker命名:'test'.
添加:'秒'.
添加:'秒'.
添加:'秒'.
添加:'分钟'.
它在第一轮中继续通过ifTrue执行.
是否有可能在smalltalk中覆盖+运算符以接受两个参数?即,我还需要传递我的自定义类的单位.就像是:
Number subclass: #NumberWithUnits
instanceVariableNames: 'myName unitTracker'
classVariableNames: ''
poolDictionaries: ''
category: 'hw3'
+ aNumber theUnits
unitTracker adjustUnits: theUnits.
^super + aNumber
Run Code Online (Sandbox Code Playgroud)
还是有一种更简单的方法可以做到这一点,我没有考虑过?
其他问题描述:
(NumberWithUnits值:3个单位:#seconds)应该给你一个代表3秒的NumberWithUnits.但是你也应该写3秒,并且应该评估为NumberWithUnits(已经在Pharo 2.0中采用了几秒).这样做的方法是向Number添加一个sec方法,它基本上返回(NumberWithUnits值:self unit:#seconds).您也可以添加米和大象的方法.然后你可以写一个表达3大象/(1秒秒),它会返回正确的东西.为它写一个测试,以确保它!
是否有一个内置程序可以让您获取您所在主机的主机名(不包括变量)inventory_hostname
?我想做的是在多个主机上执行播放,但它们必须在每个主机上手动运行(安全策略,不用担心)。但是,作为此过程的一部分,我们使用需要本地主机的实际主机名的模板变量。是否有可能用除 之外的其他东西来获取它inventory_hostname
,因为我认为它会返回localhost
?
是否有一种简单的方法可以在不过度循环的情况下执行以下操作?
myArray = [["a","b"],["c","d"],["e","f"]]
if myArray.includes?("c")
...
Run Code Online (Sandbox Code Playgroud)
我知道这很好,如果它只是一个正常的字符数组...但我想要一些同样优雅的数组的字符数组(帮助将其转换为元组数组的奖励点).