Class: CSE 114A Subject: computer-science haskell Date: 2026-01-28 Teacher: **Prof. Miller
Functions, Types, let & where
Functions
in_range min max x =
x >= min && x <= max
in_range 0 5 3
=> True
in_range 4 5 3
=> FalseFunctions(let)
- the let keyword let’s you store expressions in intermediary variables
in_range min max x =
let in_lower_bound = min <= x
in_upper_bound = max >= x
in
in_lower_bound && in_upper_boundFunctions(where)
in_range min max x = ilb && iub
where
ilb = min <= x
iub = max >= xFunctions(if)
in_range min max x =
if ilb then iub else False
where
ilb = min <= x
iub max >= x Types
x :: Integer
x = 1
y :: Bool
y = True
z :: Float
z = 3.1415Types(Functions)
in_range :: Integer -> Integer -> Integer -> Bool -- 3 Integer args, Bool ret
in_range min max x =
x >= min && x <= max
in_range 0.5 1.5 1 -- Type error
in_range 0 5 3 -- Correct