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
fp2025:lab03 [2025/03/11 17:28]
pdmatei
fp2025:lab03 [2026/03/23 11:31] (current)
silviu
Line 23: Line 23:
  
  
-**3.4.** Write a function ''​foldMap''​ which takes values $math[a_1, a_2, \ldots, a_k] from a range and computes $math[f(a_1)\;​op\;​f(a_2)\;​op\;​\ldots f(a_k)].+**3.4.** Write a function ''​foldMap''​ which takes values $math[a_1, a_2, \ldots, a_k] from a range and computes $math[f(a_1)\;​op\;​f(a_2)\;​op\;​\ldots ​\;op\;f(a_k)].
 <code scala> <code scala>
 def foldMap(op: (Int,Int) => Int, f: Int => Int)(start: Int, stop: Int): Int = ??? def foldMap(op: (Int,Int) => Int, f: Int => Int)(start: Int, stop: Int): Int = ???
Line 47: Line 47:
 </​code>​ </​code>​
  
-**3.8.** We define ''​Line2D''​ to be lines in a 2-dimensional space, and we represent them as functions. Write a function which takes a Line2D and translates it up on the Ox axis by a given offset. For instance, translateOx of 2 on y=x+1 will return y=x+3.+**3.8.** We define ''​Line2D''​ to be lines in a 2-dimensional space, and we represent them as functions. Write a function which takes a Line2D and translates it up on the Ox axis by a given offset. For instance, translateOx of 2 on y=2*x+1 will return y=2*x-3.
 <code scala> <code scala>
 type Line2D = Int => Int type Line2D = Int => Int