Week 1 Flashcards
(14 cards)
What is a Function?
Transforms information received on its inputs to info transmitted on its output
What is a Guard (+special final guard)?
A Guard is a boolean expression that must be true for the equation to apply
The special final guard, otherwise is always true
How do you write the application of a function f to an argument x in programming?
Always written f x (instead of f(x) )
or f a b c d (spaces between arguments)
What are Types?
Set of values with the same usage and behaviour
All of values in these sets are same kind of thing, eg. Integers / Strings / Floats / Characters / Booleans only
What is the purpose of a Type System?
to prevent errors during the execution of a process
What is Typechecking?
Ensures types are used consistently, so these errors are avoided
What is Dynamic Typechecking?
If typechecking happens during program execution, then we have Dynamic Typechecking
What is Name Space Pollution?
Namespace pollution occurs when too many identifiers (e.g., variables, functions) are defined in the same scope, making it hard to track and manage them. It increases the risk of naming conflicts and bugs.
Having all functions at the top level of a script can lead to Name Space Pollution
What are Local Definitions?
Local definitions are variables, functions, or objects declared within a specific block of code (e.g., a function, loop, or conditional block). They are accessible only within that block and do not affect the wider program
Prevents Name Space Pollution
Eg. Where, Let etc..
What does the Where definition do?
Allows one to name a value, and to use it in an expression
eg. in Haskell
result = x + y
where
x = 5
y = 10
What has happened to Hardware and Software prices over the years?
Hardware prices have fallen whereas software prices have increased
What is Functional Programming?
Programs Represented by Expressions:
In functional programming, everything is expressed in terms of expressions (e.g., mathematical functions) rather than statements.
Example: Instead of loops or imperative instructions, functional programming focuses on expressions like map, filter, or recursive functions.
Computation is Implemented by Reduction:
Computation occurs through reducing expressions to their simplest form (like evaluating a math equation).
Programs represented by expressions
Computation is implemented by reduction
What is Logical Programming?
Core Concept: Programs are defined using facts and rules that describe relationships and logic.
A programming paradigm where computation is based on formal logic (facts and rules).
Key Features:
Declarative: Focuses on what to solve, not how.
Uses rules and facts to infer conclusions.
No explicit flow control; the program searches for solutions.
Programs represented by clauses
Computation represented by proof
The foundation is first-order logic
What are Finite State Machines?
Programs represented by state machines
Computation is represented by transitions