简体   繁体   中英

How do I pass a list of tuples as an argument in a function?

I want to write a function that takes as an argument a list of three tuples.

What I have isn't passing the eval, as I assume that it's reading it as tuple of two ints plus an int list:

fun check_list(tuples : int*int*int list) = so forth and so forth

What is the proper syntax for typing a list of tuples?

The problem is in your syntax.

This int*int*int list is equivalent to int * int * (int list)

But what you meant is (int * int * int) list . The use of parentheses should make it clearer.

if you want a tuple of three ints then you would pass to a function like so:

fun check_list(a:int,b:int,c:int)=[(a,b,c)];

check_list(1,2,3);

plug it in and try it. I will return [(1,2,3)]. If I'm understanding your question correctly.

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