title: In-order traversal of tree and apply given function to all nodes
body: <p>I've written an in-order tree traversal function:</p>
  
  <pre><code>let rec inOrder (tree: BinTree&lt;'a&gt;) : 'a list =
      match tree with
      | Leaf -&gt; []
      | Node(x,l,r) -&gt; (inOrder l) @ [x] @ (inOrder r)
  </code></pre>
  
  <p>Now I want to use this function to 'map' over all the notes and apply a function that is given as a parameter. It should take a function and a tree and then return a tree. This is what I have so far:</p>
  
  <pre><code>let mapInOrder f t = 
      inOrder t
      |&gt; Map.ofList
  </code></pre>
  
  <p><strong>For example, if I give the function this input:</strong></p>
  
  <pre><code>mapInOrder float (Node(1,Node(2,Leaf,Leaf),Node(3,Leaf,Leaf)));;
  </code></pre>
  
  <p><strong>I want the output:</strong></p>
  
  <pre><code>(Node(1.0,Node(2.0,Leaf,Leaf),Node(3.0,Leaf,Leaf)))
  </code></pre>