? eval
'eval' is not recognized as an internal or external command, operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
刚刚为Windows 10下载了它.
val d: Double = 42
Run Code Online (Sandbox Code Playgroud)
当我试图通过intellij找到隐式转换时,没有任何有趣的东西出现.此外,Int
不是的子类型Double
.那么Scala是如何做到的呢?
我试图用一个非常简单的例子来测试parMap vs map:
import Control.Parallel.Strategies
import Criterion.Main
sq x = x^2
a = whnf sum $ map sq [1..1000000]
b = whnf sum $ parMap rseq sq [1..1000000]
main = defaultMain [
bench "1" a,
bench "2" b
]
Run Code Online (Sandbox Code Playgroud)
我的结果似乎表明parMap没有加速,我想知道为什么会这样?
benchmarking 1
Warning: Couldn't open /dev/urandom
Warning: using system clock for seed instead (quality will be lower)
time 177.7 ms (165.5 ms .. 186.1 ms)
0.997 R² (0.992 R² .. 1.000 R²)
mean 185.1 ms (179.9 ms .. 194.1 ms) …
Run Code Online (Sandbox Code Playgroud) 所以我正在尝试使用reactive-banana + wxHaskell进行GUI编程.作为Haskell及其开发工具的新手,我对堆栈感到非常困惑.
所以我试着stack install wx
,它提示我安装wxcore
,这提示我安装wxc
和wxdirect
.在我之后stack install wxdirect
,我尝试跑步stack install wxc
,但是看见:
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
wxdirect: needed (>=0.90.1.1), not present in build plan (latest is 0.92.1.0)
needed for package: wxc-0.92.1.1
-- While attempting to add dependency,
Could not find package wxdirect in known packages
Recommended action: try adding the following to your extra-deps in {project root}/stack.yaml
- wxdirect-0.92.1.0
Run Code Online (Sandbox Code Playgroud)
总之,我试图用 …
刚开始使用Scala
var c = 0
c += 1
作品
c.+=
给了我error: value += is not a member of Int
+=
定义在哪里?
我想做这样的事情:
data Bit = 0 | 1
但由于右侧必须是有效的数据构造函数(?),我必须使用类似的东西
data Bit = Zero | One
这不是特别好,因为我想使用实际值0和1.什么是我的难题的最佳解决方案?
我对"不耐烦的Scala"一书中的这些内容有疑问,我证实了这一点:
for (c <- "Hello"; i <- 0 to 1) yield (c + i).toChar
// Yields "HIeflmlmop"
for (i <- 0 to 1; c <- "Hello") yield (c + i).toChar
// Yields Vector('H', 'e', 'l', 'l', 'o', 'I', 'f', 'm', 'm', 'p')
Run Code Online (Sandbox Code Playgroud)
第一个产生a String
,第二个产生a Vector
?但我希望它们能够返回相同的值.
具体参考https://bartoszmilewski.com/2015/04/07/natural-transformations/
作者说"这不是一个算符".
我可以定义fmap :: (a -> b) -> (a -> a) -> (b -> b)
为fmap f aa = id
,似乎遵守仿函数法则.
我并不是说为什么它没有明确地成为X语言中的Functor类型类的一部分,我只是说它为什么不被承认为仿函数.