Error in SML code with higher order functions

57 Views Asked by At

I'm trying to select the minimum element in a list based on the third value of its elements. But there seems to be a problem with my usage of higher-order functions in the min_proc function. (I'm using SML in CPN Tools)

fun min_process(p1: DATA, p2: DATA) =
    if (#3 p1 <= #3 p2)
    then p1
    else p2;

fun min_proc(l) =
    if (l = [])
    then empty
    else
        if (List.length(l) = 1)
        then List.hd(l)
        else min_process(List.hd(l), min_proc(List.tl(l)));

Error at:

../compiler/TopLevel/interact/evalloop.sml:66.19-66.27
0

There are 0 best solutions below