title: reverse function and append function to custom list standard ml
body: <p>I want to make a function that reverse a mylist value. I wrote code but it isnt working, and I'd appreciate any tips or help.</p>
  
  <p>the datatype code:</p>
  
  <pre><code>datatype 'element mylist = 
    NIL
  | CONS 'element * 'element mylist;
  </code></pre>
  
  <p>and the functions I wrote are:</p>
  
  <pre><code>fun reverse NIL = NIL
    | reverse (CONS(x, xs)) = CONS((reverse xs), x);
  </code></pre>
  
  <p>I also want to write a function that appends 2 mylist values, I have some cases but it didnt work, i though of the following:</p>
  
  <pre><code>fun append NIL = fn NIL =&gt; NIL
    | append NIL = fn (CONS(x, xs)) =&gt; CONS(x, xs)
    | append (CONS(x, xs)) = fn NIL =&gt; CONS(x, xs)
    | append (CONS(x, xs)) = fn (CONS(y, ys)) =&gt; append xs (CONS(y, ys));
  </code></pre>
  
  <p>but it is not working, giving me error, what is wrong with my code?</p>
  
  <p>Thanks</p>