Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pp:2023:haskell:l07 [2023/04/22 11:30]
tpruteanu [Evaluation order]
pp:2023:haskell:l07 [2023/04/27 01:17] (current)
mihai.udubasa [Lambda calculus as a programming language (optional)] fix typo
Line 81: Line 81:
 **7.1.2. ** Evaluate in both **Normal Order** and **Applicative Order** the following expressions:​ **7.1.2. ** Evaluate in both **Normal Order** and **Applicative Order** the following expressions:​
   - $ \lambda x.\lambda y.(x \ y \ x) \ \lambda x.\lambda y.x \ (\lambda x.\lambda y.\lambda z.(x \ z \ y) \ \lambda x.\lambda y.y)$   - $ \lambda x.\lambda y.(x \ y \ x) \ \lambda x.\lambda y.x \ (\lambda x.\lambda y.\lambda z.(x \ z \ y) \ \lambda x.\lambda y.y)$
-  - $ \lambda x.y \ \lambda x.(x \ x) \ \lambda x.(x \ x)$+  - $ \lambda x.y \ (\lambda x.(x \ x) \ \lambda x.(x \ x))$
  
 ==== Lambda calculus as a programming language (optional) ==== ==== Lambda calculus as a programming language (optional) ====
  
 The [[https://​en.wikipedia.org/​wiki/​Church%E2%80%93Turing_thesis | Church-Turing thesis]] asserts that any //​computable//​ function can be computed using lambda calculus (or Turing Machines or equivalent models). \\ The [[https://​en.wikipedia.org/​wiki/​Church%E2%80%93Turing_thesis | Church-Turing thesis]] asserts that any //​computable//​ function can be computed using lambda calculus (or Turing Machines or equivalent models). \\
-For the curios, a series of additional exercises covering this topic can be found here: [[pp:​2023:​haskell:​l07-extra|Lambda Calculus as a programming language]]. \\+For the curious, a series of additional exercises covering this topic can be found here: [[pp:​2023:​haskell:​l07-extra|Lambda Calculus as a programming language]]. \\
  
 ===== 7.2 Intro to Haskell ===== ===== 7.2 Intro to Haskell =====
Line 108: Line 108:
 **7.2.2.** Implement a tail-recursive function that computes the greatest common divisor of two natural numbers. **7.2.2.** Implement a tail-recursive function that computes the greatest common divisor of two natural numbers.
 <code haskell> <code haskell>
-gcd :: Int -> Int -> Int +mygcd :: Int -> Int -> Int 
-gcd a b = undefined+mygcd a b = undefined
 </​code>​ </​code>​
 **7.2.3.** Implement the function ''​mySqrt'' ​ which computes the square root of an integer $ a $. **7.2.3.** Implement the function ''​mySqrt'' ​ which computes the square root of an integer $ a $.
Line 122: Line 122:
 } }
 </​code>​|<​code haskell> ​ </​code>​|<​code haskell> ​
-f l = case l of {+f l = case l of
   [] -> ...   [] -> ...
   (x:xs) -> ...   (x:xs) -> ...
-} 
 </​code>​ | <code haskell> </​code>​ | <code haskell>
 f [] = ... f [] = ...
Line 134: Line 133:
 </​code>​ | </​code>​ |
  
-**7.2.4.** Implement funtions ''​minimum''​ and ''​maximum''​ that take a list of ints, and return the smallest/​biggest value in the list.+**7.2.4.** Implement funtions ''​mymin''​ and ''​mymax''​ that take a list of ints, and return the smallest/​biggest value in the list.
  
 **7.2.5.** Implement a function ''​unique''​ that takes a list of ints, and removes all duplicates. **7.2.5.** Implement a function ''​unique''​ that takes a list of ints, and removes all duplicates.