Confused with F# List.nth's argument order

本秂侑毒 提交于 2019-12-10 13:15:09

问题


List.nth is 'T list -> int -> 'T, rather than the standard int -> 'T list -> 'T like Seq.nth.

This makes pipeline somewhat awkward.

Is there something behind the scene?

I don't know why.


回答1:


Might be for ocaml compatibility (or just laziness), but without deeper reasons concerning the implementation itself.




回答2:


This signature allows you to curry the function with respect to a given list. This allows you to keep a List.nth someList stored, and use it to get the nth element of the list without having to specify the list variable every time.

I'm not sure why it's nonuniform with respect to other F# functions, though.



来源:https://stackoverflow.com/questions/2968983/confused-with-f-list-nths-argument-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!