Professional Documents
Culture Documents
CNG242 Lecture 1 Haskellsomeintro
CNG242 Lecture 1 Haskellsomeintro
• Prelude> 2+17
• Prelude> (True && False) || False && (False||True)
• Functions are usually prefix
– Prelude> min 5 30
– Prelude> min(max(min 5 30) 3) 4
First functions
• Use any text editor.
• Functions always start with lowercase letters
– square x = x*x
– square2 x y= square x + square y
– squareSmall x y= (if x >y then square y else square x)
• Write a function which returns the cube of the smallest of 3 numbers. (assume the inputs
are not equal)