在Elm Lang中,\\u->;语句(符号、运算符、模式)是什么意思?

在Elm Lang中,\\u->;语句(符号、运算符、模式)是什么意思?,elm,Elm,我发现了我认为是一种模式。 乍一看,它在我看来就像一个我从未见过的图案,但它到底是什么呢 我为可能遇到相同问题的人添加此条目 \\uU->是一个匿名函数,它只接受一个参数,但它不使用函数体中的参数,因此它不是像\a->那样命名,而是使用丢弃参数,事实上它不是一个模式,而是一个lambda(匿名函数,一种不绑定到标识符的函数定义。)正如megapctr向我指出的 我在这里找到了这个lambda: 输出:“helloworld”:字符串 (identity <| (\() -> &quo

我发现了我认为是一种模式。 乍一看,它在我看来就像一个我从未见过的图案,但它到底是什么呢


我为可能遇到相同问题的人添加此条目

\\uU->
是一个匿名函数,它只接受一个参数,但它不使用函数体中的参数,因此它不是像
\a->
那样命名,而是使用

丢弃参数,事实上它不是一个模式,而是一个lambda(匿名函数,一种不绑定到标识符的函数定义。)正如megapctr向我指出的

我在这里找到了这个lambda:

输出:“helloworld”:字符串

(identity <| (\() -> "helloworld" ) ()) |> String.reverse
所有生产相同产量的产品: “helloworld”:字符串用于任何类型的输入,Int浮点字符串函数


然后模拟与我使用的管道测试代码相同的格式,Hi-Acid,感谢您的响应只是为普通观众发帖。对不起,我的意思是浪费你的时间!我的意思不是浪费你的时间!如果你想回答你自己的问题,那么你可以。有一个复选框(回答你自己的问题-分享你的知识,问答式)。这样可以避免在您编写自己的答案时由其他人回答。虽然有见解,但此答案的格式并不真正符合SO的指导原则。尝试和错误示例可能更适合SO。@Acid Burn简洁完整的答案更适合SO。谢谢Zimm和Chad
(\_ -> "helloWorld") 5
(\_ -> "helloWorld") 4.0
(\_ -> "helloWorld") "abalone"
(\_ -> "helloWorld") not
(\_ -> "helloWorld") abs
identity <| (\_ -> "helloWorld") "anything"
(identity <| (\_ -> "helloworld" ) "anything") |> String.reverse
(\() -> "hellouniverse") ()
(identity <| (\() -> "helloworld" ) ()) |> String.reverse
==================================== ERRORS ====================================

-- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm

The argument to this function is causing a mismatch.

4|    \() -> "hellouniverse" ) 5
                               ^
This function is expecting the argument to be:

    ()

But it is:

    number
==================================== ERRORS ====================================

-- TYPE MISMATCH --------------------------------------------- repl-temp-000.elm

The argument to this function is causing a mismatch.

4|    \() -> "hellouniverse" ) identity
                               ^^^^^^^^
This function is expecting the argument to be:

    ()

But it is:

    a -> a
test x = 
   ((++) "super  "  <|  ( (\() -> "hellouniverse" ) <| x )) |>  String.reverse
test ()