Flashcards
CMPT 340

Cards in this deck (37)
- 1(T/F) Programs are collections of functions?True
- 2A mapping from one set (domain) to another set (range) ?Function
- 3How to write comments in haskell?Start a line with "--" for single line comments.
For multi line comments enclose the comment in "{-" and "-}" - 4What is "=" in haskellIt is the equation operator. (Not assignment operator)
- 5Is "=" the assignment operator in haskell?No, it is the equation operator.
- 6A set of bindings (Haskell)Environment
- 7Binds names to values.A definition
- 8In the definition square :: Integer -> Integer square x = x * x What is the formal name of the argument given to the function?x
- 9How is an expression evaluated in Haskell?Looking up names in the environment
Replacing the names with their values
Carrying out the needed operations - 10Haskell is lazy. What does this mean?An expression is evaluated only if its value is needed.
- 11What is the form of an if statement in haskell?if e1 then e2 else e3
- 12What is the difference between these two definitions smaller :: (Integer, Integer) -> Integer smaller (x, y) = if (x < y) then x else y or smaller :: Integer -> Integer -> Integer smaller x y = if (x < y) then x else yIn the first definition. The pair notation is a container. this is one argument with 2 sub-components.
In the second definition. Each parameter is handled separately; they are not a single unit - 13How would this function definition look in a math textbook?


- 14(T/F) Patterns are checked in orderTrue
- 15(T/F) Patterns with literal values are tests of equality.True
- 16(T/F) Patterns with names bind the name to the given value.True
- 17How do you create a local binding? (Haskell)Use the where clause.
- 18What does the where clause do? (Haskell)Creates a local binding.
- 19Haskell is purely functional. What does this mean?The value of an expression depends only on the components of the expression.
- 20Haskell is purely functional. What are 4 ways this effects the language?Allows programmers to use functions in powerful ways
Side-effects like I/O are localized and cannot have hidden effects on other functions.
No mutation, pointers
Functions are "first-class" values - 21Haskell is strongly typed. What does this mean?The type of an expression can be inferred from the expression itself.
This means haskell has no silly bugs, type sigs' are a key part of the function definiton. Haskells type system uses a powerful inference engine. - 22What is a polymorphic function?A function that can be applied to data of many different types
- 23How is polymorphism acheived in haskell?Through the use of type variables and type conditions
This has the benefit of code reuse - 24Haskell uses Lazy evaluation. What does this mean?An expression is only evaluated when the value is needed.
- 25In Haskell functions are first-class objects. What does this mean?They can be easily passed as arguments to other functions.
Can easily be created on the fly
Can have names, but can also be anonymous - 26What do you use to compile haskell?The GHC compiler
- 27Is whitespace significant in haskell?Whitespace used for indentation is significant. Whatespace outside of indentation isn't.
- 28(T/F) In Haskell type identifiers are always capitalized?True
- 29(T/F) In Haskell function identifiers are always capitalized?False, they are always lower case
- 30What are the five basic Haskell data types?booleans: Bool
integers: Int, Integer
floating point numbers: Float, Double
characters: Char
strings: String - 31What is the name of this operator: ::The type expression operator. It is pronounced is of type
- 32Maps input types to an output type (Haskell)Function
- 33What operator is this -> (Haskell)The type operator, it is pronounced 'to'.
A functions type has at least one - 34Is Int −> Int −> Int equal to (Int −> Int) −> Int or Int −> (Int −> Int)Int −> (Int −> Int)
- 35What does strong typing mean? (Haskell?Every syntactically correct expression has an unambiguous type.
The type of an expression can be deduced from the expression itself.
Any expression whose type is ambiguous or inconsistent is rejected as incorrect - 36(T/F) Haskell is able to deduce type signatures?True
- 37—
Information
- Description
- Computer Science Flashcards on CMPT 340, created by James Scarrow on 13/01/2019.
- Created by
- James Scarrow
- Views
- 0
- Rating