我们有两个比较两个不同power函数的函数,如果它们返回相同的值(在同一个输入上),则返回true.
然后我们有两个其他函数来测试这些函数对两个列表,看看是否有任何值不返回true.
但是[1..100]我们不想使用使用范围的列表,而是使用QuickCheck.
是否可以使QuickCheck仅返回正整数?
码:
comparePower1 :: Integer -> Integer -> Bool
comparePower1 n k = power n k == power1 n k
comparePower2 :: Integer -> Integer -> Bool
comparePower2 n k = power n k == power2 n k
testing1 = and [comparePower1 n k | n <- [0..100], k <- [0..100]]
testing2 = and [comparePower2 n k | n <- [0..100], k <- [0..100]]
Run Code Online (Sandbox Code Playgroud) 我有一个dicts列表:
a = [{'one': 1}, {'two': 2}, {'three': 3}, {'four': 4}, {'five': 5}]
Run Code Online (Sandbox Code Playgroud)
我想用所有余数的总和更新此列表中每个元素的值.(所以'one'会得到价值2+3+4+5).
所以它看起来像这样:
a = [{'one': 14}, {'two': 12}, {'three': 9}, {'four': 5}, {'five': 5}]
Run Code Online (Sandbox Code Playgroud)
'five' 是最后一个,所以它不会更新.
我不知道如何实现这一目标.我认为你构造一个函数,将自己称为recursivly类似于:
def recursive(a):
if len(a) == 1:
return list(a[0].values())[0]
else:
val = list(a[0].values())[0]
return val + recursive(a.pop(0))
Run Code Online (Sandbox Code Playgroud)
但我不确定这list(a[0].values())[0]是"最好的"方式.这也是一个KeyError: 0.
有任何想法吗?
我首先尝试安装Hlint.cabal install hlint但后来我得到了错误:
cabal: Error: some packages failed to install:
cpphs-1.20.2 depends on old-time-1.1.0.3 which failed to install.
haskell-src-exts-1.18.2 depends on old-time-1.1.0.3 which failed to install.
hlint-1.9.37 depends on old-time-1.1.0.3 which failed to install.
old-time-1.1.0.3 failed during the configure step. The exception was:
ExitFailure 77
Run Code Online (Sandbox Code Playgroud)
然后我尝试安装ghc-mod,因为我读到hlint是该包的依赖项(?).认为它可以解决问题.所以我做了cabal install ghc-mod哪个给了我错误.
cabal: Error: some packages failed to install:
cpphs-1.20.2 depends on old-time-1.1.0.3 which failed to install.
ghc-mod-5.6.0.0 depends on old-time-1.1.0.3 which failed to install.
haskell-src-exts-1.17.1 depends on old-time-1.1.0.3 which …Run Code Online (Sandbox Code Playgroud) 初始化时以及更改屏幕分辨率时,我的光滑滑块的宽度会变错.
我的js:
$('.slider').slick({
infinite: false,
speed: 300,
initialSlide: 1,
slidesToShow: 3,
slidesToScroll: 1,
dots: false,
responsive: [{
breakpoint: 1024,
settings: {
slidesToShow: 2
}
}, {
breakpoint: 650,
settings: {
initialSlide: 2,
slidesToShow: 1
}
}]
});
Run Code Online (Sandbox Code Playgroud)
我的css:
.sub-slider {
width: 100%;
display: flex;
flex-flow: column;
.slider {
display: flex;
flex-flow: row;
justify-content: center;
align-content: center;
align-items: center;
min-width:500px;
.sub-box {
text-align: center;
padding-top: 45px;
cursor:pointer;
.title {
color: #6deca0;
font-family: "AmsiProNarw", sans-serif;
font-size: 48px;
font-style: italic;
font-weight: 800;
} …Run Code Online (Sandbox Code Playgroud) 我刚刚重新安装了我的电脑,现在无法让它工作......我真的不记得上次我是如何工作的.但我看到了这个指南:http://sean-bedford.com/console2-bash/
但是当我尝试将我的shell更改为:
C:\windows\System32\cmd.exe /c "c:\windows\system32\bash.exe"
Run Code Online (Sandbox Code Playgroud)
我无法启动console2.
如果我尝试在run(WIN + R)中运行路径,一切正常.
如果我更改/c为/k然后我可以运行它,但这出现了:
'c:\windows\system32\bash.exe' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
但我也可以正常地走这条道路.
我已经上传了两个文件file1.js,file2.js但我只想提交file2.js.我怎样才能做到这一点?
我正在尝试为自定义类型编写一个解组函数。考虑下面的代码(游乐场)
package main
import (
"encoding/json"
"fmt"
"strings"
"time"
)
type Time time.Time
func (st *Time) UnmarshalJSON(b []byte) error {
// "2021-05-21T03:10:20.958450" -> "2021-05-21T03:10:20.958450Z"
s := strings.Trim(string(b), "\"")
t, err := time.Parse(time.RFC3339, fmt.Sprintf("%s%s", s, "Z"))
if err != nil {
return fmt.Errorf("parse time: %w", err)
}
*st = Time(t)
return nil
}
type User struct {
Name string
TS Time
}
const data = `{"id":3, "name":"Name", "ts":"2021-05-21T03:10:20.958450"}`
func main() {
user := new(User)
json.Unmarshal([]byte(data), &user)
fmt.Printf("%v\n", user)
} …Run Code Online (Sandbox Code Playgroud) 对不起标题血量(如果你能建议更好,请做).但我的问题是,我不太明白如何让这个块工作.我有一个代码返回5列表列表中的位置.像这样:
findFive :: [[Int]] -> (Int, Int)
findFive rs = do
x <- xPos rs 0
y <- yPos rs 0
return ( (x,y) )
xPos :: [[Int]] -> Int -> Int
xPos (rs:[[]]) n = n
xPos (rs:rss) n | elem 5 rs = n
| otherwise = xPos rss (n+1)
yPos :: [[Int]] -> Int -> Int
yPos (rs:[[]]) n = n
yPos (rs:rss) n | elem 5 rs = n
| otherwise = yPos rss …Run Code Online (Sandbox Code Playgroud) 考虑这个小提琴:https://jsfiddle.net/vs9a4toz/
我希望我的按钮位于div的底部.
我尝试使用align-self: flex-end他们的容器div.但最终结果是div的内容在最后并不是div本身.
.container {
width: 600px;
display: flex;
flex-flow: row;
border: 2px solid red;
}
.box1,
.box2,
.box3 {
width: 100%;
border: 1px solid blue;
display: flex;
flex-flow: column;
size: 100px;
}
.content {
text-align: center;
}
.buttons {
display: flex;
flex-flow: column;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="box1">
<div class="content">
<p>HEJ</p>
</div>
<div class="buttons">
<button>ONEONE</button>
<button>TWOTWO</button>
</div>
</div>
<div class="box2">
<div class="content">
<p>HEJ HEJ HEJ HEJ HEJ HEJ HEJ HEJ HEJ HEJ HEJ …Run Code Online (Sandbox Code Playgroud)现在我不能使用npm. 我收到错误:
bash: /usr/local/bin/npm: No such file or directory.
我怎样才能解决这个问题?谢谢!
我正在运行 ubuntu 16.04
haskell ×3
css ×2
html ×2
bash ×1
console2 ×1
css3 ×1
flexbox ×1
formatting ×1
git ×1
git-commit ×1
go ×1
hlint ×1
javascript ×1
jquery ×1
npm ×1
package ×1
python ×1
quickcheck ×1
slick.js ×1
testing ×1
time ×1
windows-10 ×1