F# 具有多个参数的函数管道,其中一个参数是通用列表

F# 具有多个参数的函数管道,其中一个参数是通用列表,f#,functional-programming,F#,Functional Programming,我正在尝试执行函数管道,但我无法让它对多个函数参数起作用,其中一个参数是通用列表 let function1(list:System.Collections.Generic.List<Person>, x:int) = // does stuff returns a new list but for demo purposes I will just return list passed in list let function2(list:System.Col

我正在尝试执行函数管道,但我无法让它对多个函数参数起作用,其中一个参数是通用列表

let function1(list:System.Collections.Generic.List<Person>, x:int) =
     // does stuff returns a new list but for demo purposes I will just return list passed in
     list

let function2(list:System.Collections.Generic.List<Person>, x:int) =
     // does stuff returns a new list but for demo purposes I will just return list passed in
     list
编译器抱怨“表达式的类型应为'a*int',但此处的类型为int”

有什么明显的我做错了吗?
非常感谢您的帮助…

如果您想使用管道,您需要编写函数,以便它们:

  • 采用多个参数,而不是采用元组
  • 列表是最后一个参数
例如:

let function1 (x:int) (list:System.Collections.Generic.List<Person>) =
   // does stuff returns a new list but for demo 
   // purposes I will just return list passed in
   list

let function2 (x:int) (list:System.Collections.Generic.List<Person>) =
   // does stuff returns a new list but for demo 
   // purposes I will just return list passed in
   list
let function1(x:int)(列表:System.Collections.Generic.list)=
//stuff是否返回一个新列表,但用于演示
//我将返回传入的列表
列表
let function2(x:int)(列表:System.Collections.Generic.list)=
//stuff是否返回一个新列表,但用于演示
//我将返回传入的列表
列表

作为旁注,我不会在管道中使用.NET generic
List
,因为它是一个可变的数据结构,所以您可能会遇到混乱的行为。不可变的F#list或
seq
是更好的选择。

如果您想使用管道,您需要编写函数,以便它们:

  • 采用多个参数,而不是采用元组
  • 列表是最后一个参数
例如:

let function1 (x:int) (list:System.Collections.Generic.List<Person>) =
   // does stuff returns a new list but for demo 
   // purposes I will just return list passed in
   list

let function2 (x:int) (list:System.Collections.Generic.List<Person>) =
   // does stuff returns a new list but for demo 
   // purposes I will just return list passed in
   list
let function1(x:int)(列表:System.Collections.Generic.list)=
//stuff是否返回一个新列表,但用于演示
//我将返回传入的列表
列表
let function2(x:int)(列表:System.Collections.Generic.list)=
//stuff是否返回一个新列表,但用于演示
//我将返回传入的列表
列表

作为旁注,我不会在管道中使用.NET generic
List
,因为它是一个可变的数据结构,所以您可能会遇到混乱的行为。不可变的F#list或
seq
是一个更好的选择。

感谢帮助Tomas,也改为使用seq,谢谢帮助Tomas,也改为使用seq