Compound Calculus

05-Jan-2014 06:54AM

So Compound Calculus is an extension to lambda calculus meant to look a bit like Lisp, though not quite, because we don't have types yet. I'll add more on this later, but for now, here is a definition of "select" using compound calculus-ish data structures within bondi.

let rec select1 =
  fun f x -> if isPair x 
    then (append (select1 f (car x)) (select1 f (cdr x))) 
    else (if (f x) 
      then [x] 
      else []);;

let rec update1 =
  fun f u x -> if isPair x 
    then (append (update1 f u (car x)) (update1 f u (cdr x))) 
    else (if (f x) 
      then [(u x)] 
      else []);;