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.
I tried the following
fun bij(n) =
let
val ls = zip(upto (1, n), List.rev(upto (1, n)))
val Tw_2 = fn(a, b) => b
in Tw_2(List.last(ls, n-1)) end;
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?
The behavior of bij
must look something like
bij(1) = 3
bij(2) = 2
bij(3) = 1