(no title)
samthecoy | 5 years ago
divTenBy :: Double -> Double
divTenBy n = 10 / n
If you actually call the above function you get a runtime exception. We really don't like functions that do this; they are called partial.samthecoy | 5 years ago
divTenBy :: Double -> Double
divTenBy n = 10 / n
If you actually call the above function you get a runtime exception. We really don't like functions that do this; they are called partial.
Athas|5 years ago
jsmith45|5 years ago
the_af|5 years ago
It's "partial" because it's not defined for 0.
a_wild_dandan|5 years ago
wetmore|5 years ago
f :: Int -> Bool
f 0 = True
f 1 = False
f n = f (n + 1)
is surjective onto Bool but also partial (doesn't return for n > 1). In Haskell we say that when a function doesn't return, the output is bottom, written as ⊥.
You could say that a function f : A -> B is partial if f^{-1}(B \ ⊥) is surjective.
unknown|5 years ago
[deleted]
curtisf|5 years ago
unknown|5 years ago
[deleted]