title: Recursive function in SML
body: <p>I'm struggling with SML because I need it for my master thesis but I've never used before.
  I need to define a function which takes as input a list of tuple of kind:
      (string * string * string) list</p>
  
  <p>and return a list of different tuple of kind:
      ((string *  (string * string * string)) * ((string * string * string) * string)) list</p>
  
  <p>The problem is that I'm using the recursive concept to create a dynamic list but I cannot find a way. My code so far is:</p>
  
  <pre><code>fun insertRelationLts ((x,y,z),nil) = 
          let val h=(x,y,z)
          in [((x,h),(h,z))]
          end
  | insertRelationLts ((x,y,z),(a,b,c)::(d,e,f)) = 
          let val h=(x,y,z)
              val q=x
              val w=z
          in ((q,h),(h,w))::insertRelationLts((a,b,c),(d,e,f))     
          end
  </code></pre>
  
  <p>I hope someone can help me. Thanks a lot!</p>