小编Min*_*510的帖子

Windows 10 Bash(Ubuntu 14.04) - 如何向上滚动?

我在我的W10笔记本电脑上安装了bash,但有一点非常令人沮丧的是我无法向上滚动.

有谁知道用鼠标滚轮滚动的方法?许多谷歌搜索后我找不到任何东西.

上下文:如果我编译一些C++文件并获得大量错误,我无法向上滚动以查看所有这些错误.

bash windows-10 windows-subsystem-for-linux

44
推荐指数
3
解决办法
2万
查看次数

是否可以合并两个集合,以便对这两个集合的所有引用都引用新的?

在Python中,假设我有两个集合A和B,以及对这两个集合的多个引用。

有没有一种方法可以合并两个集合A和B,使对这两个集合的所有引用都引用新合并的集合?如果可能,运行时将是什么?

A = {1,3}
B = {2,4}
aRef1 = A
aRef2 = A
bRef1 = B
bRef2 = B
MergeSets(A,B)
# Now, whenever I use any of (A, B, aRef1, aRef2, bRef1, bRef2) 
# they refer to the same set which will be {1,2,3,4} 
Run Code Online (Sandbox Code Playgroud)

谢谢

编辑:

有人一直在问我为什么要这样做,这是我的以下回复之一的副本/粘贴:

所以我知道我可以做A.update(B),将B合并为A,但是然后我必须遍历对B的所有引用,并将它们设置为引用A。我问这样可以避免这些额外的迭代。我可以提供更多上下文,以针对我的特定情况找到一种新方法,但是我很想知道在一般情况下python是否可行。

此外,似乎我的问题已得到回答,并且断定这是不可能的。再次感谢大家:)

python python-3.x

6
推荐指数
1
解决办法
144
查看次数

如何让 git 只存储我的用户名而不是我的密码?

我知道我可以使用 git config credential.helper 来存储我的用户名和密码。但我只想存储我的用户名,并让终端在每次推送时询问我的密码。这是怎么做的?

类似的东西,但没有密码。

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
Run Code Online (Sandbox Code Playgroud)

git

5
推荐指数
1
解决办法
405
查看次数

如何在不丢失数据的情况下迭代heapq?

在 Python 3 中,我像这样使用 heapq:

import heapq

heap = [3]
heapq.heapify(heap)
heapq.heappush(heap, 5)
# Push more values...

# I can iterate heap like so, but by the end it will be empty:
while (heap):
    curr = heapq.heappop(heap)
    # Do whatever with curr
Run Code Online (Sandbox Code Playgroud)

有没有办法迭代 heapq 以便我按排序顺序获取值而不会改变 heapq/丢失数据?

如果没有,我怎样才能有效地模仿所需的行为?

我想出的解决方案是创建一个临时堆,在我从原始堆中弹出时推送到它,一旦我完成迭代,将原始堆设置为等于临时堆。

当然这不是很有效,而且改变了原始堆引用的对象。

temp = []
heapq.heapify(temp)

while(heap):
    curr = heapq.heappop(heap)
    heapq.heappush(temp, curr)
    # Do whatever with curr
heap = temp
Run Code Online (Sandbox Code Playgroud)

python python-3.x heapq

2
推荐指数
1
解决办法
965
查看次数

如何在hacklang中迭代形状的字段?

说我有这样的形状

$something = shape(
  'some_key' => ...,
  'another_key' => ...,
  ...
);
Run Code Online (Sandbox Code Playgroud)

如何迭代形状的每个字段?我正在寻找这样的东西

foreach ($something as $key) {
  ...
}
Run Code Online (Sandbox Code Playgroud)

hacklang

1
推荐指数
1
解决办法
213
查看次数

是否可以获取Haskell可执行文件以将值返回给调用它的bash脚本?

我有一个调用Haskell可执行文件的bash脚本,是否有可能让Haskell exe返回一个值,以便它可以存储为bash变量?

例如,假设我有两个文件:haskellFile.hsBashScript.

(1)我像这样编译haskell文件 ghc -o exe haskellFile.hs

(2)在我的BashScript调用exe这样的./exe arg1 arg2

目前我有我的haskell文件打印输出,但我希望它返回一个值,所以我可以做类似的事情 bashVar = ./exe arg1 arg2

这基本上是我的haskell文件目前的样子:

main :: IO()
main = do (arg1:arg2:_) <- getArgs
    let returnValue = someFunction arg1 arg2
    print $ returnValue -- But I want it to return a value 
Run Code Online (Sandbox Code Playgroud)

bash haskell

-2
推荐指数
1
解决办法
141
查看次数