Hi I am relatively new to ML/SML and I am trying to write function that takes as input 2 lists. The one list contains 4 random strings ["duck","goose","swan","gull"] and the second takes another 4 strings ["duck","swan","goose","pigeon"].
What I would like to do i check each element in the first list against each element the other. If the strings are in the same position and are equal output a 'yes'. If the elements are not in the same position but are in the list then output 'maybe', and if the element isn't in the second list output 'no'.
So given the 2 examples above it would output ["yes","maybe","maybe","no"].
This is what I have done so far, but I can't figure out how to keep recursively calling the main function, checkEqual, to iterate over the entire first list.
 fun buildStringList nil nil = nil
|buildStringList lst appList = 
    lst @ appList   
in
fun checkEqual nil nil = nil
| checkEqual code guess =
    if hd code = hd guess then
        buildStringList ([])(["yes"])
    else if hd code = hd(tl guess) then
        buildStringList ([])(["maybe"])
    else if hd code = hd(tl(tl guess)) then
        buildStringList ([])(["maybe"])
    else if hd code = hd(tl(tl(tl guess))) then
        buildStringList ([])(["maybe"])
    else 
        buildStringList ([])(["no"])        
end;
Any help would be greatly appreciated.
                        
There are two code paths, comparing items by index [the "yes" condition] and then comparing them without regard to index [the "maybe" path]. Using recursion and a helper function [or two] allows both code paths to be followed: