SICP Exercises in F#, Section 1.1.6

NOTE: No exercises necessary for section 1.1.5

> let abs = function
 | n when n > 0 -> n
 | n when n  -n
 | _ -> 0;;


val abs : int -> int

> let abs x = 
 match x with
 | _ when x  -x
 | _ -> x;;

val abs : int -> int

> abs -12;;
val it : int = 12
> abs 12;;
val it : int = 12
> abs 0;;
val it : int = 0
> let abs x =
 if (x  int

> let r1 x = 
 (x > 5) && (x  bool

> r1 5;;
val it : bool = false
> r1 6;;
val it : bool = true
Advertisements

0 Responses to “SICP Exercises in F#, Section 1.1.6”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: