types and classes Flashcards
type
collections of related values
classes
collections of types that support certain overloaded methods
statically typed
types are determined at compile time
strongly typed
the type cannot be changed once assigned to a value
type errors
applying a function to arguments of the wrong type
what is the difference between a list and a tuple
tuples are finite, can be different types and cant have only one value
function
a mapping of values of one type to another
polymorphic functions
its type contains one or more type variables or can be used with different types
what makes a polymorphic function overloaded
if its type contains one or more class constraints
immutability
the value of variables cannot be changed
impure functions
you can get a different result each time as they depend on the state of the world (e.g. user input)
pure functions
with the same input youll get the same results
..
a function that generates a list of numbers based on the values either side of it