小编Sau*_*ade的帖子

What exactly is meant by "partial function" in functional programming?

According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, if this were directly valid in Python:

>>> def add(x,y):
...    return x+y
... 
>>> new_function = add(1)
>>> new_function(2)
3
Run Code Online (Sandbox Code Playgroud)

In the snippet above, new_function is a partial function. However, according to the Haskell Wiki, the definition of partial function is

A partial function is a function that is not defined for all possible arguments of …

python haskell functional-programming partial-application partial-functions

54
推荐指数
3
解决办法
4129
查看次数

管道`|`运算符在elm-lang的case表达式中做什么?

我的 Elm 代码中有以下代码片段:

type alias Model =
  { content : String
  }


update : Msg -> Model -> Model
update msg model =
  case msg of
    Change newContent ->
      { model | content = newContent }
Run Code Online (Sandbox Code Playgroud)

有什么作用{ model | content = newContent }?它是否分配(绑定)newContenttomodel和的值content?这就是| 操作员被放置在那里的原因吗?

elm

8
推荐指数
2
解决办法
459
查看次数

如何在 simplelogger.properties 中为 SLF4J-simple 设置不同包的日志记录级别

在 simplelogger.properties 文件中,我们可以将默认日志级别设置为

org.slf4j.simpleLogger.defaultLogLevel=error
Run Code Online (Sandbox Code Playgroud)

但是如果要为特定包设置日志记录级别,那么该怎么做呢?例如如果包名是

com.xxx.yyy

那么如果我把它放在 simplelogger.properties 中

com.xxx.yyy.level=error
Run Code Online (Sandbox Code Playgroud)

那么它不起作用。如何配置它?

java logging log4j slf4j

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

cabal install gving errror as LICENSE: openBinaryFile: does not exist (No such file or directory)

我有阴谋集团版本:

? cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library 
Run Code Online (Sandbox Code Playgroud)

这就是我正在做的事情。

mkdir foo
cd foo
cabal init
cabal install
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

LICENSE: openBinaryFile: does not exist (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么?

haskell ghc cabal

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

如何检查Haskell中一种代数类型列表中的所有元素?

如果我有以下代数数据类型

type MyVal = Either String Int
Run Code Online (Sandbox Code Playgroud)

并具有包含MyVal类型的元素的列表

ls = [Right 1, Right 2, Right 3]
xs = [Right 1, Left "error", Right 3]
Run Code Online (Sandbox Code Playgroud)

现在,我想写函数找出那是我所有具有“ Right”值的列表,然后它应该返回True,否则返回False。

在这种情况下,ls它将返回True,xs并且将返回False。

我怎样才能做到这一点?

我尝试使用all函数,但无法正确使用它。

haskell functional-programming haskell-platform

4
推荐指数
2
解决办法
375
查看次数

Scala中的List不是同类集合吗?

我有以下功能,它将列表的头部设置为新值

  def setHead[A](ls: List[A], ele: A):List[A] = {
    ls match {
    case Nil => ls
    case x :: xs => ele :: xs
    }
  }
Run Code Online (Sandbox Code Playgroud)

用它调用后输出

println(setHead(List(-1,-2,-3,4,5,6), (x :Int)  =>  x < 0))
Run Code Online (Sandbox Code Playgroud)

List(<function1>, -2, -3, 4, 5, 6)
Run Code Online (Sandbox Code Playgroud)

但该函数采用类型'A'参数,我传递一个类型为'Int'的列表和一个函数,然后如何编译和运行,因为类型'A'不能同时为Int.

generics functional-programming scala

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

模块'Main'不会导出IO操作'main'

我有两个名为SimpleJSON.hs的haskell文件,另一个是Main.hs

--File: SimpleJSON.hs
module SimpleJSON
(
    JValue (..)
    ,getString
    ,getInt
    ,getDouble
    ,getBool
    ,getObject
    ,getArray
    ,isNull
) where

data JValue = JString String
        | JNumber Double
        | JBool Bool
        | JNull
        | JObject [(String, JValue)]
        | JArray [JValue]
          deriving (Eq, Ord, Show)
Run Code Online (Sandbox Code Playgroud)

--File: Main.hs
module Main () where
import SimpleJSON
main = print (JObject [("foo", JNumber 1), ("bar", JBool False)])
Run Code Online (Sandbox Code Playgroud)

所以在编译时我正在做

ghc -c SimpleJSON.hs
Run Code Online (Sandbox Code Playgroud)

ghc simple Main.hs SimpleJSON.o
Run Code Online (Sandbox Code Playgroud)

然后我得到错误

Main.hs:1:1: error:
The IO action ‘main’ is not exported by …
Run Code Online (Sandbox Code Playgroud)

haskell

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

如何在react js中将{variable}连接到href标签?

我正在尝试在锚标记的 href 字符串中的大括号中使用变量。假设 {entry.email} 的值为 abc@xyz.com 那么我尝试这样做<a href="mailto:"+{entry.email}>{entry.email}</a>来生成锚标记 <a href="mailto:abc@xyz">abc@xyz

在下面的代码中

const rows = props.contacts.map((entry, index) => {
    return (
        <tr key={index}>
            <td><a href="mailto:"+{entry.email}>{entry.email}</a></td>
        </tr>
    );
Run Code Online (Sandbox Code Playgroud)

但显然这不起作用,甚至无法编译。我该怎么做呢?

javascript reactjs react-redux

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

Emacs 有 elm-lang 编程语言支持吗?

我开始使用 Elm 语言https://elm-lang.org/,我正在使用 Emacs,但没有找到任何适用于 elm-lang 的包/插件。如果你知道任何然后请帮助。

emacs elm

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

如何将机器人测试用例中的整数列表传递给后端java函数或方法?

机器人测试:

${SomeList} Create List  70  30  50
Run Code Online (Sandbox Code Playgroud)

JAVA代码:

@RobotKeyword
public void myJavaMethod(List<Integer> someList)
Run Code Online (Sandbox Code Playgroud)

这里,问题被认为你把列表的类型放在Integer中,它只在String中解释.如何将其作为整数列表传递?

java robotframework robotframework-ide

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