小编Rah*_*hat的帖子

如何在 Java 中合并两个不可变集。?

我正在使用 Guava 的 Immutable 集合。基本上我有两个辅助函数,它们返回 ImmutableSets,它们都包含数据,这些数据是实现公共接口的内部类的实例。但是,我想在实际函数中将两个 Immutable 集合按顺序合并为一个 ImmutableSet。

private static ImmutableSet<Fruit.seedless> helper1(args...) {...}
private static ImmutableSet<Fruit.seeded> helper2(args...) {...}
public ImmutableSet<Fruit> MainFunction() {...}
Run Code Online (Sandbox Code Playgroud)

java collections guava

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

为什么是 [ ( True , [ ] ) , ( False , [ ['a'] ] ) ] , "[ (Bool , [ [char] ] )]" 的类型?

当我输入:type [(True,[]),(False, [['a']])] , "[(Bool,[[char]])]"ghci 时,它会输出[ (Bool , [ [char] ] )]. Haskell 的类型推断怎么可能将空列表和 [[char]] 视为相同的。

haskell type-inference

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

Babel:检测到重复的插件/预设错误

我正在做前端大师的反应课程,我们不得不修改 babel 配置以允许状态实例化,例如:state = {index: 0}在类组件中,但是在运行命令时:,并在根目录中创建一个文件并对其进行修改: 我收到以下错误:
npm install -D babel-eslint @babel/core @babel/preset-env @babel/plugin-proposal-class-properties @babel/preset-react
.babelrc
{ "presets": ["@babel/preset-react", "@babel/preset-env"], "plugins": ["@babel/plugin-proposal-class-properties"] }

/home/rahat/Documents/react_adopt_me/src/App.js: Duplicate plugin/preset detected.
    If you'd like to use two separate instances of a plugin,
    they need separate names, e.g.
    
      plugins: [
        ['some-plugin', {}],
        ['some-plugin', {}, 'some unique name'],
      ]
    
    Duplicates detected are:
    [
      {
        "alias": "/home/rahat/Documents/react_adopt_me/src/node_modules/@babel/plugin-proposal-class-properties/lib/index.js",
        "dirname": "/home/rahat/Documents/react_adopt_me/src",
        "ownPass": false,
        "file": {
          "request": "@babel/plugin-proposal-class-properties",
          "resolved": "/home/rahat/Documents/react_adopt_me/src/node_modules/@babel/plugin-proposal-class-properties/lib/index.js"
        }
      },
      {
        "alias": "base$2",
        "options": { …
Run Code Online (Sandbox Code Playgroud)

javascript json reactjs babeljs

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

Haskell IO:打印命令行参数

我有这个程序,它只是打印出命令行参数。

echoArgs :: IO ()
echoArgs = do
        line <- getArgs
        print line
Run Code Online (Sandbox Code Playgroud)

我想知道的是为什么当我输入时会失败:

echoArgs :: IO ()
echoArgs = do
            line <- getArgs
            putStrLn line
Run Code Online (Sandbox Code Playgroud)

以及为什么当我将其更改为以下内容时它不起作用:

echoArgs :: IO String
    echoArgs = do
                line <- getArgs
                let line' = read line :: String
                putStrLn line'
Run Code Online (Sandbox Code Playgroud)

io monads haskell command-line-arguments do-notation

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

为什么 x*x where x = 6 在 Haskell 中失败?

我一直在阅读 Haskell 的功能性思考以学习 Haskell,我遇到了这一点。在书中它说 where 子句不限定表达式,而是限定整个右侧的定义。我不太明白这个意思。

haskell where-clause ghci haskell-platform

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