【发布时间】:2015-09-22 17:22:05
【问题描述】:
我有以下代码。在这一行
if min<=0 then min <- List.nth list i |>ignore
我有 2 个错误。
首先在0是
This expression was expected to have type
unit
but here has type
int
然后在i是
This expression was expected to have type
unit
but here has type
int
* 我也看过this 并尝试忽略,但它不起作用
let replace touple2=
let first (a,_,_,_,_)=a
let second (_,b,_,_,_)=b
let third (_,_,c,_,_)=c
let forth (_,_,_,d,_)=d
let fifth (_,_,_,_,e)=e
let sortedlist list= List.sort(list)
let GetMin list=
list |> List.rev |> List.head
let mutable min=list.Head
let mutable i=1
for i in list do
if min<=0 then min <- List.nth list i |>ignore
min
let GetMax list=list |> List.rev |> List.head
let A=first touple2
let B=second touple2
let C=third touple2
let D=forth touple2
let E=fifth touple2
let mylist=[A;B;C;D;E]
let L=sortedlist mylist
let m1=GetMax L
printfn "%d" m1
let touple3= 14,6,18,76,76
replace touple3
【问题讨论】:
-
它应该是读者的难题吗? :) 如果您不确定表达式的边界,请尝试使用括号。
-
你不是在 2 小时前问过这个吗? stackoverflow.com/q/32720710/126014
标签: f# f#-interactive unit-type