f# - 在 F# 交互中,如何获取 [] 来自 List.map?
问题描述
总新手 F# 问题。
在 Visual Studio 2019,F# 交互式文件中,我有:
open System
module Visit =
type Model =
{
Id: int
Name: string
}
let init col cel =
{
Id = col*100 + cel*10 + 1
Name = sprintf "My Name is col: %d cel: %d" col cel
}
let getName m = m.Name
module Cell =
type Model =
{
Id: int
Visit: Visit.Model
}
let init col cel =
{
Id = col*10 + cel
Visit = Visit.init col cel
}
let getVisit (m:Model) = Visit.getName m.Visit
module Column =
type Model =
{
Id: int
Appointments: Cell.Model list
}
let init =
{ Id = 0
Appointments = [0 .. 3] |> List.map (Cell.init 0) }
let findAppointment m =
m.Appointments |> List.map ( fun cell -> Cell.getVisit)
// m.Appointments |> List.map ( fun cell -> printfn "%A" cell; cell.Id)
let find =
init |> findAppointment
我得到:
val find : (Cell.Model -> string) list = [fun:Invoke@3233; 有趣:调用@3233;有趣:调用@3233;有趣:调用@3233]
如何在列表中获取实际的名称(字符串)函数结果(不是 [fun:Invoke@...),...]???
TIA
解决方案
罪魁祸首是,这Cell.getVisit
不适用于细胞,即它应该是
m.Appointments |> List.map (fun cell -> Cell.getVisit cell)
或者
m.Appointments |> List.map Cell.getVisit
推荐阅读
- asp.net-core - 如何覆盖默认文化(本地化)ABP.IO?
- laravel - Laravel 将动态值存储到配置文件或任何文件中
- javascript - 应该将 Snapshot 笑话单元测试与 Angular 相匹配
- rest - 使用 WCF-WebHttp 适配器从 BizTalk Server 使用 REST 服务器方法
- python - 使用python进行多处理没有任何反应
- php - 在 MySQL 中更新记录时,Laravel 的 useCurrent() 不起作用
- android - 我想声明一个为我返回的 String 类型的 Array:Array
? 不是数组 - cs50 - CS50 Pset3 复数 - 无法将第二个候选人显示为获胜者
- amazon-s3 - 使用 AWS-cdk 和 aws lambda 时日志传递权限不足
- c# - 从函数返回 ActionResult OR Task