title: Bijective function in sml
body: <p>I would like to define a function that takes an integer n and returns an integer n* such that n and n* are in the same set of integers from 1 to n,and the function must be bijective.</p>
  
  <p>I tried the following</p>
  
  <pre><code>fun bij(n) =
        let 
          val ls = zip(upto (1, n), List.rev(upto (1, n))) 
          val Tw_2 = fn(a, b) =&gt; b
        in Tw_2(List.last(ls, n-1)) end;
  </code></pre>
  
  <p>but unfortunately, it returns 1 for all my values of n. I am really stuck here.
  Can anyone give me some ideas on how to implement this?</p>
  
  <p>The behavior of <code>bij</code> must look something like</p>
  
  <pre><code>bij(1) = 3
  bij(2) = 2
  bij(3) = 1
  </code></pre>