Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

COMPSCI 1JC3 C01 Introduction to Computational Thinking Fall 2024 Discussion Session Shahab Asoodeh Department of Computing and Software McMaster University September 12, 2024 Admin Exercises 01 is due on Sunday, Se...

COMPSCI 1JC3 C01 Introduction to Computational Thinking Fall 2024 Discussion Session Shahab Asoodeh Department of Computing and Software McMaster University September 12, 2024 Admin Exercises 01 is due on Sunday, September 15, at 11:59pm S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 2/10 Last lecture Currying functions: translating a function that takes multiple arguments into a sequence of functions, each taking a single argument. In other words, translating an n-ary function into a sequence of unary functions. Interpreter vs. Compilers Executing Haskell codes line-by-line vs. translating it into an optimized native machine code. Expression: Syntactic entity that denotes a value. For instance, all functions are valid expressions. Paradoxes: Curry’s and liar S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 3/10 Review What is a data type? S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 4/10 Review What is a data type? I a syntactic entity that denotes a collection of values of similar form. S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 4/10 Review What is a data type? I a syntactic entity that denotes a collection of values of similar form. Which ones of the following are not a valid type? I Integer ! Integer I I Integer⇥Integer Boolean Enteger I Integer ! Integer! Integer a I Int⇥Int I Integer ! Integer! Integer! Integer IntX int lint , int S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 4/10 Review Consider the following piece of code: a:: Integer a = “5” Do we get a type error? Yes ! S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 5/10 Review Let f : Z ! Q be a function given by x 7! 1 (x 1)2. Is it injective? x= 1 - 2- / On S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 6/10 Review Let f : Z ! Q be a function given by x 7! 1 (x 1)2. Is it injective? T Let f : N ! Q be a function given by x 7! 1 (x 1)2. Is it injective? E S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 6/10 Review Consider the following function f :: (Integer, Integer) ! Integer. Integer I - What are the types of its input and output? & L Integer X Integer Integer , Integer/ S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 7/10 Review f : Integer- Enteger > Intega- Integ - Consider the following function f :: (Integer, Integer) ! Integer. What are the types of its input and output? How about for this function: g :: Integer ! Integer ! Integer. Integer output = Integer Integer Exput = out, elegan S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 7/10 Review Define f :: Integer ! Integer ! Integer f a b = a2 + b 2. Is f 2 a legitimate expression in Haskell? S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 8/10 Review Define f :: Integer ! Integer ! Integer f23 2 2 f a b =a +b. Is f 2 a legitimate expression in Haskell? How about f (2, 3)? S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 8/10 Watch Video 02d. S. Asoodeh COMPSCI 1JC3 C01 Fall 2024: Discussion Session 10/10

Use Quizgecko on...
Browser
Browser