Skip to content

Instantly share code, notes, and snippets.

@iskandr
Created December 14, 2011 23:34
Show Gist options
  • Save iskandr/1479118 to your computer and use it in GitHub Desktop.
Save iskandr/1479118 to your computer and use it in GitHub Desktop.
logical operators
val rec iter = fn 0 => (fn f => fn x => x) | n => (fn f => fn x => (f o (iter (n-1) f)) x);
fun conj x y = case (x,y) of (true, true) => true | _ => false;
fun disj x y = case (x,y) of (true, _) => true | (_, true) => true | _ => false;
fun impl x y = case (x,y) of (false, _) => true | (true, true) => true | _ => false;
fun equiv x y = case (x,y) of (false, false) => true | (true, true) => true | _ => false;
fun semifac n = reduce ((op * ), 1, 1, (n div 2), (fn x => 2 * x + n mod 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment