title: conversion from decimal to binary in SML
body: <p>I have the following formula </p>
  
  <pre><code>fun foo 0 = [0] 
    | foo num = let val l =  (num mod 2)::foo(num div 2) in
             rev l
             end;
  </code></pre>
  
  <p>which is supposed to convert from decimal to binary.It has the following signature</p>
  
  <pre><code>val foo = fn : int -&gt; int list
  </code></pre>
  
  <p>I am not sure where exactly I am getting things wrong as I am getting incorrect results.May someone help me figure out where I am making the error?</p>