gpt4 book ai didi

function - F# 中的函数值是如何传递的?

转载 作者:行者123 更新时间:2023-12-02 20:53:17 24 4
gpt4 key购买 nike

这是我学习 F# 的第一天。当我遇到主题函数作为值

的以下示例时,我正在浏览 tryfsharp.org
let chrisTest test =
test "Chris"
let isMe x =
if x = "Chris" then
"it is Chris!"
else
"it's someone else"
chrisTest isMe

网站上的说明:-chrisTest 是一个简单的高阶函数,用于对字符串值执行测试。 isMe 函数检查字符串是否等于“Chris”。将 isChris 传递给 chrisTest 会将字符串“Chris”作为参数传递给“isChris”函数,并返回结果“it is Chris!”。

我的想法:- isMe 函数的值被传递给程序最后一行的函数 chrisTest 。但是我没有得到的是没有值传递给 isMe 函数。 isMe 函数如何决定执行返回什么值?

最佳答案

对于这种情况,我们可以从替换 christest 中的所有内容开始。那么你就有了

chrisTest isMe = isme "Chris" (as test=isme)

然后其余部分遵循类似的过程

关于function - F# 中的函数值是如何传递的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35247206/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com