简体   繁体   中英

how to pass string type list in F# function

This code is giving error FS0001: This expression was expected to have type 'string' but here has type ''a * 'b'

open System 
open System.Linq

let list1 = [ "one"; "two"; "three" ]
let list2 = [ "one"; "two"; "three" ]

let tablesValidation (l1 : string list) (l2 : string list) =
    printfn "%O" l1
    printfn "%O" l2


tablesValidation(list1,list2)
Console.ReadKey() |> ignore

In F#, function arguments do not need parentheses and are separated by spaces. Change it to this:

tablesValidation list1 list2

Your original version passed a tuple value as a single parameter, hence the error message, where a * b means a tuple with two fields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM