いずれにしても、リストを取得して最高と最低の要素を返すこれらの2つの関数を結合します。両方同時に出力したい。歓声 fun max[] = raise Empty
max[x] = x
max(x::xs) =
let
val y = max xs
in
if x > y then x else y
end;
fun min[
datatype 'a tree= Leaf of 'a | Node of 'a tree * 'a * 'a tree
fun binSearch (Node(left,n,right)) x =
if x > n then false
else if x=n then true
else binSearch (Node(left,n,right)) x =
I'm brand new to SML/NJ and I'm trying to make a recursive function that makes a listOfLists. Ex: listOf([1,2,3,4]) will output [[1],[2],[3],[4]] . I've found a recursive merge in SML/NJ, and I'm tryi
I have a function called mergeP: fun mergeP(nil) = nil
| mergeP(x::[]) = x::[]
| mergeP(x::y::zs) = (x @ y)::mergeP(zs);
If mergeP is called like: mergeP([[1],[2],[3],[4]]) it will return [[1,2],[