10.07.2015 Views

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

- 230 -else ... -> ... ->if and (equal (type 2) numb_type) (equal (type TRUE) numb_type)then ...else ... -> ... ->if and (equal numb_type numb_type) (equal numb_type numb_type)then ...else ... -> ... ->if and true falsethen ...else NUMB_ERROR -> ... ->NUMB_ERROR2) i)def issigned N = istype signed_type Ndef ISSIGNED N = MAKE_BOOL (issigned N)def sign = value (select_first (value N))def SIGN N =if issigned Nthen select_first (value N)else SIGN_ERRORdef sign_value N = value (select_second (value N))def VALUE N =if issigned Nthen select_second (value N)else SIGN_ERRORdef sign_iszero N = iszero (sign_value N)ii)def SIGN_ISZERO N =if issigned Nthen MAKE_BOOL (sign_iszero N)else SIGN_ERRORdef SIGN_SUCC N =IF SIGN_ISZERO NTHEN +1ELSEIF SIGN NTHEN MAKE_SIGNED POS (MAKE_NUMB (succ (sign_value N)))ELSE MAKE_SIGNED NEG (MAKE_NUMB (pred (sign_value N)))def SIGN_PRED N =IF SIGN_ISZERO NTHEN -1ELSEIF SIGN NTHEN MAKE_SIGNED POS (MAKE_NUMB (pred (sign_value N)))ELSE MAKE_SIGNED NEG (MAKE_NUMB (succ (sign_value N)))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!