小编sim*_*ems的帖子

Javascript将2个数组映射为1个对象

我必须使用数组(名称和状态数组)并将它们映射到具有attrbiutes名称和状态的一个对象.

数组名称:

 ["Time", "Riskchanged", "Scope", "Risk4", "Test", "Test(2)"]
Run Code Online (Sandbox Code Playgroud)

数组状态:

 ["In Bearbeitung", "Abgeschlossen", "In Bearbeitung", "Abgeschlossen", "Geplant", "In Bearbeitung"]
Run Code Online (Sandbox Code Playgroud)

功能:

this.testArr = this.riskNamesArr.map( (x, i) => {
    return {"name": x, "state": this.riskWorkflowStateArr[i]}        
});
Run Code Online (Sandbox Code Playgroud)

这适用于所有桌面浏览器,但遗憾的是不在我的iOS Safari浏览器上.如果我添加这些行,移动浏览器只显示任何内容.

那么有另一种方法可以获得相同的结果吗?

javascript arrays dictionary object

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

在python3.5 osx上安装pygame

我试图安装pygame

pip3 install hg+http://bitbucket.org/pygame/pygame
Run Code Online (Sandbox Code Playgroud)

收到此错误:

Collecting hg+http://bitbucket.org/pygame/pygame
Cloning hg http://bitbucket.org/pygame/pygame to     /var/folders/vl/g_3vs3xj2clcnyc58spzmjq00000gn/T/pip-7f5mltpu-build
Error [Errno 2] No such file or directory: 'hg' while executing   command hg clone --noupdate -q http://bitbucket.org/pygame/pygame 
/var/folders/vl/g_3vs3xj2clcnyc58spzmjq00000gn/T/pip-7f5mltpu-build
Cannot find command 'hg'
Run Code Online (Sandbox Code Playgroud)

要么

brew install pygame
Run Code Online (Sandbox Code Playgroud)

错误:

Error: Failed to download resource "pygame"
Failure while executing: /usr/local/opt/mercurial/bin/hg clone https://bitbucket.org/pygame/pygame /Library/Caches/Homebrew/pygame--hg
Run Code Online (Sandbox Code Playgroud)

有人用python 3.5在osx上成功安装了pygame吗?

python macos pygame

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

Haskell:翻转功能的目的?

我有点意外,以前没有问过.也许这是一个愚蠢的问题.

我知道翻转正在改变两个参数的顺序.

例:

(-) 5 3
= 5 - 3
= 2

flip (-) 5 3
= 3 - 5
= -2
Run Code Online (Sandbox Code Playgroud)

但为什么我需要这样的功能呢?为什么不手动更改输入?

为什么不写:

(-) 3 5
= 3 - 5
= -2
Run Code Online (Sandbox Code Playgroud)

haskell arguments flip

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

Monads(Haskell)的主要目的

根据我的读数,我了解Monads主要用于:

- 通过将一个函数输出类型与另一个函数输入类型匹配来构成函数.

我认为这是一篇很好的文章:

http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

它解释了Monads的盒子/包装概念.但是我不明白这些包装用的是什么?除了Composition之外,Wrapper有什么好处?

IO Monad也是一个常见的例子.

name <- getLine -- name has the type String and getLine IO String
Run Code Online (Sandbox Code Playgroud)

那么这种类型差异有什么好处呢?是错误处理吗?

monads haskell

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

Haskell:foldl函数作为中缀函数应用?

我给的函数foldl是以中缀方式应用的吗?

foldl (-) 0 [1,2,3]

= 0-1-2-3 
= -6
Run Code Online (Sandbox Code Playgroud)

更一般地说:

foldl f x [a,b,c]
Run Code Online (Sandbox Code Playgroud)

适用于:

(((x `f` a) `f`  b) `f` c)
Run Code Online (Sandbox Code Playgroud)

我知道它是递归的,但我可以这样思考吗?

haskell fold infix-operator foldleft

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

Haskell:一串"a"的尾巴

为什么String只有一个字母的尾部是空字符串而不是空列表?

例:

tail "a"
= ""
Run Code Online (Sandbox Code Playgroud)

但您可以创建一个String作为:

'a' : []
= "a"
Run Code Online (Sandbox Code Playgroud)

所以我认为尾巴应该是空列表[].

如果你这样做的话

tail ["x"]
Run Code Online (Sandbox Code Playgroud)

然后你得到空列表[].

这有点令人困惑.

string haskell tail

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

python:ValueError:没有足够的值来解包(预期2,得到0)

这个错误是什么意思?

labels, freq = zip(*terms_hash)
ValueError: not enough values to unpack (expected 2, got 0) 
Run Code Online (Sandbox Code Playgroud)

当我打印条款时,没有错误.

码:

fname = 'stream.json'
with open(fname, 'r') as f:
    print('alle Hashtags')
    count_all = Counter()
    for line in f:
        tweet = json.loads(line)
# Count hashtags only

        terms_hash = [term for term in preprocess(tweet['text']) 
              if term.startswith('#')]

        # Update the counter
        count_all.update(terms_hash)

        terms_hash = count_all.most_common(5)

        labels, freq = zip(*terms_hash)
        data = {'data': freq, 'x': labels}
        bar = vincent.Bar(data, iter_idx='x')
        bar.to_json('term_freq.json')    


    # Print the first 5 most frequent …
Run Code Online (Sandbox Code Playgroud)

python python-3.x tweets

0
推荐指数
1
解决办法
3万
查看次数

调用iOS webview HTTPS(自签名证书)

我想在我的iOS应用程序中调用HTTPS url(自签名证书).它适用于移动浏览器,但不适用于App Webview.

Xcode 7和Swift 2.2有解决方案吗?

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        let url = NSURL(string: "https://xxx.xxx.x.xxx:xxxx")

        let request = NSURLRequest(URL: url!)
        Webview.loadRequest(request)
    }
Run Code Online (Sandbox Code Playgroud)

ssl https ios swift

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