--will this throw an error?
x = undefined && undefined
--no. undefined never gets evaluated. it just shoves undefined into x
False && undefined
--outputs:
False
--because since the first arg is false, second never gets evaluated
True && undefined
--error, because since the first arg is true, it tries to eval the second
first100Ints = [1 .. 100]
allIntegers = [1 ..]
--defining infinite lists in instantaenous because it doesnt involve evaluation
--you can even use subsets of infinite lists and thats fine
--you can also try to print an infinite list but obviously that will never terminate.
--numbering characters in a string
numberChars :: String -> [(Int, Char)]
numberChars s = zip [1 .. n] s
where
n = length s
-- with infinite data structs:
numberChars :: String -> [(Int, Char)]
numberChars s = zip [1 ..] s