簡體   English   中英

如何在函數中將元組列表作為參數傳遞?

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

我想編寫一個函數,該函數將三個元組的列表作為參數。

我沒有通過評估,因為我假設它正在將其讀取為兩個int加上一個int列表的元組:

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

鍵入元組列表的正確語法是什么?

問題出在您的語法中。

int*int*int list等效於int * int * (int list)

但是你的意思是(int * int * int) list 使用括號應使其更清楚。

如果您想要三個整數的元組,那么您將傳遞給這樣的函數:

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

check_list(1,2,3);

插入並嘗試。 我將返回[(1,2,3)]。 如果我正確理解您的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM